dsimaging-admin 0.3.2__tar.gz → 0.3.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dsimaging-admin
3
- Version: 0.3.2
3
+ Version: 0.3.4
4
4
  Summary: Admin CLI for managing medical imaging datasets in S3/MinIO for DataSHIELD
5
5
  Project-URL: Homepage, https://github.com/isglobal-brge/dsimaging-admin
6
6
  Project-URL: Repository, https://github.com/isglobal-brge/dsimaging-admin
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "dsimaging-admin"
7
- version = "0.3.2"
7
+ version = "0.3.4"
8
8
  description = "Admin CLI for managing medical imaging datasets in S3/MinIO for DataSHIELD"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -1,3 +1,3 @@
1
1
  """dsimaging-admin: Admin CLI for managing medical imaging datasets in S3/MinIO."""
2
2
 
3
- __version__ = "0.3.2"
3
+ __version__ = "0.3.4"
@@ -33,6 +33,8 @@ def list_datasets(s3, bucket: str) -> list[dict]:
33
33
  for page in paginator.paginate(Bucket=bucket, Prefix="datasets/", Delimiter="/"):
34
34
  for cp in page.get("CommonPrefixes", []):
35
35
  ds_id = cp["Prefix"].strip("/").split("/")[-1]
36
+ if not _prefix_has_current_objects(s3, bucket, f"datasets/{ds_id}/"):
37
+ continue
36
38
  has_manifest = _object_exists(s3, bucket, f"datasets/{ds_id}/manifest.yaml")
37
39
  datasets.append({
38
40
  "dataset_id": ds_id,
@@ -175,3 +177,12 @@ def _object_exists(s3, bucket: str, key: str) -> bool:
175
177
  return True
176
178
  except Exception:
177
179
  return False
180
+
181
+
182
+ def _prefix_has_current_objects(s3, bucket: str, prefix: str) -> bool:
183
+ paginator = s3.get_paginator("list_objects_v2")
184
+ for page in paginator.paginate(Bucket=bucket, Prefix=prefix):
185
+ for obj in page.get("Contents", []):
186
+ if _object_exists(s3, bucket, obj["Key"]):
187
+ return True
188
+ return False
File without changes