Skip to content

Commit b398440

Browse files
author
Obada Haddad
committed
changed uuid naming scheme for ingestion and scoring containers to user pk + submission ID; changed temporary file naming scheme to include user pk and submission ID as prefix
1 parent aff8314 commit b398440

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
@@ -323,10 +323,13 @@ class Run:
323323
"""
324324

325325
def __init__(self, run_args):
326+
self.runRelatedName = (
327+
f"uPK-{run_args['user_pk']}_sID-{run_args['id']}"
328+
)
326329
# Directories for the run
327330
self.watch = True
328331
self.completed_program_counter = 0
329-
self.root_dir = tempfile.mkdtemp(dir=BASE_DIR)
332+
self.root_dir = tempfile.mkdtemp(prefix=f'{self.runRelatedName}__', dir=BASE_DIR)
330333
self.bundle_dir = os.path.join(self.root_dir, "bundles")
331334
self.input_dir = os.path.join(self.root_dir, "input")
332335
self.output_dir = os.path.join(self.root_dir, "output")
@@ -349,8 +352,8 @@ def __init__(self, run_args):
349352
self.stdout, self.stderr, self.ingestion_stdout, self.ingestion_stderr = (
350353
self._get_stdout_stderr_file_names(run_args)
351354
)
352-
self.ingestion_container_name = uuid.uuid4()
353-
self.program_container_name = uuid.uuid4()
355+
self.ingestion_container_name = f"ingestion_{self.runRelatedName}"
356+
self.program_container_name = f"scoring_{self.runRelatedName}"
354357
self.program_data = run_args.get("program_data")
355358
self.ingestion_program_data = run_args.get("ingestion_program")
356359
self.input_data = run_args.get("input_data")
@@ -449,10 +452,14 @@ async def send_detailed_results(self, file_path):
449452
)
450453
)
451454
except Exception as e:
452-
logger.error(f"This error might result in a Execution Time Exceeded error: {e}")
455+
logger.error(
456+
f"This error might result in a Execution Time Exceeded error: {e}"
457+
)
453458
if os.environ.get("LOG_LEVEL", "info").lower() == "debug":
454459
logger.exception(e)
455-
raise SubmissionException("Could not connect to instance to update detailed result")
460+
raise SubmissionException(
461+
"Could not connect to instance to update detailed result"
462+
)
456463

457464
def _get_stdout_stderr_file_names(self, run_args):
458465
# run_args should be the run_args argument passed to __init__ from the run_wrapper.
@@ -1223,11 +1230,16 @@ def start(self):
12231230
# Check if scoring program failed
12241231
program_results, _, _ = task_results
12251232
# Gather returns either normal values or exception instances when return_exceptions=True
1226-
had_async_exc = isinstance(program_results, BaseException) and not isinstance(program_results, asyncio.CancelledError)
1233+
had_async_exc = isinstance(
1234+
program_results, BaseException
1235+
) and not isinstance(program_results, asyncio.CancelledError)
12271236
program_rc = getattr(self, "program_exit_code", None)
12281237
failed_rc = program_rc not in (0, None)
12291238
if had_async_exc or failed_rc:
1230-
self._update_status(STATUS_FAILED, extra_information=f"program_rc={program_rc}, async={task_results}")
1239+
self._update_status(
1240+
STATUS_FAILED,
1241+
extra_information=f"program_rc={program_rc}, async={task_results}",
1242+
)
12311243
# Raise so upstream marks failed immediately
12321244
raise SubmissionException("Child task failed or non-zero return code")
12331245
self._update_status(STATUS_FINISHED)

0 commit comments

Comments
 (0)