Skip to content

Commit

Permalink
[rpc] Use a more terse name for service working directories.
Browse files Browse the repository at this point in the history
This shortens the "service-yyyy-mm-ddTHH-MM-SS.mmmm-hash" to
"s/mmddTHHMMSS-mmmmhash".
  • Loading branch information
ChrisCummins authored and bwasti committed Aug 3, 2021
1 parent 8805dc1 commit 187c001
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions compiler_gym/service/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,12 @@ def loglines(self) -> Iterable[str]:
yield from ()


def make_working_dir():
"""Make a working directory for a service. The calling code is responsible for
removing this directory when done.
def make_working_dir() -> Path:
"""Make a working directory for a service. The calling code is responsible
for removing this directory when done.
"""
timestamp = datetime.now().isoformat()
random_hash = random.getrandbits(16)
service_name = f"service-{timestamp}-{random_hash:04x}"
service_name = datetime.now().strftime(f"s/%m%dT%H%M%S-%f-{random_hash:04x}")
working_dir = transient_cache_path(service_name)
(working_dir / "logs").mkdir(parents=True, exist_ok=False)
return working_dir
Expand Down

0 comments on commit 187c001

Please sign in to comment.