Skip to content
Snippets Groups Projects
Commit 0eec7704 authored by Raphaël Gomès's avatar Raphaël Gomès
Browse files

simple-command: expose a temporary variable `POULPE_TEMP_DIR` to benchmarks

This will make it easy for benchmarks to have small temporary artifacts.
In the future, we might want to configure where this temp dir is created,
because it might be important for performance reasons.
parent cb4ec5aa
No related branches found
No related tags found
1 merge request!44Suite agnostic tooling, improvements to simple-command, SWH suite
import json
import os
import shutil
import subprocess
import sys
import tempfile
......@@ -229,10 +230,18 @@
cmd.apply_data_env(data_env)
prepare = self.get_var("simple-command.prepare-run")
r = self._time_command(
bin_env_path, data_env_path, cmd, prepare, debug=debug
)
temp_dir = tempfile.mkdtemp() # TODO same tmp dir as `copy-data-env`
try:
r = self._time_command(
bin_env_path,
data_env_path,
cmd,
temp_dir=temp_dir,
prepare=prepare,
debug=debug,
)
finally:
shutil.rmtree(temp_dir, ignore_errors=True)
res = {}
# TODO record poulpe version in results in case results accidentally
......@@ -248,7 +257,13 @@
return res
def _time_command(
self, bin_env_path, data_env_path, cmd, prepare=None, debug=False
self,
bin_env_path,
data_env_path,
cmd,
temp_dir,
prepare=None,
debug=False,
):
bin_env_path = os.path.abspath(bin_env_path)
data_env_path = os.path.abspath(data_env_path)
......@@ -261,6 +276,7 @@
# Give the benchmarks the tools to do more advanced path manipulation
# without assuming the exact structure.
env["POULPE_DATA_ENV_ROOT"] = data_env_path
env["POULPE_TMP_DIR"] = temp_dir
if cmd.cwd is not None:
env["POULPE_CWD"] = cmd.cwd
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment