From 85f9cd0d60da89e1b2eeee863f98077edcc98c70 Mon Sep 17 00:00:00 2001 From: gibsondan Date: Tue, 26 Nov 2024 17:15:36 -0600 Subject: [PATCH] correctly override k8s ApiClient private method in PatchedApiClient (#26154) Summary: Since this is a private method being overridden, it needs to add the same of the class that defines it due to private name mangling. Test Plan: Log lines confirm that patched implementation is now being called, k8s e2e tests verify that it functionally launches runs and makes other k8s api calls ## Summary & Motivation ## How I Tested These Changes ## Changelog > Insert changelog entry or delete this section. --- .../libraries/dagster-k8s/dagster_k8s/client.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/python_modules/libraries/dagster-k8s/dagster_k8s/client.py b/python_modules/libraries/dagster-k8s/dagster_k8s/client.py index 5874a024b4e3c..26c543f26f1e9 100644 --- a/python_modules/libraries/dagster-k8s/dagster_k8s/client.py +++ b/python_modules/libraries/dagster-k8s/dagster_k8s/client.py @@ -96,7 +96,9 @@ class DagsterK8sJobStatusException(Exception): class PatchedApiClient(ApiClient): # Forked from ApiClient implementation to pass configuration object down into created model # objects, avoiding lock contention issues. See https://github.com/kubernetes-client/python/issues/2284 - def __deserialize_model(self, data, klass): + # Intentionally circumventing private name mangling + # (https://docs.python.org/3/reference/expressions.html#private-name-mangling) of the __deserialize_model method on ApiClient + def _ApiClient__deserialize_model(self, data, klass): """Deserializes list or dict to model. :param data: dict, list. @@ -115,14 +117,14 @@ def __deserialize_model(self, data, klass): for attr, attr_type in six.iteritems(klass.openapi_types): if klass.attribute_map[attr] in data: value = data[klass.attribute_map[attr]] - kwargs[attr] = self.__deserialize(value, attr_type) + kwargs[attr] = self._ApiClient__deserialize(value, attr_type) instance = klass(**kwargs) if hasattr(instance, "get_real_child_model"): klass_name = instance.get_real_child_model(data) if klass_name: - instance = self.__deserialize(data, klass_name) + instance = self._ApiClient__deserialize(data, klass_name) return instance