Skip to content

Commit

Permalink
Revert "Check for the version of the api through /status/parameters (
Browse files Browse the repository at this point in the history
…#119)"

This reverts commit 6dcab62.
  • Loading branch information
ekouts authored Aug 29, 2024
1 parent 6dcab62 commit ef7e243
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 97 deletions.
32 changes: 3 additions & 29 deletions firecrest/AsyncClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
31 changes: 3 additions & 28 deletions firecrest/BasicClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
36 changes: 1 addition & 35 deletions firecrest/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 1 addition & 5 deletions firecrest/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit ef7e243

Please sign in to comment.