@@ -329,6 +329,16 @@ def create(
329329 qiita_db.artifact.Artifact
330330 A new instance of Artifact
331331
332+ Raises
333+ ------
334+ QiitaDBArtifactCreationError
335+ If `filepaths` is not provided
336+ If both `parents` and `prep_template` are provided
337+ If none of `parents` and `prep_template` are provided
338+ If `parents` is provided but `processing_parameters` is not
339+ If both `prep_template` and `processing_parameters` is provided
340+ If not all the artifacts in `parents` belong to the same study
341+
332342 Notes
333343 -----
334344 The visibility of the artifact is set by default to `sandbox` if
@@ -344,29 +354,29 @@ def create(
344354 )
345355
346356 # Check that the combination of parameters is correct
347- if bool (parents ) and bool (prep_template ):
348- raise qdb .exceptions .QiitaDBArtifactCreationError (
349- "Not valid: parents and prep_template provided"
350- )
351- elif bool (parents ) and not bool (processing_parameters ):
357+ counts = (
358+ int (bool (parents or processing_parameters ))
359+ + int (prep_template is not None )
360+ + int (bool (analysis or data_type ))
361+ )
362+ if counts != 1 :
363+ # More than one parameter has been provided
352364 raise qdb .exceptions .QiitaDBArtifactCreationError (
353- "Not valid: both parents and processing_parameters need to be provided"
365+ "One and only one of parents, prep template or analysis must "
366+ "be provided"
354367 )
355- elif bool (prep_template ) and bool (processing_parameters ):
368+ elif bool (parents ) != bool (processing_parameters ):
369+ # When provided, parents and processing parameters both should be
370+ # provided (this is effectively doing an XOR)
356371 raise qdb .exceptions .QiitaDBArtifactCreationError (
357- "Not valid: both prep_template and processing_parameters provided"
372+ "When provided, both parents and processing parameters should "
373+ "be provided"
358374 )
359375 elif bool (analysis ) and not bool (data_type ):
376+ # When provided, analysis and data_type both should be
377+ # provided (this is effectively doing an XOR)
360378 raise qdb .exceptions .QiitaDBArtifactCreationError (
361- "Not valid: both analysis and data_type need to be provided"
362- )
363- elif bool (prep_template ) and bool (data_type ):
364- raise qdb .exceptions .QiitaDBArtifactCreationError (
365- "Not valid: both prep_template and data_type need to be provided"
366- )
367- elif not bool (prep_template ) and not bool (parents ) and not bool (analysis ):
368- raise qdb .exceptions .QiitaDBArtifactCreationError (
369- "Not valid: no prep_template, parents or analysis provided"
379+ "When provided, both analysis and data_type should be provided"
370380 )
371381
372382 # There are three different ways of creating an Artifact, but all of
0 commit comments