Skip to content

Commit

Permalink
Update sourceBucket -> source_bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
bjhardcastle committed Apr 15, 2024
1 parent 4c978a5 commit b655727
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/npc_lims/metadata/codeocean.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"last_used",
"name",
"size",
"sourceBucket",
"source_bucket",
"state",
"tags",
"type",
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/npc_lims/paths/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit b655727

Please sign in to comment.