Skip to content

Commit

Permalink
Fixes after rebasing on top of the PYTHONPATH removal
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Marr <[email protected]>
  • Loading branch information
smarr committed Jan 28, 2025
1 parent 098d48b commit 2954cfb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
19 changes: 9 additions & 10 deletions rebench/denoise_client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import getpass
import json
import os

from subprocess import check_output, STDOUT, CalledProcessError
from typing import Optional, Tuple
Expand Down Expand Up @@ -70,8 +69,12 @@ def system_default() -> "DenoiseInitialSettings":


def _construct_basic_path(env_keys: list[str]) -> list[str]:
assert len(env_keys) > 0
return ["sudo", "--preserve-env=" + ",".join(env_keys), "-n", paths.get_denoise(), "--json"]
if len(env_keys) == 0:
preserve = []
else:
preserve = ["--preserve-env=" + ",".join(env_keys)]

return ["sudo"] + preserve + ["-n", paths.get_denoise(), "--json"]


def _construct_path(for_profiling: bool, env_keys: list[str]) -> list[str]:
Expand Down Expand Up @@ -132,9 +135,8 @@ def _add_denoise_exec_options(cmd: list[str], requested: Denoise):


def _exec_denoise(cmd: list[str]):
env = _get_env_with_python_path_for_denoise()
try:
output = output_as_str(check_output(cmd, stderr=STDOUT, env=env))
output = output_as_str(check_output(cmd, stderr=STDOUT))
except CalledProcessError as e:
output = output_as_str(e.output)
except FileNotFoundError as e:
Expand Down Expand Up @@ -262,15 +264,12 @@ def minimize_noise(possible_settings: Denoise, for_profiling: bool, show_warning
result, got_json, raw_output, msg, show_warnings, ui, possible_settings)


def construct_denoise_exec_prefix(
env, for_profiling, possible_settings: Denoise) -> Tuple[str, dict]:
env = _add_denoise_python_path_to_env(env)
def construct_denoise_exec_prefix(env, for_profiling, possible_settings: Denoise) -> str:
cmd = _construct_path(for_profiling, env.keys())

_add_denoise_exec_options(cmd, possible_settings)

cmd += ["exec", "--"]
return " ".join(cmd) + " ", env
return " ".join(cmd) + " "

def restore_noise(denoise_result: DenoiseInitialSettings, show_warning, ui):
if denoise_result.nothing_set:
Expand Down
5 changes: 2 additions & 3 deletions rebench/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,11 @@ def _create_scheduler(self, scheduler, print_execution_plan):

def _construct_cmdline_and_env(self, run_id: "RunId", gauge_adapter):
possible_settings = run_id.denoise.possible_settings(self._denoise_initial)
env = run_id.env
if possible_settings.needs_denoise():
cmdline, env = construct_denoise_exec_prefix(
run_id.env, run_id.is_profiling(), possible_settings)
cmdline = construct_denoise_exec_prefix(env, run_id.is_profiling(), possible_settings)
else:
cmdline = ""
env = run_id.env

cmdline += gauge_adapter.acquire_command(run_id)

Expand Down
11 changes: 5 additions & 6 deletions rebench/model/profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,19 @@ def __lt__(self, other):

return self.report_args < other.report_args

def _construct_report_cmdline_and_env(self, executor, run_id):
def _construct_report_cmdline(self, executor, run_id):
# need to use sudo, otherwise, the profile.perf file won't be accessible
possible_settings = run_id.denoise.possible_settings(executor.get_denoise_initial())
if possible_settings.needs_denoise():
cmd, env = construct_denoise_exec_prefix(run_id.env, True, Denoise.system_default())
cmd = construct_denoise_exec_prefix(run_id.env, True, Denoise.system_default())
else:
env = run_id.env
cmd = ""

return cmd + self.command + " " + self.report_args, env
return cmd + self.command + " " + self.report_args

def process_profile(self, run_id, executor):
cmdline, env = self._construct_report_cmdline_and_env(executor, run_id)
(return_code, output, _) = run(cmdline, env, cwd=run_id.location, shell=True,
cmdline = self._construct_report_cmdline(executor, run_id)
(return_code, output, _) = run(cmdline, run_id.env, cwd=run_id.location, shell=True,
verbose=executor.debug)

if return_code != 0:
Expand Down

0 comments on commit 2954cfb

Please sign in to comment.