Skip to content

Commit 5ba31db

Browse files
🔨 Fix capture osparc variables (#172)
* update workflow before publishing python package fix dependency issue and bump version point to website in project description fix broken dependency improve doc add github token to download artifacts ensure only read-access @wvangeit yet another attempt at downloading artifacts make sure to use repo that ran the trigger wf another attempt at fixing change owner allow publishing to testpypi also when pr minor change revert minor (but breaking) change minor fix add debug messages another debug message hopefully the final version final fix minor fix move master and tag to individual jobs add debug messages add python script for determining semantic version minor changes minor changes improve error handling and add version file to artifacts check if release minor fix ensure to enter venv also when tagging source venv in publishin workflow ensure only master add script for testing 'pure' semver adapt workflows to new python script minor change attempt to evaluate expressions correctly several fixes to fix tests ensure repo is checked out in publish workflow several small fixes cleanup debug minor cleanup mionr changes add debug message minor change minor change yet another try minor change minor change minor change mionr change minor changes correct workflow run id cosmetic change avoid using gh change to a single job for publishing minor cleanup swap loops in clean up jobs correction get correct versions of github workflow files update a couple of other files update a few more tests update yet another file yet another file * fix OSPARC_API_BASE_URL has preference * document server side changes
1 parent 21d813f commit 5ba31db

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

‎clients/python/client/osparc/_models.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import Optional
22
from uuid import UUID
33

4-
from pydantic import AnyHttpUrl, Field, field_validator
4+
from pydantic import AliasChoices, AnyHttpUrl, Field, field_validator
55
from pydantic_settings import BaseSettings
66

77

@@ -27,8 +27,10 @@ def _validate_uuids(cls, v: Optional[str]) -> Optional[str]:
2727
class ConfigurationModel(BaseSettings):
2828
"""Model for capturing env vars which should go into the Configuration"""
2929

30+
# Service side: https://github.com/ITISFoundation/osparc-simcore/pull/5966
3031
OSPARC_API_HOST: AnyHttpUrl = Field(
3132
default=...,
33+
validation_alias=AliasChoices("OSPARC_API_BASE_URL", "OSPARC_API_HOST"),
3234
description="OSPARC api url",
3335
examples=["https://api.osparc-master.speag.com/"],
3436
)

‎clients/python/test/test_osparc/test_apis.py‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,29 +70,46 @@ def check_headers(**kwargs):
7070
@pytest.mark.parametrize(
7171
"OSPARC_API_HOST", ["https://api.foo.com", "https://api.bar.com/", None]
7272
)
73+
@pytest.mark.parametrize(
74+
"OSPARC_API_BASE_URL", ["https://api.sdkjbf.com", "https://api.alskjd.com/", None]
75+
)
7376
@pytest.mark.parametrize("OSPARC_API_KEY", ["key", None])
7477
@pytest.mark.parametrize("OSPARC_API_SECRET", ["secret", None])
7578
def test_api_client_constructor(
7679
monkeypatch: pytest.MonkeyPatch,
7780
OSPARC_API_HOST: Optional[str],
81+
OSPARC_API_BASE_URL: Optional[str],
7882
OSPARC_API_KEY: Optional[str],
7983
OSPARC_API_SECRET: Optional[str],
8084
):
8185
with monkeypatch.context() as patch:
8286
patch.delenv("OSPARC_API_HOST", raising=False)
87+
patch.delenv("OSPARC_API_BASE_URL", raising=False)
8388
patch.delenv("OSPARC_API_KEY", raising=False)
8489
patch.delenv("OSPARC_API_SECRET", raising=False)
8590

8691
if OSPARC_API_HOST is not None:
8792
patch.setenv("OSPARC_API_HOST", OSPARC_API_HOST)
93+
if OSPARC_API_BASE_URL is not None:
94+
patch.setenv("OSPARC_API_BASE_URL", OSPARC_API_BASE_URL)
8895
if OSPARC_API_KEY is not None:
8996
patch.setenv("OSPARC_API_KEY", OSPARC_API_KEY)
9097
if OSPARC_API_SECRET is not None:
9198
patch.setenv("OSPARC_API_SECRET", OSPARC_API_SECRET)
9299

93-
if OSPARC_API_HOST and OSPARC_API_KEY and OSPARC_API_SECRET:
100+
if (
101+
(OSPARC_API_HOST or OSPARC_API_BASE_URL)
102+
and OSPARC_API_KEY
103+
and OSPARC_API_SECRET
104+
):
94105
api = ApiClient()
95-
assert api.configuration.host == OSPARC_API_HOST.rstrip("/")
106+
# if OSPARC_API_BASE_URL and OSPARC_API_HOST are both
107+
# in env, the former has preference
108+
if OSPARC_API_BASE_URL is not None:
109+
assert api.configuration.host == OSPARC_API_BASE_URL.rstrip("/")
110+
elif OSPARC_API_HOST is not None:
111+
assert api.configuration.host == OSPARC_API_HOST.rstrip("/")
112+
96113
assert api.configuration.username == OSPARC_API_KEY
97114
assert api.configuration.password == OSPARC_API_SECRET
98115

0 commit comments

Comments
 (0)