Skip to content

Commit 8b2a0d0

Browse files
committed
squashme: minor changes
1 parent 22347c9 commit 8b2a0d0

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

components/renku_data_services/data_connectors/core.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
ProjectPath,
1717
)
1818
from renku_data_services.data_connectors import apispec, models
19+
from renku_data_services.data_connectors.constants import ALLOWED_GLOBAL_DATA_CONNECTOR_PROVIDERS
1920
from renku_data_services.data_connectors.doi import schema_org
2021
from renku_data_services.data_connectors.doi.metadata import create_envidat_metadata_url, get_dataset_metadata
2122
from renku_data_services.data_connectors.doi.models import DOI, SchemaOrgDataset
@@ -94,11 +95,6 @@ async def validate_unsaved_storage_doi(
9495
configuration: dict[str, Any]
9596
source_path: str
9697

97-
if storage.storage_type != "doi":
98-
raise errors.ProgrammingError(
99-
message="Only doi-type storage can be validated by the validate_unsaved_storage_doi function."
100-
)
101-
10298
doi_str = storage.configuration.get("doi")
10399
if not isinstance(doi_str, str):
104100
raise errors.ValidationError(message="Cannot find the doi in the storage configuration")
@@ -116,7 +112,7 @@ async def validate_unsaved_storage_doi(
116112
# Most likely supported by rclone doi provider, you have to call validator.get_doi_metadata to confirm
117113
configuration = storage.configuration
118114
source_path = storage.source_path
119-
storage_type = storage.storage_type
115+
storage_type = storage.storage_type or "doi"
120116

121117
validator.validate(configuration)
122118

@@ -176,9 +172,11 @@ async def prevalidate_unsaved_global_data_connector(
176172
) -> models.PrevalidatedGlobalDataConnector:
177173
"""Pre-validate an unsaved data connector."""
178174
# TODO: allow admins to create global data connectors, e.g. s3://giab
179-
if isinstance(body.storage, apispec.CloudStorageUrlV2) or body.storage.storage_type != "doi":
180-
raise errors.ValidationError(message="Only doi storage type is allowed for global data connectors")
175+
if isinstance(body.storage, apispec.CloudStorageUrlV2):
176+
raise errors.ValidationError(message="Global data connectors cannot be configured via a URL.")
181177
storage, doi = await validate_unsaved_storage_doi(body.storage, validator=validator)
178+
if storage.storage_type not in ALLOWED_GLOBAL_DATA_CONNECTOR_PROVIDERS:
179+
raise errors.ValidationError(message="Only doi storage type is allowed for global data connectors")
182180
if not storage.readonly:
183181
raise errors.ValidationError(message="Global data connectors must be read-only")
184182

test/bases/renku_data_services/data_api/test_data_connectors.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2452,8 +2452,6 @@ async def test_validate_envidat_data_connector() -> None:
24522452
assert config["provider"] == "Other"
24532453
assert config["endpoint"].find("zhdk.cloud.switch.ch") >= 0
24542454
assert res.converted_storage.source_path == "envidat-doi/10.16904_12"
2455-
breakpoint()
24562455
res = await core.validate_unsaved_global_data_connector(res, validator)
24572456
assert len(res.description) > 0
24582457
assert len(res.keywords) > 0
2459-
breakpoint()

0 commit comments

Comments
 (0)