|
116 | 116 | ] |
117 | 117 | MAX_EXECUTION_TIME_LIMIT = int(os.environ.get('MAX_EXECUTION_TIME_LIMIT', 600)) # time limit of the default queue |
118 | 118 |
|
| 119 | +import sys |
| 120 | +import os |
119 | 121 |
|
120 | 122 | def _send_to_compute_worker(submission, is_scoring): |
| 123 | + print("CONTAINER CHECK PID=", os.getpid(), flush=True) |
| 124 | + sys.stderr.write("STDERR TEST\n") |
| 125 | + sys.stderr.flush() |
| 126 | + |
| 127 | + print("STDOUT TEST", flush=True) |
| 128 | + |
| 129 | + logger.error("LOGGER ERROR TEST") |
| 130 | + |
| 131 | + logger.warning("ZZZZ _send_to_compute_worker called") |
121 | 132 | run_args = { |
122 | 133 | "user_pk": submission.owner.pk, |
123 | 134 | "submissions_api_url": settings.SUBMISSIONS_API_URL, |
@@ -201,6 +212,49 @@ def _send_to_compute_worker(submission, is_scoring): |
201 | 212 | time_padding = 60 * 20 # 20 minutes |
202 | 213 | time_limit = submission.phase.execution_time_limit + time_padding |
203 | 214 |
|
| 215 | + print("DJANGO VIEW REACHED", flush=True) |
| 216 | + logger.warning("test Avant try") |
| 217 | + |
| 218 | + |
| 219 | + try: |
| 220 | + competition = submission.phase.competition |
| 221 | + |
| 222 | + user_group_ids = list(submission.owner.groups.values_list("id", flat=True)) |
| 223 | + logger.debug("User %s groups ids: %s", submission.owner.pk, user_group_ids) |
| 224 | + |
| 225 | + comp_user_groups_qs = ( |
| 226 | + competition.participant_groups |
| 227 | + .select_related("queue") |
| 228 | + .filter(id__in=user_group_ids) |
| 229 | + ) |
| 230 | + |
| 231 | + group = comp_user_groups_qs.filter(queue__isnull=False).first() or comp_user_groups_qs.first() |
| 232 | + |
| 233 | + if group: |
| 234 | + logger.info( |
| 235 | + "Submission %s candidate group(s) in competition %s: chosen group=%s queue=%s", |
| 236 | + submission.pk, |
| 237 | + competition.pk, |
| 238 | + group.pk, |
| 239 | + getattr(group.queue, "name", None), |
| 240 | + ) |
| 241 | + |
| 242 | + if group.queue: |
| 243 | + run_args["queue"] = group.queue.name |
| 244 | + competition.queue = group.queue |
| 245 | + else: |
| 246 | + logger.debug( |
| 247 | + "Submission %s owner %s: no intersection between user's groups %s and competition %s participant_groups", |
| 248 | + submission.pk, |
| 249 | + submission.owner.pk, |
| 250 | + user_group_ids, |
| 251 | + competition.pk, |
| 252 | + ) |
| 253 | + |
| 254 | + except Exception: |
| 255 | + logger.exception("Error while resolving competition/group for submission %s", submission.pk) |
| 256 | + |
| 257 | + |
204 | 258 | if submission.phase.competition.queue: # if the competition is running on a custom queue, not the default queue |
205 | 259 | submission.queue_name = submission.phase.competition.queue.name or '' |
206 | 260 | run_args['execution_time_limit'] = submission.phase.execution_time_limit # use the competition time limit |
|
0 commit comments