From 3b7cf08e7840397ecc43e93e111c2cc7f8aacc67 Mon Sep 17 00:00:00 2001 From: Michael Thornton Date: Fri, 22 Nov 2024 09:35:00 -0800 Subject: [PATCH 1/4] dump failing update query to the log --- nmdc_automation/run_process/run_import.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nmdc_automation/run_process/run_import.py b/nmdc_automation/run_process/run_import.py index 922765d3..970f3791 100644 --- a/nmdc_automation/run_process/run_import.py +++ b/nmdc_automation/run_process/run_import.py @@ -85,6 +85,7 @@ def import_projects(import_file, import_yaml, site_configuration, iteration): runtime.run_query(data_generation_update) except Exception as e: logger.error(f"Error applying update to sequencing data generation: {e}") + logger.error(data_generation_update) raise e From ff45e202aa82c03b95d3e533dc5fa85e87ac46c0 Mon Sep 17 00:00:00 2001 From: Michael Thornton Date: Fri, 22 Nov 2024 10:34:34 -0800 Subject: [PATCH 2/4] fix incorrect update query syntax --- nmdc_automation/import_automation/activity_mapper.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/nmdc_automation/import_automation/activity_mapper.py b/nmdc_automation/import_automation/activity_mapper.py index a3e97ba5..d1930d16 100644 --- a/nmdc_automation/import_automation/activity_mapper.py +++ b/nmdc_automation/import_automation/activity_mapper.py @@ -120,9 +120,10 @@ def map_sequencing_data(self) -> Tuple[nmdc.Database, Dict]: db.data_object_set.append(DataObject(**do_record)) has_output.append(data_object_id) update = { - "collection": "data_generation_set", - "filter": {"id": self.nucelotide_sequencing_id}, - "update": {"$addToSet": {"has_output": has_output}} + "update": "data_generation_set", + "updates": [ + {"q": {"id": self.nucelotide_sequencing_id}, "u": {"$addToSet": {"has_output": has_output}}} + ] } # update self.data_object_map if len(has_output) > 1: From 360fb576a9585473a635c7bd834605657687a8f2 Mon Sep 17 00:00:00 2001 From: Michael Thornton Date: Fri, 22 Nov 2024 10:45:25 -0800 Subject: [PATCH 3/4] fix update query --- nmdc_automation/import_automation/activity_mapper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nmdc_automation/import_automation/activity_mapper.py b/nmdc_automation/import_automation/activity_mapper.py index d1930d16..87970b51 100644 --- a/nmdc_automation/import_automation/activity_mapper.py +++ b/nmdc_automation/import_automation/activity_mapper.py @@ -122,7 +122,7 @@ def map_sequencing_data(self) -> Tuple[nmdc.Database, Dict]: update = { "update": "data_generation_set", "updates": [ - {"q": {"id": self.nucelotide_sequencing_id}, "u": {"$addToSet": {"has_output": has_output}}} + {"q": {"id": self.nucelotide_sequencing_id}, "u": {"$addToSet": {"has_output": has_output[0]}}} ] } # update self.data_object_map From f241a2f224109e7ece3c0abbd782a468cb80e004 Mon Sep 17 00:00:00 2001 From: Michael Thornton Date: Fri, 22 Nov 2024 10:57:30 -0800 Subject: [PATCH 4/4] update unit test --- tests/test_imports.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/test_imports.py b/tests/test_imports.py index 2ef2a40d..29b2c637 100644 --- a/tests/test_imports.py +++ b/tests/test_imports.py @@ -42,9 +42,10 @@ def test_gold_mapper_map_sequencing_data(gold_mapper): exp_dobj_type = "Metagenome Raw Reads" # From the gold_import_files fixture exp_nucleotide_sequencing_id = "nmdc:omprc-11-importT" # From the gold mapper fixture exp_update = { - "collection": "data_generation_set", - "filter": {"id": exp_nucleotide_sequencing_id}, - "update": {"$addToSet": {"has_output": [exp_dobj_id]}} + "update": "data_generation_set", + "updates": [ + {"q": {"id": exp_nucleotide_sequencing_id}, "u": {"$addToSet": {"has_output": exp_dobj_id}}} + ], } # Sequencing data does not get a URL exp_url = None