Skip to content

Commit

Permalink
correctly override k8s ApiClient private method in PatchedApiClient (d…
Browse files Browse the repository at this point in the history
…agster-io#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.
  • Loading branch information
gibsondan authored Nov 26, 2024
1 parent f73593e commit 85f9cd0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions python_modules/libraries/dagster-k8s/dagster_k8s/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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


Expand Down

0 comments on commit 85f9cd0

Please sign in to comment.