Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding job submit ENVIRONMENT and minor improvement to runWorkflow #3040

Merged
merged 4 commits into from
Nov 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion qiita_db/processing_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -880,12 +880,30 @@ def submit(self, parent_job_id=None, dependent_jobs_list=None):
# portal server that submitted the job
url = "%s%s" % (qiita_config.base_url, qiita_config.portal_dir)

# if the word ENVIRONMENT is in the plugin_env_script we have a special
# case where we are going to execute some command and then wait for the
# plugin to return their own id (first implemented for
# fast-bowtie2+woltka)
if 'ENVIRONMENT' in plugin_env_script:
# the job has to be in running state so the plugin can change its`
# status
with qdb.sql_connection.TRN:
self._set_status('running')
qdb.sql_connection.TRN.commit()

create_nested_path(job_dir)
cmd = (f'{plugin_env_script}; {plugin_start_script} '
f'{url} {self.id} {job_dir}')
stdout, stderr, return_value = _system_call(cmd)
if return_value != 0 or stderr != '':
self._set_error(stderr)
job_id = stdout
ElDeveloper marked this conversation as resolved.
Show resolved Hide resolved
# note that dependent jobs, such as m validator jobs marshalled into
# n 'queues' require the job_id returned by an external scheduler such
# as Torque's MOAB, rather than a job name that can be defined within
# Qiita. Hence, this method must be able to handle the case where a job
# requires metadata from a late-defined and time-sensitive source.
if qiita_config.plugin_launcher in ProcessingJob._launch_map:
elif qiita_config.plugin_launcher in ProcessingJob._launch_map:
launcher = ProcessingJob._launch_map[qiita_config.plugin_launcher]
if launcher['execute_in_process']:
# run this launcher function within this process.
Expand Down
18 changes: 18 additions & 0 deletions qiita_db/test/test_processing_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,24 @@ def test_submit_error(self):
qdb.exceptions.QiitaDBOperationNotPermittedError):
job.submit()

def test_submit_environment(self):
job = _create_job()
software = job.command.software
current = software.environment_script

# temporal update and then rollback to not commit change
with qdb.sql_connection.TRN:
sql = """UPDATE qiita.software SET environment_script = %s
WHERE software_id = %s"""
qdb.sql_connection.TRN.add(sql, [
f'{current} ENVIRONMENT', software.id])

job.submit()

self.assertEqual(job.status, 'error')

qdb.sql_connection.TRN.rollback()

def test_complete_multiple_outputs(self):
# This test performs the test of multiple functions at the same
# time. "release", "release_validators" and
Expand Down
12 changes: 8 additions & 4 deletions qiita_pet/static/js/networkVue.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Vue.component('processing-graph', {
'<div class="col-md-2">' +
'<h4><span class="blinking-message">Start workflow:</h4></span>' +
'</div>' +
'<div class="col-md-1">' +
'<div class="col-md-2">' +
'<a class="btn btn-success form-control" id="run-btn"><span class="glyphicon glyphicon-play"></span> Run</a>' +
'</div>' +
'</div>' +
Expand Down Expand Up @@ -341,6 +341,8 @@ Vue.component('processing-graph', {
*
*/
runWorkflow: function() {
$('#run-btn').attr('disabled', true);
$('#run-btn').html('<span class="glyphicon glyphicon-stop"></span> Submitting');
let vm = this;
$.post(vm.portal + "/study/process/workflow/run/", {workflow_id: vm.workflowId}, function(data){
bootstrapAlert("Workflow " + vm.workflowId + " submitted", "success");
Expand All @@ -351,9 +353,11 @@ Vue.component('processing-graph', {
.fail(function(object, status, error_msg) {
bootstrapAlert("Error submitting workflow: " + object.statusText, "danger");
});
// return button to regular state
$('#run-btn').attr('disabled', false);
$('#run-btn').html('<span class="glyphicon glyphicon-play"></span> Run');
.always(function() {
// return button to regular state
$('#run-btn').attr('disabled', false);
$('#run-btn').html('<span class="glyphicon glyphicon-play"></span> Run');
});
},

/**
Expand Down