Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(yaml): V2D-1504 Failure in Deserializing Successful Response When Creating SeldonDeployment with SDK #65

Merged
merged 1 commit into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ python:
make -C python licenses
# Apply patch
git apply templates/python/metadata_tags_metrics.patch
git apply templates/python/int_or_string.patch

3 changes: 0 additions & 3 deletions python/docs/IntOrString.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

82 changes: 1 addition & 81 deletions python/seldon_deploy_sdk/models/int_or_string.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

115 changes: 115 additions & 0 deletions templates/python/int_or_string.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
diff --git a/python/docs/IntOrString.md b/python/docs/IntOrString.md
index ef3be07..e4c51e9 100644
--- a/python/docs/IntOrString.md
+++ b/python/docs/IntOrString.md
@@ -3,9 +3,6 @@
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
-**int_val** | **int** | | [optional]
-**str_val** | **str** | | [optional]
-**type** | [**Type**](Type.md) | | [optional]
Comment on lines +9 to +11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: I don't think this should be deleted, since elsewhere we still use the IntOrString type? [1]

[1]

$ rg IntOrString                                                                                                                       
swagger-v1alpha1.yml
2505:        $ref: '#/definitions/IntOrString'
2657:  IntOrString:
2671:      IntOrString is a type that can hold an int32 or a string.  When used in
6056:        $ref: '#/definitions/IntOrString'
6058:        $ref: '#/definitions/IntOrString'
6560:        $ref: '#/definitions/IntOrString'
6562:        $ref: '#/definitions/IntOrString'
7008:        $ref: '#/definitions/IntOrString'
7230:        $ref: '#/definitions/IntOrString'
7312:    title: Type represents the stored type of IntOrString.

python/README.md
319: - [IntOrString](docs/IntOrString.md)

python/docs/HTTPGetAction.md
9:**port** | [**IntOrString**](IntOrString.md) |  | [optional]

python/docs/ServicePort.md
11:**target_port** | [**IntOrString**](IntOrString.md) |  | [optional]

python/docs/TCPSocketAction.md
7:**port** | [**IntOrString**](IntOrString.md) |  | [optional]

python/docs/SeldonPdbSpec.md
6:**max_unavailable** | [**IntOrString**](IntOrString.md) |  | [optional]
7:**min_available** | [**IntOrString**](IntOrString.md) |  | [optional]

python/docs/RollingUpdateDeployment.md
6:**max_surge** | [**IntOrString**](IntOrString.md) |  | [optional]
7:**max_unavailable** | [**IntOrString**](IntOrString.md) |  | [optional]

python/test/test_int_or_string.py
19:from seldon_deploy_sdk.models.int_or_string import IntOrString  # noqa: E501
23:class TestIntOrString(unittest.TestCase):
24:    """IntOrString unit test stubs"""
32:    def testIntOrString(self):
33:        """Test IntOrString"""
35:        # model = seldon_deploy_sdk.models.int_or_string.IntOrString()  # noqa: E501

python/docs/IntOrString.md
1:# IntOrString

python/seldon_deploy_sdk/__init__.py
156:from seldon_deploy_sdk.models.int_or_string import IntOrString

python/seldon_deploy_sdk/models/rolling_update_deployment.py
34:        'max_surge': 'IntOrString',
35:        'max_unavailable': 'IntOrString'
61:        :rtype: IntOrString
71:        :type: IntOrString
82:        :rtype: IntOrString
92:        :type: IntOrString

python/seldon_deploy_sdk/models/seldon_pdb_spec.py
34:        'max_unavailable': 'IntOrString',
35:        'min_available': 'IntOrString'
61:        :rtype: IntOrString
71:        :type: IntOrString
82:        :rtype: IntOrString
92:        :type: IntOrString

python/seldon_deploy_sdk/models/tcp_socket_action.py
35:        'port': 'IntOrString'
84:        :rtype: IntOrString
94:        :type: IntOrString

python/seldon_deploy_sdk/models/service_port.py
39:        'target_port': 'IntOrString'
194:        :rtype: IntOrString
204:        :type: IntOrString

python/seldon_deploy_sdk/models/__init__.py
128:from seldon_deploy_sdk.models.int_or_string import IntOrString

