Skip to content

Commit

Permalink
Added temp files
Browse files Browse the repository at this point in the history
  • Loading branch information
leventeBajczi committed Feb 18, 2024
1 parent 18ffb45 commit c88e5dc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions contrib/slurm-benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ def create_argument_parser(self):
type=str,
help="The path to the singularity .sif file to use. Will bind $PWD to $HOME when run.",
)
slurm_args.add_argument(
"--scratchdir",
dest="scratchdir",
type=str,
default="./",
help="The path to the singularity .sif file to use. Will bind $PWD to $HOME when run.",
)

return parser

Expand Down
6 changes: 5 additions & 1 deletion contrib/slurm/slurmexecutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ def execute(self, run):
except KeyboardInterrupt:
# If the run was interrupted, we ignore the result and cleanup.
stop()

if STOPPED_BY_INTERRUPT:
try:
if benchmark.config.debug:
os.rename(run.log_file, run.log_file + ".killed")
Expand All @@ -216,7 +218,9 @@ def run_slurm(benchmark, args, log_file, timelimit, cpus, memory):

mem_per_cpu = int(memory / cpus / 1000000)

with tempfile.TemporaryDirectory() as tempdir:
assert benchmark.config.scratchdir and os.path.exists(benchmark.config.scratchdir)

with tempfile.TemporaryDirectory(dir=benchmark.config.scratchdir) as tempdir:

os.makedirs(os.path.join(tempdir, "upper"))
os.makedirs(os.path.join(tempdir, "work"))
Expand Down

0 comments on commit c88e5dc

Please sign in to comment.