@@ -77,6 +77,7 @@ def get(self, artifact_id):
7777 'processing_parameters': dict with the processing parameters used
7878 to generate the artifact or None
7979 'files': dict with the artifact files, keyed by filepath type
80+ 'parents': list of the parents artifact ids
8081 """
8182 with qdb .sql_connection .TRN :
8283 artifact = _get_artifact (artifact_id )
@@ -93,7 +94,8 @@ def get(self, artifact_id):
9394 artifact .can_be_submitted_to_vamps ,
9495 'prep_information' : [p .id for p in artifact .prep_templates ],
9596 'study' : study .id if study else None ,
96- 'analysis' : analysis .id if analysis else None }
97+ 'analysis' : analysis .id if analysis else None ,
98+ 'parents' : [p .id for p in artifact .parents ]}
9799 params = artifact .processing_parameters
98100 response ['processing_parameters' ] = (
99101 params .values if params is not None else None )
@@ -184,16 +186,28 @@ def post(self):
184186 analysis = self .get_argument ('analysis' , None )
185187 name = self .get_argument ('name' , None )
186188 dtype = self .get_argument ('data_type' , None )
189+ parents = self .get_argument ('parents' , None )
190+ job_id = self .get_argument ('job_id' , None )
187191
188192 if prep_template is not None :
189193 prep_template = qdb .metadata_template .prep_template .PrepTemplate (
190194 prep_template )
191195 dtype = None
192196 if analysis is not None :
193197 analysis = qdb .analysis .Analysis (analysis )
198+ if parents is not None :
199+ # remember that this method is only accessed via the tests so
200+ # to load an artifact with parents, the easiest it to use
201+ # the job_id that is being used for testing and passed as a
202+ # parameter
203+ parents = [qdb .artifact .Artifact (p ) for p in loads (parents )]
204+ pp = qdb .processing_job .ProcessingJob (job_id ).parameters
205+ else :
206+ pp = None
194207
195208 a = qdb .artifact .Artifact .create (
196209 filepaths , artifact_type , name = name , prep_template = prep_template ,
210+ parents = parents , processing_parameters = pp ,
197211 analysis = analysis , data_type = dtype )
198212
199213 self .write ({'artifact' : a .id })
0 commit comments