-
Notifications
You must be signed in to change notification settings - Fork 5
✨ Capture osparc envs automatically using a pydantic model #170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
bisgaard-itis
merged 18 commits into
ITISFoundation:master
from
bisgaard-itis:is5925/osparc-envs-auto
Jul 12, 2024
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
239d04c
cleanup
pcrespov 77838c8
overrides Config with new defaults
pcrespov da8e388
testing config
pcrespov b4a2e37
upgrades pre-commit
pcrespov ca74b42
mv pytest.ini
pcrespov 129abe8
monkey patch
pcrespov 132a4f8
update workflow before publishing python package
bisgaard-itis bc1b114
merge itis/master into master
bisgaard-itis 2995354
wrap api_client
bisgaard-itis 6f1e38c
add type
bisgaard-itis e3c83aa
remove _configuration.py
bisgaard-itis 8097e26
avoid bad import
bisgaard-itis 14c52c6
fix import
bisgaard-itis 5d782ee
fix e2e tests
bisgaard-itis 7442aa4
add unit test
bisgaard-itis 5cf0a3b
resolved merge conflicts
bisgaard-itis 8cc4a75
require api_client in wrapped apis
bisgaard-itis eee80b1
fix unit tests
bisgaard-itis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from typing import Optional | ||
|
||
from osparc_client import ApiClient as _ApiClient | ||
from osparc_client import Configuration | ||
from pydantic import ValidationError | ||
|
||
from ._models import ConfigurationModel | ||
|
||
|
||
class ApiClient(_ApiClient): | ||
def __init__( | ||
self, | ||
configuration: Optional[Configuration] = None, | ||
header_name=None, | ||
header_value=None, | ||
cookie=None, | ||
pool_threads=1, | ||
): | ||
if configuration is None: | ||
try: | ||
env_vars = ConfigurationModel() | ||
configuration = Configuration( | ||
host=f"{env_vars.OSPARC_API_HOST}".rstrip( | ||
"/" | ||
), # https://github.com/pydantic/pydantic/issues/7186 | ||
username=env_vars.OSPARC_API_KEY, | ||
password=env_vars.OSPARC_API_SECRET, | ||
) | ||
except ValidationError as exc: | ||
raise RuntimeError( | ||
"Could not initialize configuration from environment. " | ||
"If your osparc host, key and secret are not exposed as " | ||
"environment variables you must construct the " | ||
"Configuration object explicitly" | ||
bisgaard-itis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) from exc | ||
|
||
super().__init__(configuration, header_name, header_value, cookie, pool_threads) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.