Skip to content

Commit

Permalink
Expand envvars in runtime path
Browse files Browse the repository at this point in the history
  • Loading branch information
caizixian committed Nov 20, 2023
1 parent e1c10ce commit 19d9f2c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,23 @@ jobs:
- name: Test with mypy
run: |
mypy --check-untyped-defs src/running
black:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools build[virtualenv]
pip install .[zulip,tests]
pip install black
- name: Test with black
run: |
black --check src tests
2 changes: 1 addition & 1 deletion src/running/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __init__(
runtime_specific_modifiers_strategy: Optional[
Callable[[Runtime], Sequence[Modifier]]
] = None,
**kwargs
**kwargs,
):
self.name = name
self.suite_name = suite_name
Expand Down
4 changes: 2 additions & 2 deletions src/running/command/log_preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def ratio_work_perf_event(event_name: str):

def inner(stats: Dict[str, float]):
new_stats = deepcopy(stats)
for (k, v) in stats.items():
for k, v in stats.items():
if compiled.match(k):
new_column = k.replace(".total", ".ratio")
new_stats[new_column] = v / stats[aggregated_column]
Expand Down Expand Up @@ -107,7 +107,7 @@ def calc_work_ipc(stats: Dict[str, float]):
pattern = "work\\.\\w+\\.PERF_COUNT_HW_INSTRUCTIONS\\.total"
compiled = re.compile(pattern)
new_stats = deepcopy(stats)
for (k, v) in stats.items():
for k, v in stats.items():
if compiled.match(k):
cycles = k.replace("PERF_COUNT_HW_INSTRUCTIONS", "PERF_COUNT_HW_CPU_CYCLES")
ipc = k.replace(
Expand Down
9 changes: 5 additions & 4 deletions src/running/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pathlib import Path
import logging
from running.util import register
import os.path


class Runtime(object):
Expand Down Expand Up @@ -90,7 +91,7 @@ def __init__(self, **kwargs):
except ValueError:
raise TypeError("The release of an OpenJDK has to be int-like")
self.home: Path
self.home = Path(kwargs["home"])
self.home = Path(os.path.expandvars(kwargs["home"]))
if not self.home.exists():
logging.warning("OpenJDK home {} doesn't exist".format(self.home))
self.executable = self.home / "bin" / "java"
Expand All @@ -110,7 +111,7 @@ class JikesRVM(JVM):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.home: Path
self.home = Path(kwargs["home"])
self.home = Path(os.path.expandvars(kwargs["home"]))
if not self.home.exists():
logging.warning("JikesRVM home {} doesn't exist".format(self.home))
self.executable = self.home / "rvm"
Expand All @@ -129,7 +130,7 @@ class JavaScriptRuntime(Runtime):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.executable: Path
self.executable = Path(kwargs["executable"])
self.executable = Path(os.path.expandvars(kwargs["executable"]))
if not self.executable.exists():
logging.warning(
"JavaScriptRuntime executable {} doesn't exist".format(self.executable)
Expand Down Expand Up @@ -204,7 +205,7 @@ class Julia(Runtime):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.executable: Path
self.executable = Path(kwargs["executable"])
self.executable = Path(os.path.expandvars(kwargs["executable"]))
if not self.executable.exists():
logging.warning("Julia executable {} doesn't exist".format(self.executable))
self.executable = self.executable.absolute()
Expand Down

0 comments on commit 19d9f2c

Please sign in to comment.