Skip to content

Commit

Permalink
fix ESMFMKFILE for benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenworsley committed Apr 25, 2024
1 parent 377a533 commit 7696d49
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions benchmarks/asv_delegated_conda.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def _prep_env(self) -> None:
message = f"Running delegated environment management for: {self.name}"
log.info(message)
env_path = Path(self._path)
environ["ESMFMKFILE"] = str(env_path / "lib" / "esmf.mk")

def copy_asv_files(src_parent: Path, dst_parent: Path) -> None:
"""For copying between self._path and a temporary cache."""
Expand Down
6 changes: 6 additions & 0 deletions benchmarks/benchmarks/generate_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from pathlib import Path
import re
from subprocess import CalledProcessError, check_output, run
import sys
from textwrap import dedent
from warnings import warn

Expand Down Expand Up @@ -55,6 +56,8 @@
# False forces a benchmark run to re-make all the data files.
REUSE_DATA = True

ESMFMKFILE = "ESMFMKFILE"


def run_function_elsewhere(func_to_run, *args, **kwargs):
"""
Expand Down Expand Up @@ -90,9 +93,12 @@ def run_function_elsewhere(func_to_run, *args, **kwargs):
f"{func_to_run.__name__}(" + ",".join(func_call_term_strings) + ")"
)
python_string = "\n".join([func_string, func_call_string])
old_esmf_mk_file = environ.get(ESMFMKFILE, None)
environ[ESMFMKFILE] = str(Path(sys.executable).parents[1] / "lib" / "esmf.mk")
result = run(
[DATA_GEN_PYTHON, "-c", python_string], capture_output=True, check=True
)
environ[ESMFMKFILE] = old_esmf_mk_file
return result.stdout


Expand Down
2 changes: 0 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,6 @@ def benchmarks(
Path(".nox").rglob(f"tests*/bin/python{PY_VER}")
).resolve()
session.env[data_gen_var] = data_gen_python
esmf_mk_file = data_gen_python.parents[1] / "lib" / "esmf.mk"
session.env[ESMFMKFILE] = esmf_mk_file

print("Running ASV...")
session.cd("benchmarks")
Expand Down

0 comments on commit 7696d49

Please sign in to comment.