|
1 | 1 | """Celery tasks for CI platform operations.""" |
2 | 2 |
|
3 | | -from celery import shared_task |
4 | 3 | from celery.exceptions import SoftTimeLimitExceeded |
5 | 4 | from celery.utils.log import get_task_logger |
6 | 5 | from github import Auth, Github, GithubException |
@@ -31,16 +30,12 @@ def start_test_task(self, test_id: int, bot_token: str): |
31 | 30 | :return: Dict with status and message |
32 | 31 | """ |
33 | 32 | # Import inside task to avoid circular imports and ensure fresh Flask context |
34 | | - from run import app, config |
35 | | - |
36 | 33 | from database import create_session |
37 | | - from mod_ci.controllers import ( |
38 | | - get_compute_service_object, |
39 | | - mark_test_failed, |
40 | | - start_test, |
41 | | - ) |
| 34 | + from mod_ci.controllers import (get_compute_service_object, |
| 35 | + mark_test_failed, start_test) |
42 | 36 | from mod_ci.models import GcpInstance |
43 | 37 | from mod_test.models import Test |
| 38 | + from run import app, config |
44 | 39 |
|
45 | 40 | with app.app_context(): |
46 | 41 | db = create_session(config['DATABASE_URI']) |
@@ -123,11 +118,12 @@ def check_expired_instances_task(self): |
123 | 118 |
|
124 | 119 | :return: Dict with status and message |
125 | 120 | """ |
126 | | - from run import app, config |
| 121 | + from github import Auth, Github |
127 | 122 |
|
128 | 123 | from database import create_session |
129 | | - from github import Auth, Github |
130 | | - from mod_ci.controllers import delete_expired_instances, get_compute_service_object |
| 124 | + from mod_ci.controllers import (delete_expired_instances, |
| 125 | + get_compute_service_object) |
| 126 | + from run import app, config |
131 | 127 |
|
132 | 128 | with app.app_context(): |
133 | 129 | db = create_session(config['DATABASE_URI']) |
@@ -178,11 +174,10 @@ def process_pending_tests_task(self): |
178 | 174 |
|
179 | 175 | :return: Dict with status and count of queued tests |
180 | 176 | """ |
181 | | - from run import app, config |
182 | | - |
183 | 177 | from database import create_session |
184 | 178 | from mod_ci.models import GcpInstance, MaintenanceMode |
185 | 179 | from mod_test.models import Test, TestPlatform, TestProgress, TestStatus |
| 180 | + from run import app, config |
186 | 181 |
|
187 | 182 | with app.app_context(): |
188 | 183 | db = create_session(config['DATABASE_URI']) |
|
0 commit comments