From b5cf4dd3332a05269ba8533af7ec45506d5c884a Mon Sep 17 00:00:00 2001 From: "Christian R. Garcia" Date: Tue, 17 Sep 2024 16:28:21 -0700 Subject: [PATCH] Fixed config init time. Set default retriable configs for init tapis client calls. --- Dockerfile-tests | 6 +++--- tapipy/tapis.py | 19 +++++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Dockerfile-tests b/Dockerfile-tests index c803df2..e300ccd 100644 --- a/Dockerfile-tests +++ b/Dockerfile-tests @@ -14,7 +14,7 @@ RUN python -m pip install --upgrade pip # Moving files ADD tests/tapipy-tests.py /home/tapis/tapipy-tests.py -#ADD tests /home/tapis/tests +ADD tests /home/tapis/tests # Add tapipy files and build with Poetry build. ADD . /home/tapis/tapipy-install-dir @@ -26,5 +26,5 @@ RUN pip install *.whl WORKDIR /home/tapis # Testing -ENTRYPOINT ["pytest", "--verbose", "/home/tapis/tapipy-tests.py"] -#ENTRYPOINT [ "/home/tapis/tests/run.sh" ] \ No newline at end of file +#ENTRYPOINT ["pytest", "--verbose", "/home/tapis/tapipy-tests.py"] +ENTRYPOINT [ "/home/tapis/tests/run.sh" ] \ No newline at end of file diff --git a/tapipy/tapis.py b/tapipy/tapis.py index d545d24..b552a95 100644 --- a/tapipy/tapis.py +++ b/tapipy/tapis.py @@ -341,8 +341,9 @@ def __init__(self, tapi_client): def reload_tenants(self): try: - sites = self.tapi_client.tenants.list_sites() - tenants = self.tapi_client.tenants.list_tenants() + # _config required to ensure user client-level config isn't applied during Tapipy initialization + sites = self.tapi_client.tenants.list_sites(_config=Config()) + tenants = self.tapi_client.tenants.list_tenants(_config=Config()) except Exception as e: raise errors.BaseTapyException(f"Unable to retrieve sites and tenants from the Tenants API. e: {e}") for t in tenants: @@ -495,6 +496,14 @@ def __init__(self, # method signature should be def fn(op: Opertaion, response: Response, **kwargs) self.plugin_on_call_post_request_callables = [] + self.config = config + if type(config) == dict: + self.config = Config(**config) + # Set the configuration object + if type(config) not in [Config, dict]: + raise TypeError("Tapis Client Config must be an instance of 'Config' or a dictionary") + + # we lazy-load the tenant_cache to prevent making a call to the Tenants API when not needed. if tenants: self.tenant_cache = tenants @@ -507,13 +516,7 @@ def __init__(self, if t.base_url == base_url: self.tenant_id = t.tenant_id - # Set the configuration object - if type(config) not in [Config, dict]: - raise TypeError("Tapis Client Config must be an instance of 'Config' or a dictionary") - self.config = config - if type(config) == dict: - self.config = Config(**config) for p in plugins: # call each plugin's on_tapis_client_instantiation() function with all args passed in.