Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion qiita_db/handlers/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -184,16 +186,28 @@ 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(
prep_template)
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})
Expand Down
2 changes: 2 additions & 0 deletions qiita_db/handlers/tests/test_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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}
Expand Down
Loading