- 
                Notifications
    You must be signed in to change notification settings 
- Fork 79
fix #2902 #2994
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 #2902 #2994
Changes from 2 commits
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 | 
|---|---|---|
|  | @@ -591,6 +591,9 @@ def create(cls, user, parameters, force=False): | |
| TTRN.add(sql, [artifact_info, job_id]) | ||
| else: | ||
| pending[artifact_info[0]][pname] = artifact_info[1] | ||
| elif pname == 'artifact': | ||
| 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. Would you mind describing what's going on here? 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. Sure, the  (*) all regular jobs, except internal Qiita, have their parameters in this format: parameter_name: [parameter_type, value]; so normally, we just check that parameter_type is  | ||
| TTRN.add(sql, [parameters.values[pname], job_id]) | ||
|  | ||
| if pending: | ||
| sql = """UPDATE qiita.processing_job | ||
| SET pending = %s | ||
|  | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -14,6 +14,7 @@ | |
| from shutil import copyfile | ||
| from functools import partial | ||
| from json import dumps | ||
| from time import sleep | ||
|  | ||
| import pandas as pd | ||
| import networkx as nx | ||
|  | @@ -1114,6 +1115,45 @@ def test_delete_with_jobs(self): | |
| # Check that the job still exists, so we cap keep track of system usage | ||
| qdb.processing_job.ProcessingJob(job.id) | ||
|  | ||
| def test_being_deleted_by(self): | ||
| test = qdb.artifact.Artifact.create( | ||
| self.filepaths_root, "FASTQ", prep_template=self.prep_template) | ||
| uploads_fp = join(qdb.util.get_mountpoint("uploads")[0][1], | ||
| str(test.study.id)) | ||
| self._clean_up_files.extend( | ||
| [join(uploads_fp, basename(x['fp'])) for x in test.filepaths]) | ||
|  | ||
| # verifying that there are no jobs in the list | ||
| self.assertIsNone(test.being_deleted_by) | ||
|  | ||
| # creating new deleting job | ||
| qiita_plugin = qdb.software.Software.from_name_and_version( | ||
| 'Qiita', 'alpha') | ||
| cmd = qiita_plugin.get_command('delete_artifact') | ||
| params = qdb.software.Parameters.load( | ||
| cmd, values_dict={'artifact': test.id}) | ||
| job = qdb.processing_job.ProcessingJob.create( | ||
| qdb.user.User('test@foo.bar'), params, True) | ||
| job._set_status('running') | ||
|  | ||
| # verifying that there is a job and is the same than above | ||
| self.assertEqual(job, test.being_deleted_by) | ||
|  | ||
| # let's set it as error and now we should not have it anymore | ||
| job._set_error('Killed by admin') | ||
| self.assertIsNone(test.being_deleted_by) | ||
|  | ||
| # now, let's actually remove | ||
| job = qdb.processing_job.ProcessingJob.create( | ||
| qdb.user.User('test@foo.bar'), params, True) | ||
| job.submit() | ||
| # let's wait for job | ||
| while job.status in ('queued', 'running'): | ||
| sleep(1) | ||
|          | ||
|  | ||
| with self.assertRaises(qdb.exceptions.QiitaDBUnknownIDError): | ||
| qdb.artifact.Artifact(test.id) | ||
|  | ||
| def test_delete_as_output_job(self): | ||
| fd, fp = mkstemp(suffix='_table.biom') | ||
| self._clean_up_files.append(fp) | ||
|  | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -188,6 +188,9 @@ def get_network_nodes_edges(graph, full_access, nodes=None, edges=None): | |
| # n[1] is the object | ||
| for n in graph.nodes(): | ||
| if n[0] == 'job': | ||
| # ignoring internal Jobs | ||
| 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. Does this need a new test case? 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. This if is needed as a consequence of now adding the internal jobs to the database; my guess is that originally we didn't have it cause we didn't store them. In other words, the test for these method would need to change if we didn't have this if (as now the jobs will be returned here) AKA it's being tested here. | ||
| if n[1].command.software.name == 'Qiita': | ||
| continue | ||
| atype = 'job' | ||
| name = n[1].command.name | ||
| status = n[1].status | ||
|  | ||
Uh oh!
There was an error while loading. Please reload this page.