Skip to content

Commit

Permalink
Added catch for data discovery (#107)
Browse files Browse the repository at this point in the history
* Added catch for data discovery

* cleanup
  • Loading branch information
dogversioning authored Oct 19, 2023
1 parent 7cd64cd commit 0eb3a1d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/handlers/site_upload/process_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ def process_upload(s3_client, sns_client, s3_bucket_name: str, s3_key: str) -> N
new_key = f"{BucketPath.ARCHIVE.value}/{s3_key.split('/', 1)[-1]}"
move_s3_file(s3_client, s3_bucket_name, s3_key, new_key)
elif s3_key.endswith(".parquet"):
if "__meta_" in s3_key:
if "__meta_" in s3_key or "/discovery__" in s3_key:
new_key = f"{BucketPath.STUDY_META.value}/{s3_key.split('/', 1)[-1]}"
topic_sns_arn = os.environ.get("TOPIC_PROCESS_STUDY_META_ARN")
sns_subject = "Process study medata upload event"
sns_subject = "Process study metadata upload event"
else:
new_key = f"{BucketPath.LATEST.value}/{s3_key.split('/', 1)[-1]}"
topic_sns_arn = os.environ.get("TOPIC_PROCESS_COUNTS_ARN")
Expand Down
15 changes: 14 additions & 1 deletion tests/site_upload/test_process_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,19 @@
200,
ITEM_COUNT + 1,
),
( # Adding discovery data package
"./tests/test_data/cube_simple_example.parquet",
(
f"/{EXISTING_STUDY}/{EXISTING_DATA_P}/{EXISTING_SITE}/"
f"{EXISTING_VERSION}/discovery__file.parquet"
),
(
f"/{EXISTING_STUDY}/{EXISTING_DATA_P}/{EXISTING_SITE}/"
f"{EXISTING_VERSION}/discovery__file.parquet"
),
200,
ITEM_COUNT + 1,
),
],
)
def test_process_upload(
Expand Down Expand Up @@ -155,7 +168,7 @@ def test_process_upload(
== datetime.now(timezone.utc).isoformat()
)
elif item["Key"].startswith(BucketPath.STUDY_META.value):
assert "_meta_" in item["Key"]
assert any(x in item["Key"] for x in ["_meta_", "/discovery__"])
elif item["Key"].startswith(BucketPath.ARCHIVE.value):
found_archive = True
else:
Expand Down

0 comments on commit 0eb3a1d

Please sign in to comment.