From 066ab1bea267fa5748f2ec87c0aa9afb8fde15f9 Mon Sep 17 00:00:00 2001 From: Neelay Shah Date: Wed, 26 Nov 2025 12:19:25 +0100 Subject: [PATCH] task(BE-0000): Samia local testing --- CLI_REFERENCE.md | 30 +++++++++++----------- src/aignostics/platform/_authentication.py | 3 +++ src/aignostics/platform/_client.py | 2 ++ src/aignostics/platform/_constants.py | 1 + src/aignostics/platform/_settings.py | 8 ++++++ tests/constants_test.py | 2 ++ 6 files changed, 31 insertions(+), 15 deletions(-) diff --git a/CLI_REFERENCE.md b/CLI_REFERENCE.md index 7a9ce4519..40144d1fe 100644 --- a/CLI_REFERENCE.md +++ b/CLI_REFERENCE.md @@ -14,7 +14,7 @@ $ aignostics [OPTIONS] COMMAND [ARGS]... * `--show-completion`: Show completion for the current shell, to copy it or customize the installation. * `--help`: Show this message and exit. -🔬 Aignostics Python SDK v0.2.195 - built with love in Berlin 🐻 +🔬 Aignostics Python SDK v0.2.199 - built with love in Berlin 🐻 **Commands**: @@ -55,7 +55,7 @@ $ aignostics notebook [OPTIONS] [NOTEBOOK] **Arguments**: -* `[NOTEBOOK]`: Path to the notebook file to run. If not provided, a default notebook will be used. [default: /Users/helmut/Code/python-sdk/src/aignostics/notebook/_notebook.py] +* `[NOTEBOOK]`: Path to the notebook file to run. If not provided, a default notebook will be used. [default: /home/neelay/work/python-sdk/src/aignostics/notebook/_notebook.py] **Options**: @@ -117,7 +117,7 @@ $ aignostics application dump-schemata [OPTIONS] APPLICATION_ID **Options**: * `--application-version TEXT`: Version of the application. If not provided, the latest version will be used. -* `--destination DIRECTORY`: Path pointing to directory where the input and output schemata will be dumped. [default: /Users/helmut/Code/python-sdk] +* `--destination DIRECTORY`: Path pointing to directory where the input and output schemata will be dumped. [default: /home/neelay/work/python-sdk] * `--zip / --no-zip`: If set, the schema files will be zipped into a single file, with the schema files deleted. [default: no-zip] * `--help`: Show this message and exit. @@ -204,7 +204,7 @@ $ aignostics application run execute [OPTIONS] APPLICATION_ID METADATA_CSV_FILE * `--application-version TEXT`: Version of the application. If not provided, the latest version will be used. * `--create-subdirectory-for-run / --no-create-subdirectory-for-run`: Create a subdirectory for the results of the run in the destination directory [default: create-subdirectory-for-run] * `--create-subdirectory-per-item / --no-create-subdirectory-per-item`: Create a subdirectory per item in the destination directory [default: create-subdirectory-per-item] -* `--upload-prefix TEXT`: Prefix for the upload destination. If not given will be set to current milliseconds. [default: 1761499056785.385] +* `--upload-prefix TEXT`: Prefix for the upload destination. If not given will be set to current milliseconds. [default: 1762792479396.364] * `--wait-for-completion / --no-wait-for-completion`: Wait for run completion and download results incrementally [default: wait-for-completion] * `--note TEXT`: Optional note to include with the run submission via custom metadata. * `--due-date TEXT`: Optional soft due date to include with the run submission, ISO8601 format. The scheduler will try to complete the run by this date, taking the subscription tierand available GPU resources into account. @@ -267,7 +267,7 @@ $ aignostics application run upload [OPTIONS] APPLICATION_ID METADATA_CSV_FILE **Options**: * `--application-version TEXT`: Version of the application. If not provided, the latest version will be used. -* `--upload-prefix TEXT`: Prefix for the upload destination. If not given will be set to current milliseconds. [default: 1761499056785.492] +* `--upload-prefix TEXT`: Prefix for the upload destination. If not given will be set to current milliseconds. [default: 1762792479396.5398] * `--onboard-to-aignostics-portal / --no-onboard-to-aignostics-portal`: If set, the run will be onboarded to the Aignostics Portal. [default: no-onboard-to-aignostics-portal] * `--help`: Show this message and exit. @@ -468,7 +468,7 @@ $ aignostics application run result download [OPTIONS] RUN_ID [DESTINATION_DIREC **Arguments**: * `RUN_ID`: Id of the run to download results for [required] -* `[DESTINATION_DIRECTORY]`: Destination directory to download results to [default: /Users/helmut/Library/Application Support/aignostics/results] +* `[DESTINATION_DIRECTORY]`: Destination directory to download results to [default: /home/neelay/snap/code/211/.local/share/aignostics/results] **Options**: @@ -578,7 +578,7 @@ $ aignostics bucket download [OPTIONS] [WHAT]... **Options**: * `--what-is-key / --no-what-is-key`: Specify if 'what' is a single object key. If not specified, 'what' is treated as a regex pattern. [default: no-what-is-key] -* `--destination DIRECTORY`: Destination directory to download the matching objects to. [default: /Users/helmut/Library/Application Support/aignostics/bucket_downloads] +* `--destination DIRECTORY`: Destination directory to download the matching objects to. [default: /home/neelay/snap/code/211/.local/share/aignostics/bucket_downloads] * `--help`: Show this message and exit. ### `aignostics bucket delete` @@ -740,7 +740,7 @@ $ aignostics dataset idc download [OPTIONS] SOURCE [TARGET] **Arguments**: * `SOURCE`: Identifier or comma-separated set of identifiers. IDs matched against collection_id, PatientId, StudyInstanceUID, SeriesInstanceUID or SOPInstanceUID. Example: 1.3.6.1.4.1.5962.99.1.1069745200.1645485340.1637452317744.2.0 [required] -* `[TARGET]`: target directory for download [default: /Users/helmut/Library/Application Support/aignostics/datasets/idc] +* `[TARGET]`: target directory for download [default: /home/neelay/snap/code/211/.local/share/aignostics/datasets/idc] **Options**: @@ -779,7 +779,7 @@ $ aignostics dataset aignostics download [OPTIONS] SOURCE_URL [DESTINATION_DIREC **Arguments**: * `SOURCE_URL`: URL to download. Example: gs://aignx-storage-service-dev/sample_data_formatted/9375e3ed-28d2-4cf3-9fb9-8df9d11a6627.tiff [required] -* `[DESTINATION_DIRECTORY]`: Destination directory to download to [default: /Users/helmut/Library/Application Support/aignostics/datasets/aignostics] +* `[DESTINATION_DIRECTORY]`: Destination directory to download to [default: /home/neelay/snap/code/211/.local/share/aignostics/datasets/aignostics] **Options**: @@ -948,10 +948,10 @@ $ aignostics qupath install [OPTIONS] **Options**: * `--version TEXT`: Version of QuPath to install. Do not change this unless you know what you are doing. [default: 0.6.0-rc5] -* `--path DIRECTORY`: Path to install QuPath to. If not specified, the default installation path will be used.Do not change this unless you know what you are doing. [default: /Users/helmut/Library/Application Support/aignostics] +* `--path DIRECTORY`: Path to install QuPath to. If not specified, the default installation path will be used.Do not change this unless you know what you are doing. [default: /home/neelay/snap/code/211/.local/share/aignostics] * `--reinstall / --no-reinstall`: Reinstall QuPath even if it is already installed. This will overwrite the existing installation. [default: reinstall] -* `--platform-system TEXT`: Override the system to assume for the installation. This is useful for testing purposes. [default: Darwin] -* `--platform-machine TEXT`: Override the machine architecture to assume for the installation. This is useful for testing purposes. [default: arm64] +* `--platform-system TEXT`: Override the system to assume for the installation. This is useful for testing purposes. [default: Linux] +* `--platform-machine TEXT`: Override the machine architecture to assume for the installation. This is useful for testing purposes. [default: x86_64] * `--help`: Show this message and exit. ### `aignostics qupath launch` @@ -1017,9 +1017,9 @@ $ aignostics qupath uninstall [OPTIONS] **Options**: * `--version TEXT`: Version of QuPath to install. If not specified, all versions will be uninstalled. -* `--path DIRECTORY`: Path to install QuPath to. If not specified, the default installation path will be used.Do not change this unless you know what you are doing. [default: /Users/helmut/Library/Application Support/aignostics] -* `--platform-system TEXT`: Override the system to assume for the installation. This is useful for testing purposes. [default: Darwin] -* `--platform-machine TEXT`: Override the machine architecture to assume for the installation. This is useful for testing purposes. [default: arm64] +* `--path DIRECTORY`: Path to install QuPath to. If not specified, the default installation path will be used.Do not change this unless you know what you are doing. [default: /home/neelay/snap/code/211/.local/share/aignostics] +* `--platform-system TEXT`: Override the system to assume for the installation. This is useful for testing purposes. [default: Linux] +* `--platform-machine TEXT`: Override the machine architecture to assume for the installation. This is useful for testing purposes. [default: x86_64] * `--help`: Show this message and exit. ### `aignostics qupath add` diff --git a/src/aignostics/platform/_authentication.py b/src/aignostics/platform/_authentication.py index d0eee41e1..5368041a0 100644 --- a/src/aignostics/platform/_authentication.py +++ b/src/aignostics/platform/_authentication.py @@ -124,6 +124,8 @@ def get_token(use_cache: bool = True, use_device_flow: bool = False) -> str: # 1. Do not want to use the cached token # 2. The cached token is expired # 3. No token was cached yet + + token = _authenticate(use_device_flow) claims = verify_and_decode_token(token) @@ -169,6 +171,7 @@ def _authenticate(use_device_flow: bool) -> str: RuntimeError: If authentication fails. AssertionError: If the returned token doesn't have the expected format. """ + # have another setting which says no authentication if refresh_token := settings().refresh_token: token = _access_token_from_refresh_token(refresh_token) elif _can_open_browser() and not use_device_flow: diff --git a/src/aignostics/platform/_client.py b/src/aignostics/platform/_client.py index 7aca7a60c..24d560b84 100644 --- a/src/aignostics/platform/_client.py +++ b/src/aignostics/platform/_client.py @@ -274,6 +274,8 @@ def get_api_client(cache_token: bool = True) -> PublicApi: return Client._api_client_uncached def token_provider() -> str: + # # given some setting do not inject token_provider into client + return None return get_token(use_cache=cache_token) ca_file = os.getenv("REQUESTS_CA_BUNDLE") # point to .cer file of proxy if defined diff --git a/src/aignostics/platform/_constants.py b/src/aignostics/platform/_constants.py index a4c1d3f64..cfa8c3caf 100644 --- a/src/aignostics/platform/_constants.py +++ b/src/aignostics/platform/_constants.py @@ -26,3 +26,4 @@ REDIRECT_URI_DEV = "http://localhost:8989/" DEVICE_URL_DEV = "https://dev-8ouohmmrbuh2h4vu.eu.auth0.com/oauth/device/code" JWS_JSON_URL_DEV = "https://dev-8ouohmmrbuh2h4vu.eu.auth0.com/.well-known/jwks.json" + diff --git a/src/aignostics/platform/_settings.py b/src/aignostics/platform/_settings.py index e36ab1d9b..f7626b09a 100644 --- a/src/aignostics/platform/_settings.py +++ b/src/aignostics/platform/_settings.py @@ -582,6 +582,14 @@ def pre_init(cls, values: dict) -> dict: # type: ignore[type-arg] # noqa: N805 values["device_url"] = DEVICE_URL_DEV values["jws_json_url"] = JWS_JSON_URL_DEV values["client_id_interactive"] = CLIENT_ID_INTERACTIVE_DEV + case x if x == "http://localhost:8000": + values["audience"] = "abcfsofihaosfih" + values["authorization_base_url"] = "abc" + values["token_url"] = "http://localhost:8000" + values["redirect_uri"] = "http://localhost:8000" + values["device_url"] = "http://localhost:8000" + values["jws_json_url"] = "http://localhost:8000" + values["client_id_interactive"] = "abc" case _: raise ValueError(UNKNOWN_ENDPOINT_URL) diff --git a/tests/constants_test.py b/tests/constants_test.py index aed1e22e7..4795e84b5 100644 --- a/tests/constants_test.py +++ b/tests/constants_test.py @@ -60,6 +60,8 @@ SPOT_3_HEIGHT = 3952 SPOT_3_RESOLUTION_MPP = 0.46499982 +# adapt to the DB seed + match os.getenv("AIGNOSTICS_PLATFORM_ENVIRONMENT", "production"): case "production": TEST_APPLICATION_ID = "test-app"