From 6fea3bb8f730a8f3957e7d8d470a9b3c070c51fd Mon Sep 17 00:00:00 2001 From: Eirini Koutsaniti Date: Thu, 29 Aug 2024 17:23:03 +0200 Subject: [PATCH] Revert "Check for the version of the api through `/status/parameters` (#119)" (#123) This reverts commit 6dcab6239636f73eb7fe9bc075c0fb1d0d94ddef. --- firecrest/AsyncClient.py | 32 +++----------------------------- firecrest/BasicClient.py | 31 +++---------------------------- firecrest/cli/__init__.py | 36 +----------------------------------- firecrest/types.py | 6 +----- 4 files changed, 8 insertions(+), 97 deletions(-) diff --git a/firecrest/AsyncClient.py b/firecrest/AsyncClient.py index 6c014ec..3514213 100644 --- a/firecrest/AsyncClient.py +++ b/firecrest/AsyncClient.py @@ -200,6 +200,7 @@ def __init__( self.polling_sleep_times: list = 250 * [0] #: Disable all logging from the client. self.disable_client_logging: bool = False + self._api_version: Version = parse("1.15.0") self._session = httpx.AsyncClient(verify=self._verify) #: Seconds between requests in each microservice @@ -246,36 +247,9 @@ def __init__( "/tasks": None, } - # Try to set the api version by querying the /status/parameters - # endpoint - try: - general_params = self._api_version = self._get_request( - endpoint="/status/parameters", - ).json()["out"]["general"] - for g in general_params: - if g["name"] == "FIRECREST_VERSION": - self._api_version = parse(g["value"]) - return - - # We want the except block to catch this and set the - # version to the default one - raise Exception - - except Exception: - self.log( - logging.WARNING, - "Could not get the version of the api from firecREST. " - "The version will be set to 1.15.0, but you can manually " - "set it with the method `set_api_version`." - ) - self._api_version = parse("1.15.0") - def set_api_version(self, api_version: str) -> None: - """Set the version of the api of firecrest manually. By default, the - client will query the api (before the first request), through the - /status endpoint. This information is only available for - version>=1.16.1, so for older deployments the default will be 1.15.0. - The version is parsed by the `packaging` library. + """Set the version of the api of firecrest. By default it will be assumed that you are + using version 1.13.1 or compatible. The version is parsed by the `packaging` library. """ self._api_version = parse(api_version) diff --git a/firecrest/BasicClient.py b/firecrest/BasicClient.py index 30171d8..166348e 100644 --- a/firecrest/BasicClient.py +++ b/firecrest/BasicClient.py @@ -157,37 +157,12 @@ def __init__( self.polling_sleep_times: list = [1, 0.5] + 234 * [0.25] #: Disable all logging from the client. self.disable_client_logging: bool = False + self._api_version: Version = parse("1.15.0") self._session = requests.Session() - # Try to set the api version by querying the /status/parameters - # endpoint - try: - general_params = self._api_version = self._get_request( - endpoint="/status/parameters", - ).json()["out"]["general"] - for g in general_params: - if g["name"] == "FIRECREST_VERSION": - self._api_version = parse(g["value"]) - return - - # We want the except block to catch this and set the - # version to the default one - raise Exception - - except Exception: - self.log( - logging.WARNING, - "Could not get the version of the api from firecREST. " - "The version will be set to 1.15.0, but you can manually " - "set it with the method `set_api_version`." - ) - self._api_version = parse("1.15.0") def set_api_version(self, api_version: str) -> None: - """Set the version of the api of firecrest manually. By default, the - client will query the api (before the first request), through the - /status endpoint. This information is only available for - version>=1.16.1, so for older deployments the default will be 1.15.0. - The version is parsed by the `packaging` library. + """Set the version of the api of firecrest. By default it will be assumed that you are + using version 1.13.1 or compatible. The version is parsed by the `packaging` library. """ self._api_version = parse(api_version) diff --git a/firecrest/cli/__init__.py b/firecrest/cli/__init__.py index b46dd6e..769dcfb 100644 --- a/firecrest/cli/__init__.py +++ b/firecrest/cli/__init__.py @@ -218,41 +218,7 @@ def parameters( *info ) - extra_tables = [] - - if "compute" in result: - info = [ - ("Name", "name"), - ("Value", "value"), - ("Unit", "unit"), - ] - if "description" in result["compute"][0]: - info.append(("Description", "description")) - - compute_table = create_table( - "Compute parameters", - result["compute"], - *info - ) - extra_tables.append(compute_table) - - if "general" in result: - info = [ - ("Name", "name"), - ("Value", "value"), - ("Unit", "unit"), - ] - if "description" in result["general"][0]: - info.append(("Description", "description")) - - general_table = create_table( - "General parameters", - result["general"], - *info - ) - extra_tables.append(general_table) - - console.print(storage_table, utilities_table, *extra_tables, overflow="fold") + console.print(storage_table, utilities_table, overflow="fold") except Exception as e: examine_exeption(e) raise typer.Exit(code=1) diff --git a/firecrest/types.py b/firecrest/types.py index 2efcf6a..0d60d7f 100644 --- a/firecrest/types.py +++ b/firecrest/types.py @@ -23,14 +23,10 @@ class Parameter(TypedDict): class Parameters(TypedDict): - """A parameters record, from `status/parameters`. For older versions - of the API `compute` and `system` may not be present. - """ + """A parameters record, from `status/parameters`""" storage: list[Parameter] utilities: list[Parameter] - compute: list[Parameter] - general: list[Parameter] class Service(TypedDict):