Skip to content

Commit 71c0b41

Browse files
josenavasantgonza
authored andcommitted
Transfer submit to vamps (#2265)
* Move qiita_db/private.py -> qiita_ware/private_plugin.py * Transferring VAMPS submission to internal job * Fixing import
1 parent 0be1275 commit 71c0b41

File tree

7 files changed

+62
-31
lines changed

7 files changed

+62
-31
lines changed

qiita_db/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,11 @@
2626
import study
2727
import user
2828
import processing_job
29-
import private
3029

3130
__version__ = "0.2.0-dev"
3231

3332
__all__ = ["analysis", "artifact", "base", "commands", "environment_manager",
3433
"exceptions", "investigation", "logger", "meta_util",
3534
"ontology", "portal", "reference", "search",
3635
"software", "sql_connection", "study", "user", "util",
37-
"metadata_template", "processing_job", "private"]
36+
"metadata_template", "processing_job"]

qiita_db/support_files/patches/58.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- Aug 31, 2017
2+
-- Remove MOI and transfer all jobs to internal QIITA plugin
3+
4+
SELECT 42;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# -----------------------------------------------------------------------------
2+
# Copyright (c) 2014--, The Qiita Development Team.
3+
#
4+
# Distributed under the terms of the BSD 3-clause License.
5+
#
6+
# The full license is in the file LICENSE, distributed with this software.
7+
# -----------------------------------------------------------------------------
8+
9+
from qiita_db.sql_connection import TRN
10+
from qiita_db.software import Software, Command
11+
12+
with TRN:
13+
# Retrieve the Qiita plugin
14+
qiita_plugin = Software.from_name_and_version('Qiita', 'alpha')
15+
16+
# Create the submit to VAMPS command
17+
parameters = {'artifact': ['artifact:["Demultiplexed"]', None]}
18+
Command.create(qiita_plugin, "submit_to_VAMPS",
19+
"submits an artifact to VAMPS", parameters)

qiita_pet/handlers/study_handlers/vamps_handlers.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
from tornado.web import authenticated, HTTPError
1111
from qiita_files.demux import stats as demux_stats
1212

13-
from qiita_ware.context import submit
14-
from qiita_ware.dispatchable import submit_to_VAMPS
1513
from qiita_db.exceptions import QiitaDBUnknownIDError
1614
from qiita_db.artifact import Artifact
15+
from qiita_db.software import Software, Parameters
16+
from qiita_db.processing_job import ProcessingJob
1717
from qiita_pet.handlers.base_handlers import BaseHandler
1818
from qiita_core.util import execute_as_transaction
1919

@@ -99,23 +99,23 @@ def post(self, preprocessed_data_id):
9999
user.id)
100100
msg = ''
101101
msg_level = 'success'
102-
study = Artifact(preprocessed_data_id).study
103-
study_id = study.id
104-
state = study.ebi_submission_status
105-
if state == 'submitting':
106-
msg = "Cannot resubmit! Current state is: %s" % state
107-
msg_level = 'danger'
108-
else:
109-
channel = user.id
110-
job_id = submit(channel, submit_to_VAMPS,
111-
int(preprocessed_data_id))
112102

113-
self.render('compute_wait.html',
114-
job_id=job_id, title='VAMPS Submission',
115-
completion_redirect=('/study/description/%s?top_tab='
116-
'preprocessed_data_tab&sub_tab=%s'
117-
% (study_id,
118-
preprocessed_data_id)))
119-
return
103+
plugin = Software.from_name_and_version('Qiita', 'alpha')
104+
cmd = plugin.get_command('submit_to_VAMPS')
105+
artifact = Artifact(preprocessed_data_id)
106+
107+
# Check if the artifact is already being submitted to VAMPS
108+
is_being_submitted = any(
109+
[j.status in ('queued', 'running')
110+
for j in artifact.jobs(cmd=cmd)])
120111

121-
self.display_template(preprocessed_data_id, msg, msg_level)
112+
if is_being_submitted == 'submitting':
113+
msg = "Cannot resubmit! Data is already being submitted"
114+
msg_level = 'danger'
115+
self.display_template(preprocessed_data_id, msg, msg_level)
116+
else:
117+
params = Parameters.load(
118+
cmd, values_dict={'artifact': preprocessed_data_id})
119+
job = ProcessingJob.create(user, params)
120+
job.submit()
121+
self.redirect('/study/description/%s' % artifact.study.study_id)

qiita_ware/dispatchable.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,14 @@
55
#
66
# The full license is in the file LICENSE, distributed with this software.
77
# -----------------------------------------------------------------------------
8-
from qiita_ware.commands import submit_EBI, submit_VAMPS
8+
from qiita_ware.commands import submit_EBI
99

1010

1111
def submit_to_ebi(preprocessed_data_id, submission_type):
1212
"""Submit a study to EBI"""
1313
submit_EBI(preprocessed_data_id, submission_type, True)
1414

1515

16-
def submit_to_VAMPS(preprocessed_data_id):
17-
"""Submit a study to VAMPS"""
18-
return submit_VAMPS(preprocessed_data_id)
19-
20-
2116
def copy_raw_data(prep_template, artifact_id):
2217
"""Creates a new raw data by copying from artifact_id
2318

qiita_db/private.py renamed to qiita_ware/private_plugin.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import traceback
1313

1414
import qiita_db as qdb
15+
from qiita_ware.commands import submit_VAMPS
1516

1617

1718
def build_analysis_files(job):
@@ -66,8 +67,21 @@ def release_validators(job):
6667
job._set_status('success')
6768

6869

70+
def submit_to_VAMPS(job):
71+
"""Submits an artifact to VAMPS
72+
73+
Parameters
74+
----------
75+
job : qiita_db.processing_job.ProcessingJob
76+
The processing job performing the task
77+
"""
78+
with qdb.sql_connection.TRN:
79+
submit_VAMPS(job.parameters.values['artifact'])
80+
81+
6982
TASK_DICT = {'build_analysis_files': build_analysis_files,
70-
'release_validators': release_validators}
83+
'release_validators': release_validators,
84+
'submit_to_VAMPS': submit_to_VAMPS}
7185

7286

7387
def private_task(job_id):

scripts/qiita-private-plugin

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import click
1212

13-
import qiita_db as qdb
13+
from qiita_ware.private_plugin import private_task
1414

1515

1616
@click.command()
@@ -23,7 +23,7 @@ def execute(url, job_id, output_dir):
2323
The parameters url and output_dir are ignored, but they are added for
2424
compatibility with the plugin system.
2525
"""
26-
qdb.private.private_task(job_id)
26+
private_task(job_id)
2727

2828

2929
if __name__ == '__main__':

0 commit comments

Comments
 (0)