Skip to content

Commit 65d0028

Browse files
authored
Merge pull request #2194 from codalab/cw_better_naming
Made competition container and temp folder names more readable
2 parents a4c4730 + 9ab95e8 commit 65d0028

1 file changed

Lines changed: 19 additions & 7 deletions

File tree

compute_worker/compute_worker.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,13 @@ class Run:
345345
"""
346346

347347
def __init__(self, run_args):
348+
self.run_related_name = (
349+
f"uPK-{run_args['user_pk']}_sID-{run_args['id']}"
350+
)
348351
# Directories for the run
349352
self.watch = True
350353
self.completed_program_counter = 0
351-
self.root_dir = tempfile.mkdtemp(dir=BASE_DIR)
354+
self.root_dir = tempfile.mkdtemp(prefix=f'{self.run_related_name}__', dir=BASE_DIR)
352355
self.bundle_dir = os.path.join(self.root_dir, "bundles")
353356
self.input_dir = os.path.join(self.root_dir, "input")
354357
self.output_dir = os.path.join(self.root_dir, "output")
@@ -371,8 +374,8 @@ def __init__(self, run_args):
371374
self.stdout, self.stderr, self.ingestion_stdout, self.ingestion_stderr = (
372375
self._get_stdout_stderr_file_names(run_args)
373376
)
374-
self.ingestion_container_name = uuid.uuid4()
375-
self.program_container_name = uuid.uuid4()
377+
self.ingestion_container_name = f"ingestion_{self.run_related_name}"
378+
self.program_container_name = f"scoring_{self.run_related_name}"
376379
self.program_data = run_args.get("program_data")
377380
self.ingestion_program_data = run_args.get("ingestion_program")
378381
self.input_data = run_args.get("input_data")
@@ -471,10 +474,14 @@ async def send_detailed_results(self, file_path):
471474
)
472475
)
473476
except Exception as e:
474-
logger.error(f"This error might result in a Execution Time Exceeded error: {e}")
477+
logger.error(
478+
f"This error might result in a Execution Time Exceeded error: {e}"
479+
)
475480
if os.environ.get("LOG_LEVEL", "info").lower() == "debug":
476481
logger.exception(e)
477-
raise SubmissionException("Could not connect to instance to update detailed result")
482+
raise SubmissionException(
483+
"Could not connect to instance to update detailed result"
484+
)
478485

479486
def _get_stdout_stderr_file_names(self, run_args):
480487
# run_args should be the run_args argument passed to __init__ from the run_wrapper.
@@ -1247,11 +1254,16 @@ def start(self):
12471254
# Check if scoring program failed
12481255
program_results, _, _ = task_results
12491256
# Gather returns either normal values or exception instances when return_exceptions=True
1250-
had_async_exc = isinstance(program_results, BaseException) and not isinstance(program_results, asyncio.CancelledError)
1257+
had_async_exc = isinstance(
1258+
program_results, BaseException
1259+
) and not isinstance(program_results, asyncio.CancelledError)
12511260
program_rc = getattr(self, "program_exit_code", None)
12521261
failed_rc = program_rc not in (0, None)
12531262
if had_async_exc or failed_rc:
1254-
self._update_status(STATUS_FAILED, extra_information=f"program_rc={program_rc}, async={task_results}")
1263+
self._update_status(
1264+
STATUS_FAILED,
1265+
extra_information=f"program_rc={program_rc}, async={task_results}",
1266+
)
12551267
# Raise so upstream marks failed immediately
12561268
raise SubmissionException("Child task failed or non-zero return code")
12571269
self._update_status(STATUS_FINISHED)

0 commit comments

Comments
 (0)