Skip to content

Commit 6c2609c

Browse files
authored
Merge 3d6f6c3 into 88e19ff
2 parents 88e19ff + 3d6f6c3 commit 6c2609c

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

qiita_db/analysis.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,21 +147,31 @@ def create(
147147
description : str
148148
Description of the analysis
149149
from_default : bool, optional
150-
If True, use the default analysis to populate selected samples.
150+
If True, use the default analysis to populate selected samples;
151+
when True, we will create a `build_analysis_files` job.
151152
Default False.
152153
merge_duplicated_sample_ids : bool, optional
153154
If the duplicated sample ids in the selected studies should be
154155
merged or prepended with the artifact ids. False (default) prepends
155156
the artifact id
156157
categories : list of str, optional
157158
If not None, use _only_ these categories for the metaanalysis
158-
reservation : str
159+
reservation : str, optional
159160
The slurm reservation to asign to the analysis
160161
161162
Returns
162163
-------
163164
qdb.analysis.Analysis
164165
The newly created analysis
166+
167+
Notes
168+
-----
169+
Before 12.09.25 this method was fully tangled with `build_analysis_files`, which
170+
meant that we couldn't create a stand alone analysis; additionally, this method
171+
had the intrinsic assumption that we can create an analysis not from default but not
172+
pass any sample/artifact information - which will create an empty analysis but still submit
173+
a build_analysis_files file. Thus, we are using this assumption to define if we should
174+
create the `build_analysis_files` job
165175
"""
166176
with qdb.sql_connection.TRN:
167177
portal_id = qdb.util.convert_to_id(
@@ -199,6 +209,7 @@ def create(
199209
if reservation is not None:
200210
instance.slurm_reservation = reservation
201211

212+
if from_default:
202213
# Once the analysis is created, we can create the mapping file and
203214
# the initial set of artifacts
204215
plugin = qdb.software.Software.from_name_and_version("Qiita", "alpha")
@@ -211,15 +222,18 @@ def create(
211222
"categories": categories,
212223
},
213224
)
225+
214226
job = qdb.processing_job.ProcessingJob.create(owner, params, True)
215-
sql = """INSERT INTO qiita.analysis_processing_job
216-
(analysis_id, processing_job_id)
217-
VALUES (%s, %s)"""
218-
qdb.sql_connection.TRN.add(sql, [a_id, job.id])
219-
qdb.sql_connection.TRN.execute()
220227

221-
# Doing the submission outside of the transaction
222-
job.submit()
228+
with qdb.sql_connection.TRN:
229+
sql = """INSERT INTO qiita.analysis_processing_job
230+
(analysis_id, processing_job_id)
231+
VALUES (%s, %s)"""
232+
qdb.sql_connection.TRN.add(sql, [a_id, job.id])
233+
qdb.sql_connection.TRN.execute()
234+
235+
job.submit()
236+
223237
return instance
224238

225239
@classmethod

0 commit comments

Comments
 (0)