Skip to content

Commit

Permalink
🔨 Fix capture osparc variables (#172)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
bisgaard-itis authored Jul 16, 2024
1 parent 21d813f commit 5ba31db
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
4 changes: 3 additions & 1 deletion clients/python/client/osparc/_models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Optional
from uuid import UUID

from pydantic import AnyHttpUrl, Field, field_validator
from pydantic import AliasChoices, AnyHttpUrl, Field, field_validator
from pydantic_settings import BaseSettings


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

# Service side: https://github.com/ITISFoundation/osparc-simcore/pull/5966
OSPARC_API_HOST: AnyHttpUrl = Field(
default=...,
validation_alias=AliasChoices("OSPARC_API_BASE_URL", "OSPARC_API_HOST"),
description="OSPARC api url",
examples=["https://api.osparc-master.speag.com/"],
)
Expand Down
21 changes: 19 additions & 2 deletions clients/python/test/test_osparc/test_apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,29 +70,46 @@ def check_headers(**kwargs):
@pytest.mark.parametrize(
"OSPARC_API_HOST", ["https://api.foo.com", "https://api.bar.com/", None]
)
@pytest.mark.parametrize(
"OSPARC_API_BASE_URL", ["https://api.sdkjbf.com", "https://api.alskjd.com/", None]
)
@pytest.mark.parametrize("OSPARC_API_KEY", ["key", None])
@pytest.mark.parametrize("OSPARC_API_SECRET", ["secret", None])
def test_api_client_constructor(
monkeypatch: pytest.MonkeyPatch,
OSPARC_API_HOST: Optional[str],
OSPARC_API_BASE_URL: Optional[str],
OSPARC_API_KEY: Optional[str],
OSPARC_API_SECRET: Optional[str],
):
with monkeypatch.context() as patch:
patch.delenv("OSPARC_API_HOST", raising=False)
patch.delenv("OSPARC_API_BASE_URL", raising=False)
patch.delenv("OSPARC_API_KEY", raising=False)
patch.delenv("OSPARC_API_SECRET", raising=False)

if OSPARC_API_HOST is not None:
patch.setenv("OSPARC_API_HOST", OSPARC_API_HOST)
if OSPARC_API_BASE_URL is not None:
patch.setenv("OSPARC_API_BASE_URL", OSPARC_API_BASE_URL)
if OSPARC_API_KEY is not None:
patch.setenv("OSPARC_API_KEY", OSPARC_API_KEY)
if OSPARC_API_SECRET is not None:
patch.setenv("OSPARC_API_SECRET", OSPARC_API_SECRET)

if OSPARC_API_HOST and OSPARC_API_KEY and OSPARC_API_SECRET:
if (
(OSPARC_API_HOST or OSPARC_API_BASE_URL)
and OSPARC_API_KEY
and OSPARC_API_SECRET
):
api = ApiClient()
assert api.configuration.host == OSPARC_API_HOST.rstrip("/")
# if OSPARC_API_BASE_URL and OSPARC_API_HOST are both
# in env, the former has preference
if OSPARC_API_BASE_URL is not None:
assert api.configuration.host == OSPARC_API_BASE_URL.rstrip("/")
elif OSPARC_API_HOST is not None:
assert api.configuration.host == OSPARC_API_HOST.rstrip("/")

assert api.configuration.username == OSPARC_API_KEY
assert api.configuration.password == OSPARC_API_SECRET

Expand Down

0 comments on commit 5ba31db

Please sign in to comment.