Skip to content

Commit 9db885d

Browse files
authored
[Benchmarks] Print all important env vars in debug logs (#20415)
Print also PATH and LD_LIBRARY_PATH when these are modified in benchmark commands.
1 parent c614b19 commit 9db885d

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

devops/scripts/benchmarks/utils/utils.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,31 +49,37 @@ def run(
4949
command = command.split()
5050

5151
env = os.environ.copy()
52-
5352
for ldlib in ld_library:
5453
if os.path.isdir(ldlib):
55-
env["LD_LIBRARY_PATH"] = (
56-
ldlib + os.pathsep + env.get("LD_LIBRARY_PATH", "")
54+
env_vars["LD_LIBRARY_PATH"] = os.pathsep.join(
55+
filter(None, [ldlib, env_vars.get("LD_LIBRARY_PATH", "")])
5756
)
5857
else:
5958
log.warning(f"LD_LIBRARY_PATH component does not exist: {ldlib}")
6059

6160
# order is important, we want provided sycl rt libraries to be first
6261
if add_sycl:
6362
sycl_bin_path = os.path.join(options.sycl, "bin")
64-
env["PATH"] = sycl_bin_path + os.pathsep + env.get("PATH", "")
63+
env_vars["PATH"] = os.pathsep.join(
64+
filter(None, [sycl_bin_path, env_vars.get("PATH", "")])
65+
)
6566
sycl_lib_path = os.path.join(options.sycl, "lib")
66-
env["LD_LIBRARY_PATH"] = (
67-
sycl_lib_path + os.pathsep + env.get("LD_LIBRARY_PATH", "")
67+
env_vars["LD_LIBRARY_PATH"] = os.pathsep.join(
68+
filter(None, [sycl_lib_path, env_vars.get("LD_LIBRARY_PATH", "")])
6869
)
6970

70-
env.update(env_vars)
71-
7271
command_str = " ".join(command)
7372
env_str = " ".join(f"{key}={value}" for key, value in env_vars.items())
7473
full_command_str = f"{env_str} {command_str}".strip()
7574
log.debug(f"Running: {full_command_str}")
7675

76+
for key, value in env_vars.items():
77+
# Only PATH and LD_LIBRARY_PATH should be prepended to existing values
78+
if key in ("PATH", "LD_LIBRARY_PATH") and (old := env.get(key)):
79+
env[key] = os.pathsep.join([value, old])
80+
else:
81+
env[key] = value
82+
7783
# Normalize input to bytes if it's a str
7884
if isinstance(input, str):
7985
input_bytes = input.encode()

0 commit comments

Comments
 (0)