Skip to content

Commit

Permalink
Fixed config init time. Set default retriable configs for init tapis …
Browse files Browse the repository at this point in the history
…client calls.
  • Loading branch information
NotChristianGarcia committed Sep 17, 2024
1 parent e086884 commit b5cf4dd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
6 changes: 3 additions & 3 deletions Dockerfile-tests
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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" ]
#ENTRYPOINT ["pytest", "--verbose", "/home/tapis/tapipy-tests.py"]
ENTRYPOINT [ "/home/tapis/tests/run.sh" ]
19 changes: 11 additions & 8 deletions tapipy/tapis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down

0 comments on commit b5cf4dd

Please sign in to comment.