- 
                Notifications
    You must be signed in to change notification settings 
- Fork 79
Workflow object #1641
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
Workflow object #1641
Changes from 32 commits
261e4f2
              b516a49
              6efbfdb
              2f1d29e
              ac860d2
              77ac8eb
              320f681
              1e0e381
              08bd0b1
              9022c1d
              e863c01
              b647e2a
              a9fa2ec
              f582051
              de4bceb
              0d116b0
              d732e24
              f24dd63
              3ee5a69
              7aa1dda
              4e7d884
              08e4e2c
              e911e61
              6804cbf
              719dd8e
              3af70a4
              d6a9db0
              b59bf52
              c58d3ab
              12b3d7a
              6ac0bbd
              d78be98
              b3134f8
              99f2b71
              2a5ff50
              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 | 
|---|---|---|
|  | @@ -6,7 +6,6 @@ | |
| # The full license is in the file LICENSE, distributed with this software. | ||
| # ----------------------------------------------------------------------------- | ||
|  | ||
| from datetime import datetime | ||
| from json import loads | ||
|  | ||
| import qiita_db as qdb | ||
|  | @@ -104,15 +103,11 @@ def post(self, job_id): | |
| with qdb.sql_connection.TRN: | ||
| job, success, error_msg = _get_job(job_id) | ||
| if success: | ||
| job_status = job.status | ||
| if job_status == 'queued': | ||
| job.status = 'running' | ||
| job.heartbeat = datetime.now() | ||
| elif job_status == 'running': | ||
| job.heartbeat = datetime.now() | ||
| else: | ||
| try: | ||
| job.update_heartbeat_state() | ||
| except qdb.exceptions.QiitaDBOperationNotPermittedError as e: | ||
| success = False | ||
| error_msg = 'Job already finished. Status: %s' % job_status | ||
| error_msg = str(e) | ||
|  | ||
| response = {'success': success, 'error': error_msg} | ||
| self.write(response) | ||
|  | @@ -175,26 +170,19 @@ def post(self, job_id): | |
| with qdb.sql_connection.TRN: | ||
| job, success, error_msg = _get_job(job_id) | ||
| if success: | ||
| if job.status != 'running': | ||
| success = False | ||
| error_msg = 'Job in a non-running state.' | ||
| else: | ||
| payload = loads(self.request.body) | ||
| if payload['success']: | ||
| for artifact_data in payload['artifacts']: | ||
| filepaths = artifact_data['filepaths'] | ||
| atype = artifact_data['artifact_type'] | ||
| parents = job.input_artifacts | ||
| params = job.parameters | ||
| qdb.artifact.Artifact.create( | ||
| filepaths, atype, parents=parents, | ||
| processing_parameters=params) | ||
| job.status = 'success' | ||
| payload = loads(self.request.body) | ||
| try: | ||
| payload_success = payload['success'] | ||
| if payload_success: | ||
| artifacts = payload['artifacts'] | ||
| error = None | ||
|          | ||
| else: | ||
| log = qdb.logger.LogEntry.create( | ||
| 'Runtime', payload['error']) | ||
| job.status = 'error' | ||
| job.log = log | ||
| artifacts = None | ||
| error = payload['error'] | ||
| job.complete(payload_success, artifacts, error) | ||
| except qdb.exceptions.QiitaDBOperationNotPermittedError as e: | ||
| success = False | ||
| error_msg = str(e) | ||
|  | ||
| response = {'success': success, 'error': error_msg} | ||
| self.write(response) | ||
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.
Would you mind restricting the scope of this try block to just the line that might raise the exception?
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.
Done