From 3dc8403e10366db1152eaf78390296412716f2c1 Mon Sep 17 00:00:00 2001 From: Julian Taylor Date: Mon, 7 Nov 2022 09:05:14 +0100 Subject: [PATCH] [Python] pass api_client configuration to model deserialize (#13922) The if not passed the models create a new configuration object which configures logging and determines cpu count every time. This causes extreme performance issues when deserializing larger sets of items. See also https://github.com/kubernetes-client/python/issues/1921 --- .../src/main/resources/python-legacy/api_client.mustache | 1 + .../client/petstore/python-asyncio/petstore_api/api_client.py | 1 + samples/client/petstore/python-legacy/petstore_api/api_client.py | 1 + .../client/petstore/python-tornado/petstore_api/api_client.py | 1 + .../client/petstore/python-legacy/petstore_api/api_client.py | 1 + 5 files changed, 5 insertions(+) diff --git a/modules/openapi-generator/src/main/resources/python-legacy/api_client.mustache b/modules/openapi-generator/src/main/resources/python-legacy/api_client.mustache index d5b8a6f2548..de0ef4b9462 100644 --- a/modules/openapi-generator/src/main/resources/python-legacy/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/python-legacy/api_client.mustache @@ -715,6 +715,7 @@ class ApiClient(object): value = data[klass.attribute_map[attr]] kwargs[attr] = self.__deserialize(value, attr_type) + kwargs["local_vars_configuration"] = self.configuration instance = klass(**kwargs) if has_discriminator: diff --git a/samples/client/petstore/python-asyncio/petstore_api/api_client.py b/samples/client/petstore/python-asyncio/petstore_api/api_client.py index 6bdc318161f..7b655dd2771 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/api_client.py +++ b/samples/client/petstore/python-asyncio/petstore_api/api_client.py @@ -692,6 +692,7 @@ class ApiClient(object): value = data[klass.attribute_map[attr]] kwargs[attr] = self.__deserialize(value, attr_type) + kwargs["local_vars_configuration"] = self.configuration instance = klass(**kwargs) if has_discriminator: diff --git a/samples/client/petstore/python-legacy/petstore_api/api_client.py b/samples/client/petstore/python-legacy/petstore_api/api_client.py index 072c932db7e..10d903cb0df 100644 --- a/samples/client/petstore/python-legacy/petstore_api/api_client.py +++ b/samples/client/petstore/python-legacy/petstore_api/api_client.py @@ -691,6 +691,7 @@ class ApiClient(object): value = data[klass.attribute_map[attr]] kwargs[attr] = self.__deserialize(value, attr_type) + kwargs["local_vars_configuration"] = self.configuration instance = klass(**kwargs) if has_discriminator: diff --git a/samples/client/petstore/python-tornado/petstore_api/api_client.py b/samples/client/petstore/python-tornado/petstore_api/api_client.py index 714686f8d6b..2b978d96a8f 100644 --- a/samples/client/petstore/python-tornado/petstore_api/api_client.py +++ b/samples/client/petstore/python-tornado/petstore_api/api_client.py @@ -693,6 +693,7 @@ class ApiClient(object): value = data[klass.attribute_map[attr]] kwargs[attr] = self.__deserialize(value, attr_type) + kwargs["local_vars_configuration"] = self.configuration instance = klass(**kwargs) if has_discriminator: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/api_client.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/api_client.py index 072c932db7e..10d903cb0df 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/api_client.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/api_client.py @@ -691,6 +691,7 @@ class ApiClient(object): value = data[klass.attribute_map[attr]] kwargs[attr] = self.__deserialize(value, attr_type) + kwargs["local_vars_configuration"] = self.configuration instance = klass(**kwargs) if has_discriminator: