From 7331bc2a9dca44bb719ce4a4f8bd124d0e4302d3 Mon Sep 17 00:00:00 2001 From: Ali Date: Tue, 20 Aug 2024 14:05:30 +0200 Subject: [PATCH] _dynamic_info_firecrest_version updated --- aiida_firecrest/transport.py | 29 ++++++++++++++++++++++------- pyproject.toml | 2 +- tests/conftest.py | 22 ++++++++++++++++------ 3 files changed, 39 insertions(+), 14 deletions(-) diff --git a/aiida_firecrest/transport.py b/aiida_firecrest/transport.py index c3e5bec..60f9eef 100644 --- a/aiida_firecrest/transport.py +++ b/aiida_firecrest/transport.py @@ -158,16 +158,31 @@ def _dynamic_info_firecrest_version( small_file_size_mb=0.0, api_version="100.0.0", # version is irrelevant here ) + + parameters = transport._client.parameters() try: - transport.listdir(transport._cwd.joinpath(temp_directory), recursive=True) - _version = "1.16.0" - except Exception: - # all sort of exceptions can be raised here, but we don't care. Since this is just a workaround - _version = "1.15.0" + info = next( + ( + item + for item in parameters["general"] # type: ignore[typeddict-item] + if item["name"] == "FIRECREST_VERSION" + ), + None, + ) + if info is not None: + _version = str(info["value"]) + else: + raise KeyError + except KeyError as err: + raise click.BadParameter( + "Could not get the version of the FirecREST server" + ) from err + + if parse(_version) < parse("1.15.0"): + raise click.BadParameter(f"FirecREST api version {_version} is not supported") click.echo( - click.style("Fireport: ", bold=True, fg="magenta") - + f"Deployed version of FirecREST api: v{_version}" + click.style("Fireport: ", bold=True, fg="magenta") + f"FirecRESTapi: {_version}" ) return _version diff --git a/pyproject.toml b/pyproject.toml index 401a5e4..22d554d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,7 +54,7 @@ exclude = [ [tool.ruff] line-length = 120 -extend-select = ["A", "B", "C4", "ICN", "ISC", "N", "RUF", "SIM"] +lint.extend-select = ["A", "B", "C4", "ICN", "ISC", "N", "RUF", "SIM"] # extend-ignore = [] [tool.isort] diff --git a/tests/conftest.py b/tests/conftest.py index df53355..785aaa7 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -324,6 +324,20 @@ def parameters( "value": "Slurm", } ], + "general": [ + { + "description": "FirecREST version.", + "name": "FIRECREST_VERSION", + "unit": "", + "value": "v1.16.1-dev.9", + }, + { + "description": "FirecREST build timestamp.", + "name": "FIRECREST_BUILD", + "unit": "", + "value": "2024-08-16T15:58:47Z", + }, + ], "storage": [ { "description": "Type of object storage, like `swift`, `s3v2` or `s3v4`.", @@ -361,17 +375,13 @@ def parameters( ], "utilities": [ { - "description": "The maximum allowable file size for various operations" - " of the utilities microservice", + "description": "The maximum allowable file size for various operations of the utilities microservice.", "name": "UTILITIES_MAX_FILE_SIZE", "unit": "MB", "value": "5", }, { - "description": ( - "Maximum time duration for executing the commands " - "in the cluster for the utilities microservice." - ), + "description": "Maximum time duration for executing the commands in the cluster for the utilities microservice.", "name": "UTILITIES_TIMEOUT", "unit": "seconds", "value": "5",