Skip to content
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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

olloz26
Copy link
Collaborator

@olloz26 olloz26 commented Jul 10, 2024

/deploy renku-ui=olloz26/connect-renkulab-and-openbis-datasets

@olloz26 olloz26 requested a review from a team as a code owner July 10, 2024 14:20
Copy link
Member

@Panaetius Panaetius left a 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.

@coveralls
Copy link

coveralls commented Jul 11, 2024

Pull Request Test Coverage Report for Build 10897839042

Details

  • 71 of 108 (65.74%) changed or added relevant lines in 11 files are covered.
  • 4 unchanged lines in 4 files lost coverage.
  • Overall coverage decreased (-0.2%) to 90.187%

Changes Missing Coverage Covered Lines Changed/Added Lines %
components/renku_data_services/storage/core.py 8 12 66.67%
components/renku_data_services/storage/rclone.py 19 23 82.61%
components/renku_data_services/utils/core.py 4 33 12.12%
Files with Coverage Reduction New Missed Lines %
components/renku_data_services/base_api/misc.py 1 98.15%
components/renku_data_services/connected_services/db.py 1 82.18%
components/renku_data_services/crc/blueprints.py 1 94.12%
components/renku_data_services/crc/db.py 1 87.58%
Totals Coverage Status
Change from base Build 10883923522: -0.2%
Covered Lines: 9384
Relevant Lines: 10405

💛 - Coveralls

@olevski olevski marked this pull request as draft July 11, 2024 15:13
@olloz26 olloz26 force-pushed the pitch/connect-renkulab-and-openbis-datasets branch 2 times, most recently from 5139120 to 968f309 Compare August 22, 2024 16:15
@olloz26 olloz26 marked this pull request as ready for review August 29, 2024 13:14
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`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* 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 :)

components/renku_data_services/secrets/orm.py Outdated Show resolved Hide resolved
Comment on lines 319 to 326
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,
)
Copy link
Member

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.

Comment on lines 319 to 320
provider = validator.providers[storage.storage_type]
sensitive_lookup = [o.name for o in provider.options if o.sensitive]
Copy link
Member

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))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

components/renku_data_services/storage/db.py Outdated Show resolved Hide resolved
components/renku_data_services/storage/rclone.py Outdated Show resolved Hide resolved
components/renku_data_services/utils/core.py Show resolved Hide resolved
components/renku_data_services/utils/core.py Show resolved Hide resolved
@olloz26 olloz26 force-pushed the pitch/connect-renkulab-and-openbis-datasets branch from 3c70bf2 to 06cede5 Compare September 5, 2024 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants