|
43 | 43 |
|
44 | 44 | from gevent.event import Event |
45 | 45 |
|
46 | | -from cms.db import Dataset, SessionGen, Submission, UserTest |
47 | | -from cms.grading.Job import Job, JobGroup |
| 46 | +from cms.db import SessionGen |
| 47 | +from cms.grading.Job import JobGroup |
48 | 48 | from cmscommon.datetime import make_datetime, make_timestamp |
49 | 49 |
|
50 | 50 |
|
@@ -221,30 +221,11 @@ def acquire_worker(self, operations): |
221 | 221 | self._start_time[shard] = make_datetime() |
222 | 222 |
|
223 | 223 | with SessionGen() as session: |
224 | | - jobs = [] |
225 | | - datasets = {} |
226 | | - submissions = {} |
227 | | - user_tests = {} |
228 | | - for operation in operations: |
229 | | - if operation.dataset_id not in datasets: |
230 | | - datasets[operation.dataset_id] = Dataset.get_from_id( |
231 | | - operation.dataset_id, session) |
232 | | - if operation.for_submission(): |
233 | | - if operation.object_id not in submissions: |
234 | | - submissions[operation.object_id] = \ |
235 | | - Submission.get_from_id( |
236 | | - operation.object_id, session) |
237 | | - object_ = submissions[operation.object_id] |
238 | | - else: |
239 | | - if operation.object_id not in user_tests: |
240 | | - user_tests[operation.object_id] = \ |
241 | | - UserTest.get_from_id(operation.object_id, session) |
242 | | - object_ = user_tests[operation.object_id] |
243 | | - logger.info("Asking worker %s to `%s'.", shard, operation) |
244 | | - |
245 | | - jobs.append(Job.from_operation( |
246 | | - operation, object_, datasets[operation.dataset_id])) |
247 | | - job_group_dict = JobGroup(jobs).export_to_dict() |
| 224 | + job_group_dict = \ |
| 225 | + JobGroup.from_operations(operations, session).export_to_dict() |
| 226 | + |
| 227 | + logger.info("Asking worker %s to %s.", shard, |
| 228 | + ", ".join("`%s'" % operation for operation in operations)) |
248 | 229 |
|
249 | 230 | self._worker[shard].execute_job_group( |
250 | 231 | job_group_dict=job_group_dict, |
|
0 commit comments