From 093ed7060975936d7d5a7c9280d61d595ca03ac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karatu=C4=9F=20Ozan=20Bircan?= Date: Thu, 2 Jan 2025 12:48:52 +0000 Subject: [PATCH] fix: Set SKIPPED status if no sumstat files for yaml gen --- sumstats_service/app.py | 9 +++++++-- sumstats_service/config.py | 1 + sumstats_service/resources/mongo_client.py | 7 +++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/sumstats_service/app.py b/sumstats_service/app.py index 399fcfe..7e2d634 100644 --- a/sumstats_service/app.py +++ b/sumstats_service/app.py @@ -442,8 +442,13 @@ def convert_metadata_to_yaml(gcst_id, **kwargs): additional_info={"exception": str(e)}, ) else: - logger.info( - f"Skipping {gcst_id=} hm: {is_harmonised_included} as it has no files." + info = f"Skipping {gcst_id=} hm: {is_harmonised_included} as it has no files." + logger.info(info) + mdb.insert_or_update_metadata_yaml_request( + gcst_id=gcst_id, + status=config.MetadataYamlStatus.SKIPPED, + is_harmonised=is_harmonised_included, + additional_info={"info": info}, ) diff --git a/sumstats_service/config.py b/sumstats_service/config.py index 92e4ea6..748401e 100644 --- a/sumstats_service/config.py +++ b/sumstats_service/config.py @@ -227,3 +227,4 @@ class MetadataYamlStatus(Enum): IN_PROGRESS = "in-progress" COMPLETED = "completed" FAILED = "failed" + SKIPPED = "skipped" diff --git a/sumstats_service/resources/mongo_client.py b/sumstats_service/resources/mongo_client.py index 9b4a731..24896b5 100644 --- a/sumstats_service/resources/mongo_client.py +++ b/sumstats_service/resources/mongo_client.py @@ -174,10 +174,13 @@ def insert_or_update_metadata_yaml_request( gcst_id, status, is_harmonised=False, - additional_info={}, + additional_info=None, globus_endpoint_id=None, ): + if additional_info is None: + additional_info = {} + print(f"adding {gcst_id} with hm: {is_harmonised} to yaml") update_doc = { @@ -194,7 +197,7 @@ def insert_or_update_metadata_yaml_request( # If status is COMPLETED, then reset attempts to 0. # Otherwise increment attempts. - if status == config.MetadataYamlStatus.COMPLETED: + if status == config.MetadataYamlStatus.COMPLETED or status == config.MetadataYamlStatus.SKIPPED: update_doc["$set"]["attempts"] = 0 else: update_doc["$inc"] = {"attempts": 1}