diff --git a/src/npc_lims/metadata/codeocean.py b/src/npc_lims/metadata/codeocean.py index 6a6a8b5..7cb961b 100644 --- a/src/npc_lims/metadata/codeocean.py +++ b/src/npc_lims/metadata/codeocean.py @@ -35,7 +35,7 @@ "last_used", "name", "size", - "sourceBucket", + "source_bucket", "state", "tags", "type", @@ -387,11 +387,11 @@ def get_raw_data_root(session: str | npc_session.SessionRecord) -> upath.UPath: def get_path_from_data_asset(asset: DataAssetAPI) -> upath.UPath: """Reconstruct path to raw data in bucket (e.g. on s3) using data asset uuid or dict of info from Code Ocean API.""" - if "sourceBucket" not in asset: + if "source_bucket" not in asset: raise ValueError( - f"Asset {asset['id']} has no `sourceBucket` info - not sure how to create UPath:\n{asset!r}" + f"Asset {asset['id']} has no `source_bucket` info - not sure how to create UPath:\n{asset!r}" ) - bucket_info = asset["sourceBucket"] + bucket_info = asset["source_bucket"] roots = {"aws": "s3", "gcs": "gs"} if bucket_info["origin"] not in roots: raise RuntimeError( diff --git a/src/npc_lims/paths/s3.py b/src/npc_lims/paths/s3.py index 8e97fab..e3a470a 100644 --- a/src/npc_lims/paths/s3.py +++ b/src/npc_lims/paths/s3.py @@ -37,7 +37,7 @@ def get_data_asset_s3_path(asset_id: str | codeocean.DataAssetAPI) -> upath.UPat """ bucket = CODE_OCEAN_DATA_BUCKET with contextlib.suppress(AttributeError, KeyError, TypeError): - bucket = upath.UPath(upath.UPath(f's3://{asset_id["sourceBucket"]}')) # type: ignore[index] + bucket = upath.UPath(upath.UPath(f's3://{asset_id["source_bucket"]}')) # type: ignore[index] with contextlib.suppress(AttributeError, KeyError): return bucket / asset_id.get("id") # type: ignore[union-attr, operator] with contextlib.suppress(AttributeError):