Skip to content

Commit

Permalink
Make build step work for hh5 environment
Browse files Browse the repository at this point in the history
  • Loading branch information
abhaasgoyal committed Feb 14, 2024
1 parent 2dfc9f8 commit 7c8fa5a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions benchcab/benchcab.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,18 @@ def __init__(
self.benchcab_exe_path = benchcab_exe_path
self.validate_env = validate_env

self._system_paths = ["/bin", "/usr/bin", "/usr/local/bin"]
self._config: Optional[dict] = None
self._models: list[Model] = []
self.tasks: list[Task] = [] # initialise fluxsite tasks lazily

self._set_environment()

def _set_environment(self):
"""Sets environment variables on current user environment."""
# Prioritize system binaries over externally set $PATHs (#220)
os.environ["PATH"] = f"{':'.join(self._system_paths)}:{os.environ['PATH']}"

def _validate_environment(self, project: str, modules: list):
"""Performs checks on current user environment."""
if not self.validate_env:
Expand Down Expand Up @@ -85,6 +93,14 @@ def _validate_environment(self, project: str, modules: list):
print(f"Error: module ({modname}) is not available.")
sys.exit(1)

system_paths = os.getenv("PATH").split(":")[: len(self._system_paths)]
if set(system_paths) != set(self._system_paths):
msg = f"""Error: System paths are not prioritized over user-defined paths

Check warning on line 98 in benchcab/benchcab.py

View check run for this annotation

Codecov / codecov/patch

benchcab/benchcab.py#L96-L98

Added lines #L96 - L98 were not covered by tests
Currently set as: {system_paths}
The required system paths are: {self._system_paths}
"""
raise EnvironmentError(msg)

Check warning on line 102 in benchcab/benchcab.py

View check run for this annotation

Codecov / codecov/patch

benchcab/benchcab.py#L102

Added line #L102 was not covered by tests

all_site_ids = set(
internal.MEORG_EXPERIMENTS["five-site-test"]
+ internal.MEORG_EXPERIMENTS["forty-two-site-test"]
Expand Down

0 comments on commit 7c8fa5a

Please sign in to comment.