MCPcopy Create free account
hub / github.com/It4innovations/hyperqueue / generate_job_dir

Function generate_job_dir

benchmarks/src/submit/utils.py:5–19  ·  view source on GitHub ↗

Tries to find a directory in `workdir` which name is an integer and return a large integer padded. The returned name is padded by zeros.

(workdir: Path)

Source from the content-addressed store, hash-verified

3
4
5def generate_job_dir(workdir: Path) -> Path:
6 """Tries to find a directory in `workdir` which name is an integer and return a large integer
7 padded. The returned name is padded by zeros."""
8 workdir.mkdir(parents=True, exist_ok=True)
9
10 ids = []
11 for item in workdir.iterdir():
12 if item.is_dir():
13 try:
14 ids.append(int(item.name))
15 except BaseException:
16 pass
17 max_id = max(ids or [0])
18 dir_name = f"{max_id + 1:03}"
19 return (workdir / dir_name).absolute()
20
21
22def format_allocation_time(duration: datetime.timedelta) -> str:

Callers 2

executeFunction · 0.90
run_in_slurmFunction · 0.85

Calls 1

appendMethod · 0.80

Tested by

no test coverage detected