File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -1463,8 +1463,22 @@ def prep_templates(self):
14631463 FROM qiita.preparation_artifact
14641464 WHERE artifact_id = %s"""
14651465 qdb .sql_connection .TRN .add (sql , [self .id ])
1466- return [qdb .metadata_template .prep_template .PrepTemplate (pt_id )
1467- for pt_id in qdb .sql_connection .TRN .execute_fetchflatten ()]
1466+ templates = [qdb .metadata_template .prep_template .PrepTemplate (pt_id )
1467+ for pt_id in qdb .sql_connection .TRN .execute_fetchflatten ()]
1468+
1469+ if len (templates ) > 1 :
1470+ # We never expect an artifact to be associated with multiple
1471+ # preparations
1472+ ids = [p .id for p in templates ]
1473+ msg = f"Artifact({ self .id } ) associated with preps: { sorted (ids )} "
1474+ raise ValueError (msg )
1475+
1476+ if len (templates ) == 0 :
1477+ # An artifact must be associated with a template
1478+ msg = f"Artifact({ self .id } ) is not associated with a template"
1479+ raise ValueError (msg )
1480+
1481+ return templates
14681482
14691483 @property
14701484 def study (self ):
You can’t perform that action at this time.
0 commit comments