python/seldon_deploy_sdk/models/int_or_string.py
20:class IntOrString(object):
46:        """IntOrString - a model defined in Swagger"""  # noqa: E501
62:        """Gets the int_val of this IntOrString.  # noqa: E501
65:        :return: The int_val of this IntOrString.  # noqa: E501
72:        """Sets the int_val of this IntOrString.
75:        :param int_val: The int_val of this IntOrString.  # noqa: E501
83:        """Gets the str_val of this IntOrString.  # noqa: E501
86:        :return: The str_val of this IntOrString.  # noqa: E501
93:        """Sets the str_val of this IntOrString.
96:        :param str_val: The str_val of this IntOrString.  # noqa: E501
104:        """Gets the type of this IntOrString.  # noqa: E501
107:        :return: The type of this IntOrString.  # noqa: E501
114:        """Sets the type of this IntOrString.
117:        :param type: The type of this IntOrString.  # noqa: E501
144:        if issubclass(IntOrString, dict):
160:        if not isinstance(other, IntOrString):

python/seldon_deploy_sdk/models/http_get_action.py
37:        'port': 'IntOrString',
145:        :rtype: IntOrString
155:        :type: IntOrString

Copy link
Contributor Author

@ChewieSC ChewieSC Nov 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just as a note for why this works:
in __deserialize_model (api_client.py) there is this:

if (not klass.swagger_types and
        not self.__hasattr(klass, 'get_real_child_model')):
    return data

which is now true (no swagger_type no more), so we return data and thereby supply the intended base type (i.e. the int or string - which K8s expects).

Tested with int and string examples.


[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

diff --git a/python/seldon_deploy_sdk/models/int_or_string.py b/python/seldon_deploy_sdk/models/int_or_string.py
index e9c49bc..182fadf 100644
--- a/python/seldon_deploy_sdk/models/int_or_string.py
+++ b/python/seldon_deploy_sdk/models/int_or_string.py
@@ -31,95 +31,15 @@ class IntOrString(object):
and the value is json key in definition.
"""
swagger_types = {
- 'int_val': 'int',
- 'str_val': 'str',
- 'type': 'Type'
}

attribute_map = {
- 'int_val': 'IntVal',
- 'str_val': 'StrVal',
- 'type': 'Type'
}

- def __init__(self, int_val=None, str_val=None, type=None): # noqa: E501
+ def __init__(self): # noqa: E501
"""IntOrString - a model defined in Swagger""" # noqa: E501
-
- self._int_val = None
- self._str_val = None
- self._type = None
self.discriminator = None

- if int_val is not None:
- self.int_val = int_val
- if str_val is not None:
- self.str_val = str_val
- if type is not None:
- self.type = type
-
- @property
- def int_val(self):
- """Gets the int_val of this IntOrString. # noqa: E501
-
-
- :return: The int_val of this IntOrString. # noqa: E501
- :rtype: int
- """
- return self._int_val
-
- @int_val.setter
- def int_val(self, int_val):
- """Sets the int_val of this IntOrString.
-
-
- :param int_val: The int_val of this IntOrString. # noqa: E501
- :type: int
- """
-
- self._int_val = int_val
-
- @property
- def str_val(self):
- """Gets the str_val of this IntOrString. # noqa: E501
-
-
- :return: The str_val of this IntOrString. # noqa: E501
- :rtype: str
- """
- return self._str_val
-
- @str_val.setter
- def str_val(self, str_val):
- """Sets the str_val of this IntOrString.
-
-
- :param str_val: The str_val of this IntOrString. # noqa: E501
- :type: str
- """
-
- self._str_val = str_val
-
- @property
- def type(self):
- """Gets the type of this IntOrString. # noqa: E501
-
-
- :return: The type of this IntOrString. # noqa: E501
- :rtype: Type
- """
- return self._type
-
- @type.setter
- def type(self, type):
- """Sets the type of this IntOrString.
-
-
- :param type: The type of this IntOrString. # noqa: E501
- :type: Type
- """
-
- self._type = type
-
def to_dict(self):
"""Returns the model properties as a dict"""
result = {}