-
Notifications
You must be signed in to change notification settings - Fork 0
feat: issue #11 and issue#12 #19
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
base: main
Are you sure you want to change the base?
Changes from all 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 | ||||
|---|---|---|---|---|---|---|
| @@ -1,15 +1,108 @@ | ||||||
| from flask import Blueprint, jsonify, request | ||||||
| from flask import Blueprint, jsonify, request, current_app | ||||||
| from datetime import datetime, timezone | ||||||
| import uuid | ||||||
| import json | ||||||
| import time | ||||||
| import requests | ||||||
| import shlex | ||||||
| import logging | ||||||
| from services.task_service import get_submitted_tasks, add_task, update_single_task_status | ||||||
| from utils.tes_utils import load_tes_instances | ||||||
| from utils.auth_utils import get_instance_credentials | ||||||
|
|
||||||
| logger = logging.getLogger(__name__) | ||||||
|
|
||||||
| tasks_bp = Blueprint('tasks', __name__) | ||||||
|
|
||||||
| def build_failed_task(tes_task, tes_url, tes_name, tes_endpoint=None, | ||||||
| error_message=None, error_type=None, error_code=None, | ||||||
| error_reason=None, http_status_code=None): | ||||||
| """ | ||||||
| Construct a standardized failed task dictionary. | ||||||
|
|
||||||
| Args: | ||||||
| tes_task: The TES task specification dict | ||||||
| tes_url: TES instance URL | ||||||
| tes_name: TES instance name | ||||||
| tes_endpoint: Optional TES endpoint used (if reached that stage) | ||||||
| error_message: Human-readable error description | ||||||
| error_type: Category of error (e.g., 'connection_error', 'bad_request') | ||||||
| error_code: Machine-readable error code | ||||||
| error_reason: Detailed reason for the error | ||||||
| http_status_code: HTTP status code if applicable | ||||||
|
|
||||||
| Returns: | ||||||
| Dict containing failed task with SUBMISSION_FAILED state | ||||||
| """ | ||||||
| now_iso = datetime.now(timezone.utc).isoformat() | ||||||
|
|
||||||
| failed_task = { | ||||||
| 'id': str(uuid.uuid4()), | ||||||
| 'task_id': 'N/A', | ||||||
| 'name': tes_task['name'], | ||||||
| 'task_name': tes_task['name'], | ||||||
| 'description': tes_task['description'], | ||||||
| 'state': 'SUBMISSION_FAILED', | ||||||
|
Comment on lines
+39
to
+45
|
||||||
| 'status': 'SUBMISSION_FAILED', | ||||||
| 'creation_time': now_iso, | ||||||
| 'submitted_at': now_iso, | ||||||
| 'start_time': None, | ||||||
| 'end_time': None, | ||||||
| 'tes_url': tes_url, | ||||||
| 'tes_name': tes_name, | ||||||
| 'tes_endpoint': tes_endpoint, | ||||||
| 'inputs': tes_task.get('inputs', []), | ||||||
| 'outputs': tes_task.get('outputs', []), | ||||||
| 'resources': tes_task.get('resources', {}), | ||||||
| 'executors': tes_task.get('executors', []), | ||||||
| 'volumes': [], | ||||||
| 'tags': {} | ||||||
| } | ||||||
|
|
||||||
| # Add error details if provided | ||||||
| if error_message: | ||||||
| failed_task['error_message'] = error_message | ||||||
| if error_type: | ||||||
| failed_task['error_type'] = error_type | ||||||
| if error_code: | ||||||
| failed_task['error_code'] = error_code | ||||||
| if error_reason: | ||||||
| failed_task['error_reason'] = error_reason | ||||||
| if http_status_code: | ||||||
|
||||||
| if http_status_code: | |
| if http_status_code is not None: |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,7 +86,7 @@ def update_single_task_status(task): | |
| return False | ||
|
|
||
| def update_task_statuses(): | ||
| terminal_states = ['COMPLETE', 'CANCELED', 'SYSTEM_ERROR', 'EXECUTOR_ERROR', 'PREEMPTED'] | ||
| terminal_states = ['COMPLETE', 'CANCELED', 'SYSTEM_ERROR', 'EXECUTOR_ERROR', 'PREEMPTED', 'SUBMISSION_FAILED'] | ||
|
||
|
|
||
| while True: | ||
| try: | ||
|
|
||
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.
Unused import:
current_appis imported but never referenced in this module. Please remove it to avoid linting/maintenance noise.