Skip to content

Commit

Permalink
Merge branch 'main' into 103-we-should-be-using-the-logging-module
Browse files Browse the repository at this point in the history
  • Loading branch information
abhaasgoyal authored Feb 14, 2024
2 parents 9b49c13 + b560dd8 commit 7a3b741
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
14 changes: 14 additions & 0 deletions benchcab/benchcab.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ def __init__(

# Get the logger object
self.logger = get_logger()
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."""
Expand Down Expand Up @@ -99,6 +105,14 @@ def _validate_environment(self, project: str, modules: list):
self.logger.error(f"Module ({modname}) is not available.")

Check warning on line 105 in benchcab/benchcab.py

View check run for this annotation

Codecov / codecov/patch

benchcab/benchcab.py#L105

Added line #L105 was not covered by tests
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

Check warning on line 110 in benchcab/benchcab.py

View check run for this annotation

Codecov / codecov/patch

benchcab/benchcab.py#L108-L110

Added lines #L108 - L110 were not covered by tests
Currently set as: {system_paths}
The required system paths are: {internal.SYSTEM_PATHS}
"""
raise EnvironmentError(msg)

Check warning on line 114 in benchcab/benchcab.py

View check run for this annotation

Codecov / codecov/patch

benchcab/benchcab.py#L114

Added line #L114 was not covered by tests

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 7a3b741

Please sign in to comment.