From b623a3aef5a03fad5d48c78a383b5f0b20c7d53d Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Mon, 1 Dec 2025 14:02:24 -0700 Subject: [PATCH 1/4] add parents ArtifactHandler --- qiita_db/handlers/artifact.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/qiita_db/handlers/artifact.py b/qiita_db/handlers/artifact.py index 0ac6662c5..793928b08 100644 --- a/qiita_db/handlers/artifact.py +++ b/qiita_db/handlers/artifact.py @@ -77,6 +77,7 @@ def get(self, artifact_id): 'processing_parameters': dict with the processing parameters used to generate the artifact or None 'files': dict with the artifact files, keyed by filepath type + 'parents': list of the parents artifact ids """ with qdb.sql_connection.TRN: artifact = _get_artifact(artifact_id) @@ -93,7 +94,8 @@ def get(self, artifact_id): artifact.can_be_submitted_to_vamps, 'prep_information': [p.id for p in artifact.prep_templates], 'study': study.id if study else None, - 'analysis': analysis.id if analysis else None} + 'analysis': analysis.id if analysis else None, + 'parents': [p.id for p in artifact.parents]} params = artifact.processing_parameters response['processing_parameters'] = ( params.values if params is not None else None) From 978ac4fff36af88677f7df850bc2d466747964aa Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Tue, 2 Dec 2025 09:36:16 -0700 Subject: [PATCH 2/4] fixing test --- qiita_db/handlers/tests/test_artifact.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/qiita_db/handlers/tests/test_artifact.py b/qiita_db/handlers/tests/test_artifact.py index d826a5e28..c42a9120d 100644 --- a/qiita_db/handlers/tests/test_artifact.py +++ b/qiita_db/handlers/tests/test_artifact.py @@ -86,6 +86,7 @@ def test_get_artifact(self): 'prep_information': [1], 'study': 1, 'analysis': None, + 'parents': [], 'processing_parameters': None, 'files': exp_fps} self.assertEqual(loads(obs.body), exp) @@ -109,6 +110,7 @@ def test_get_artifact(self): 'prep_information': [], 'study': None, 'analysis': 1, + 'parents': [8], 'processing_parameters': {'biom_table': '8', 'depth': '9000', 'subsample_multinomial': 'False'}, 'files': exp_fps} From e4bdfcf10bd04c035ea3a055d21482fb0364ee2b Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Tue, 2 Dec 2025 14:24:05 -0700 Subject: [PATCH 3/4] add job_id to ArtifactAPItestHandler --- qiita_db/handlers/artifact.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/qiita_db/handlers/artifact.py b/qiita_db/handlers/artifact.py index 793928b08..dacef2bd3 100644 --- a/qiita_db/handlers/artifact.py +++ b/qiita_db/handlers/artifact.py @@ -1,4 +1,5 @@ # ----------------------------------------------------------------------------- + pp = qdb.software.Parameters(parameters_id) # Copyright (c) 2014--, The Qiita Development Team. # # Distributed under the terms of the BSD 3-clause License. @@ -186,6 +187,8 @@ def post(self): analysis = self.get_argument('analysis', None) name = self.get_argument('name', None) dtype = self.get_argument('data_type', None) + parents = self.get_argument('parents', None) + job_id = self.get_argument('job_id', None) if prep_template is not None: prep_template = qdb.metadata_template.prep_template.PrepTemplate( @@ -193,9 +196,19 @@ def post(self): dtype = None if analysis is not None: analysis = qdb.analysis.Analysis(analysis) + if parents is not None: + # remember that this method is only accessed via the tests so + # to load an artifact with parents, the easiest it to use + # the job_id that is being used for testing and passed as a + # parameter + parents = [qdb.artifact.Artifact(p) for p in loads(parents)] + pp = qdb.processing_job.ProcessingJob(job_id).parameters + else: + pp = None a = qdb.artifact.Artifact.create( filepaths, artifact_type, name=name, prep_template=prep_template, + parents=parents, processing_parameters=pp, analysis=analysis, data_type=dtype) self.write({'artifact': a.id}) From 1c820617bf42c8962c959d7dfeda82a46d9da08a Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Tue, 2 Dec 2025 14:28:35 -0700 Subject: [PATCH 4/4] flake8 --- qiita_db/handlers/artifact.py | 1 - 1 file changed, 1 deletion(-) diff --git a/qiita_db/handlers/artifact.py b/qiita_db/handlers/artifact.py index dacef2bd3..a34c7be1f 100644 --- a/qiita_db/handlers/artifact.py +++ b/qiita_db/handlers/artifact.py @@ -1,5 +1,4 @@ # ----------------------------------------------------------------------------- - pp = qdb.software.Parameters(parameters_id) # Copyright (c) 2014--, The Qiita Development Team. # # Distributed under the terms of the BSD 3-clause License.