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 6706a73
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
15 changes: 15 additions & 0 deletions benchcab/benchcab.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ def __init__(
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(internal.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 +92,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(internal.SYSTEM_PATHS)]
if set(system_paths) != set(internal.SYSTEM_PATHS):
msg = f"""Error: System paths are not prioritized over user-defined paths
Currently set as: {system_paths}
The required system paths are: {internal.SYSTEM_PATHS}
"""
raise EnvironmentError(msg)

all_site_ids = set(
internal.MEORG_EXPERIMENTS["five-site-test"]
+ internal.MEORG_EXPERIMENTS["forty-two-site-test"]
Expand Down
3 changes: 3 additions & 0 deletions benchcab/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
# Path to the user's current working directory
CWD = Path.cwd()

# Default system paths in Unix
SYSTEM_PATHS = ["/bin", "/usr/bin", "/usr/local/bin"]

# Path to the user's home directory
HOME_DIR = Path(os.environ["HOME"])

Expand Down

0 comments on commit 6706a73

Please sign in to comment.