-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: add custom openBIS type #299
base: main
Are you sure you want to change the base?
feat: add custom openBIS type #299
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Failing due to not passing style checks. If you install https://pre-commit.com/ it'd check this before every commit. Alternatively, run make style_checks
to run the checks locally.
In this case, a simple ruff check --fix
should fix it.
Pull Request Test Coverage Report for Build 10897839042Details
💛 - Coveralls |
5139120
to
968f309
Compare
README.md
Outdated
@@ -27,12 +27,14 @@ details. | |||
|
|||
1. Write code | |||
2. Run tests: `make tests` | |||
* Run a specific test e.g.: `poetry run pytest test/bases/renku_data_services/data_api/test_storage_v2.py::test_storage_v2_create_openbis_secret` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Run a specific test e.g.: `poetry run pytest test/bases/renku_data_services/data_api/test_storage_v2.py::test_storage_v2_create_openbis_secret` | |
* Run a specific test e.g.: `poetry run pytest -k test_storage_v2_create_openbis_secret` |
also works :)
provider = validator.providers[storage.storage_type] | ||
sensitive_lookup = [o.name for o in provider.options if o.sensitive] | ||
for secret in secrets: | ||
if len(secret.value) > 0 and secret.name in sensitive_lookup: | ||
continue | ||
raise errors.ValidationError( | ||
message=f"The '{secret.name}' property is not marked sensitive and can not be saved in the secret " | ||
f"storage." | ||
) | ||
expiration_timestamp = None | ||
|
||
if storage.storage_type == "openbis": | ||
|
||
async def openbis_transform_session_token_to_pat() -> tuple[str, datetime]: | ||
if len(secrets) == 1 and secrets[0].name == "session_token": | ||
try: | ||
return await get_openbis_pat(storage.configuration["host"], secrets[0].value) | ||
except Exception as e: | ||
raise errors.ProgrammingError(message=str(e)) | ||
|
||
raise errors.ValidationError(message="The openBIS storage has only one secret: session_token") | ||
|
||
( | ||
secrets[0].value, | ||
expiration_timestamp, | ||
) = await openbis_transform_session_token_to_pat() | ||
|
||
result = await self.storage_v2_repo.upsert_storage_secrets( | ||
storage_id=storage_id, user=user, secrets=secrets | ||
storage_id=storage_id, | ||
user=user, | ||
secrets=secrets, | ||
expiration_timestamp=expiration_timestamp, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: I'd put this in a storage/core.py file as this is business logic that shouldn't be in the presentation layer (blueprints.py file).
I'd also do the openbis check as a plain function, not a nested one with closures.
provider = validator.providers[storage.storage_type] | ||
sensitive_lookup = [o.name for o in provider.options if o.sensitive] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: I think you can use validator.get_provider
here and you should definitely use provider.sensitive_options
instead of the list comprehension
try: | ||
return await get_openbis_pat(storage.configuration["host"], secrets[0].value) | ||
except Exception as e: | ||
raise errors.ProgrammingError(message=str(e)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raise errors.ProgrammingError(message=str(e)) | |
raise errors.ProgrammingError(message=str(e)) from e |
this way the inner stack trace does not get lost in e.g. sentry
3c70bf2
to
06cede5
Compare
/deploy renku-ui=olloz26/connect-renkulab-and-openbis-datasets