Skip to content

Commit 6d494a6

Browse files
committed
triage: consistent {url: container} mapping
1 parent 4910346 commit 6d494a6

File tree

1 file changed

+7
-1
lines changed
  • .github/triage/jax_toolbox_triage

1 file changed

+7
-1
lines changed

.github/triage/jax_toolbox_triage/pyxis.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
import hashlib
12
import logging
23
import pathlib
34
import secrets
45
import subprocess
56
import typing
67

8+
# Used to make sure the {url: name} mapping is consistent within a process, but that
9+
# names are not re-used by different invocations of the triage tool. Using a consistent
10+
# mapping is a simple way of avoiding re-creating the container multiple times, e.g.
11+
# for .exists()
12+
_process_token = secrets.token_bytes()
713

814
class PyxisContainer:
915
def __init__(
@@ -16,7 +22,7 @@ def __init__(
1622
self._logger = logger
1723
mount_str = ",".join(map(lambda t: f"{t[0]}:{t[1]}", mounts))
1824
self._mount_args = [f"--container-mounts={mount_str}"] if mount_str else []
19-
self._name = secrets.token_urlsafe()
25+
self._name = hashlib.sha256(url.encode() + _process_token).hexdigest()
2026
self._url = url
2127

2228
def __enter__(self):

0 commit comments

Comments
 (0)