-
Notifications
You must be signed in to change notification settings - Fork 80
Fix 1812 #2371
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
Fix 1812 #2371
Changes from all commits
91b9e08
35b0168
352e9bb
0da47b2
0dc98c6
180b6d7
03db962
1fb126d
7303611
123ef94
c5db978
aa27112
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ | |
from qiita_core.qiita_settings import qiita_config | ||
|
||
|
||
def _create_job(): | ||
def _create_job(force=True): | ||
job = qdb.processing_job.ProcessingJob.create( | ||
qdb.user.User('test@foo.bar'), | ||
qdb.software.Parameters.load( | ||
|
@@ -37,7 +37,8 @@ def _create_job(): | |
"qual_score_window": 0, "disable_primers": False, | ||
"reverse_primers": "disable", | ||
"reverse_primer_mismatches": 0, | ||
"truncate_ambi_bases": False, "input_data": 1})) | ||
"truncate_ambi_bases": False, "input_data": 1}), | ||
force) | ||
return job | ||
|
||
|
||
|
@@ -246,7 +247,8 @@ def test_create(self): | |
exp_params = qdb.software.Parameters.load(exp_command, | ||
json_str=json_str) | ||
exp_user = qdb.user.User('test@foo.bar') | ||
obs = qdb.processing_job.ProcessingJob.create(exp_user, exp_params) | ||
obs = qdb.processing_job.ProcessingJob.create( | ||
exp_user, exp_params, True) | ||
self.assertEqual(obs.user, exp_user) | ||
self.assertEqual(obs.command, exp_command) | ||
self.assertEqual(obs.parameters, exp_params) | ||
|
@@ -256,6 +258,15 @@ def test_create(self): | |
self.assertEqual(obs.step, None) | ||
self.assertTrue(obs in qdb.artifact.Artifact(1).jobs()) | ||
|
||
def test_create_duplicated(self): | ||
job = _create_job() | ||
job._set_status('running') | ||
with self.assertRaisesRegexp(ValueError, 'Cannot create job because ' | ||
'the parameters are the same as jobs ' | ||
'that are queued, running or already ' | ||
'have succeeded:'): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How is this passing if this is not a regex, and there's no pattern to match here? Shouldn't there be a job id, or a regex indicating that this should match a job id? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cause it behaves as an IN. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it! |
||
_create_job(False) | ||
|
||
def test_set_status(self): | ||
job = _create_job() | ||
self.assertEqual(job.status, 'in_construction') | ||
|
@@ -328,7 +339,7 @@ def test_complete_multiple_outputs(self): | |
'out1', "command_output", "name"), | ||
'name': 'out1'})}) | ||
user = qdb.user.User('test@foo.bar') | ||
obs1 = qdb.processing_job.ProcessingJob.create(user, params) | ||
obs1 = qdb.processing_job.ProcessingJob.create(user, params, True) | ||
obs1._set_status('running') | ||
params = qdb.software.Parameters.load( | ||
qdb.software.Command(4), | ||
|
@@ -339,7 +350,7 @@ def test_complete_multiple_outputs(self): | |
'cmd_out_id': qdb.util.convert_to_id( | ||
'out1', "command_output", "name"), | ||
'name': 'out1'})}) | ||
obs2 = qdb.processing_job.ProcessingJob.create(user, params) | ||
obs2 = qdb.processing_job.ProcessingJob.create(user, params, True) | ||
obs2._set_status('running') | ||
# Make sure that we link the original job with its validator jobs | ||
job._set_validator_jobs([obs1, obs2]) | ||
|
@@ -416,7 +427,8 @@ def test_complete_no_artifact_data(self): | |
qdb.user.User('test@foo.bar'), | ||
qdb.software.Parameters.load( | ||
qdb.software.Command(5), | ||
values_dict={"input_data": 1})) | ||
values_dict={"input_data": 1}), | ||
True) | ||
job._set_status('running') | ||
job.complete(False, error='Some Error') | ||
self.assertEqual(job.status, 'error') | ||
|
@@ -450,7 +462,7 @@ def test_complete_type(self): | |
values_dict={'template': pt.id, 'files': fp, | ||
'artifact_type': 'BIOM'}) | ||
obs = qdb.processing_job.ProcessingJob.create( | ||
qdb.user.User('test@foo.bar'), params) | ||
qdb.user.User('test@foo.bar'), params, True) | ||
obs._set_status('running') | ||
obs.complete(True, artifacts_data=artifacts_data) | ||
self.assertEqual(obs.status, 'success') | ||
|
@@ -513,7 +525,7 @@ def test_complete_failure(self): | |
'cmd_out_id': 3})} | ||
) | ||
obs = qdb.processing_job.ProcessingJob.create( | ||
qdb.user.User('test@foo.bar'), params) | ||
qdb.user.User('test@foo.bar'), params, True) | ||
job._set_validator_jobs([obs]) | ||
obs.complete(False, error="Validation failure") | ||
self.assertEqual(obs.status, 'error') | ||
|
@@ -601,7 +613,7 @@ def test_update_children(self): | |
name = "Test processing workflow" | ||
|
||
tester = qdb.processing_job.ProcessingWorkflow.from_scratch( | ||
exp_user, exp_params, name=name) | ||
exp_user, exp_params, name=name, force=True) | ||
|
||
parent = tester.graph.nodes()[0] | ||
connections = {parent: {'demultiplexed': 'input_data'}} | ||
|
@@ -643,7 +655,7 @@ def test_outputs(self): | |
'name': 'outArtifact'})} | ||
) | ||
obs = qdb.processing_job.ProcessingJob.create( | ||
qdb.user.User('test@foo.bar'), params) | ||
qdb.user.User('test@foo.bar'), params, True) | ||
job._set_validator_jobs([obs]) | ||
exp_artifact_count = qdb.util.get_count('qiita.artifact') + 1 | ||
obs._complete_artifact_definition(artifact_data) | ||
|
@@ -722,7 +734,7 @@ def test_from_default_workflow(self): | |
name = "Test processing workflow" | ||
|
||
obs = qdb.processing_job.ProcessingWorkflow.from_default_workflow( | ||
exp_user, dflt_wf, req_params, name=name) | ||
exp_user, dflt_wf, req_params, name=name, force=True) | ||
self.assertEqual(obs.name, name) | ||
self.assertEqual(obs.user, exp_user) | ||
obs_graph = obs.graph | ||
|
@@ -786,7 +798,7 @@ def test_from_scratch(self): | |
name = "Test processing workflow" | ||
|
||
obs = qdb.processing_job.ProcessingWorkflow.from_scratch( | ||
exp_user, exp_params, name=name) | ||
exp_user, exp_params, name=name, force=True) | ||
self.assertEqual(obs.name, name) | ||
self.assertEqual(obs.user, exp_user) | ||
obs_graph = obs.graph | ||
|
@@ -811,12 +823,12 @@ def test_add(self): | |
name = "Test processing workflow" | ||
|
||
obs = qdb.processing_job.ProcessingWorkflow.from_scratch( | ||
exp_user, exp_params, name=name) | ||
exp_user, exp_params, name=name, force=True) | ||
|
||
parent = obs.graph.nodes()[0] | ||
connections = {parent: {'demultiplexed': 'input_data'}} | ||
dflt_params = qdb.software.DefaultParameters(10) | ||
obs.add(dflt_params, connections=connections) | ||
obs.add(dflt_params, connections=connections, force=True) | ||
|
||
obs_graph = obs.graph | ||
self.assertTrue(isinstance(obs_graph, nx.DiGraph)) | ||
|
@@ -843,7 +855,7 @@ def test_add(self): | |
# This also tests that the `graph` property returns the graph correctly | ||
# when there are root nodes that don't have any children | ||
dflt_params = qdb.software.DefaultParameters(1) | ||
obs.add(dflt_params, req_params={'input_data': 1}) | ||
obs.add(dflt_params, req_params={'input_data': 1}, force=True) | ||
|
||
obs_graph = obs.graph | ||
self.assertTrue(isinstance(obs_graph, nx.DiGraph)) | ||
|
@@ -887,7 +899,7 @@ def test_remove(self): | |
name = "Test processing workflow" | ||
|
||
tester = qdb.processing_job.ProcessingWorkflow.from_scratch( | ||
exp_user, exp_params, name=name) | ||
exp_user, exp_params, name=name, force=True) | ||
|
||
parent = tester.graph.nodes()[0] | ||
connections = {parent: {'demultiplexed': 'input_data'}} | ||
|
@@ -910,7 +922,7 @@ def test_remove(self): | |
name = "Test processing workflow" | ||
|
||
tester = qdb.processing_job.ProcessingWorkflow.from_default_workflow( | ||
exp_user, dflt_wf, req_params, name=name) | ||
exp_user, dflt_wf, req_params, name=name, force=True) | ||
|
||
tester.remove(tester.graph.edges()[0][0], cascade=True) | ||
|
||
|
@@ -929,7 +941,7 @@ def test_remove_error(self): | |
name = "Test processing workflow" | ||
|
||
tester = qdb.processing_job.ProcessingWorkflow.from_default_workflow( | ||
exp_user, dflt_wf, req_params, name=name) | ||
exp_user, dflt_wf, req_params, name=name, force=True) | ||
|
||
with self.assertRaises( | ||
qdb.exceptions.QiitaDBOperationNotPermittedError): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we default to
True
, are there situations in the codebase where this isFalse
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or rather, this API has changed I believe since the existing functionality would be
force=False
if I understand the docs above. Will this change be a problem elsewhere?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...or was the default behavior previously to force the execution?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a local function to avoid duplication of code that by default always ignores/forces the duplicated jobs. There is a single test (below) that doesn't force this behavior:
_create_job(False)