Skip to content

Commit

Permalink
Update benchmark base (#2788)
Browse files Browse the repository at this point in the history
* update get_relative_path with Pathlib

Signed-off-by: Asish Kumar <[email protected]>

* pass tardis-refdata via env variables

Signed-off-by: Asish Kumar <[email protected]>

* change os

Signed-off-by: Asish Kumar <[email protected]>

* change import os.environ

Signed-off-by: Asish Kumar <[email protected]>

---------

Signed-off-by: Asish Kumar <[email protected]>
  • Loading branch information
officialasishkumar authored Aug 16, 2024
1 parent ef8a5ac commit fad3987
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
22 changes: 17 additions & 5 deletions asv.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,30 @@
"project": "tardis",
"project_url": "https://tardis-sn.github.io/tardis",
"repo": ".",
"install_command": ["in-dir={env_dir} python -mpip install {wheel_file}"],
"uninstall_command": ["return-code=any python -mpip uninstall -y {project}"],
"install_command": [
"in-dir={env_dir} python -mpip install {wheel_file}"
],
"uninstall_command": [
"return-code=any python -mpip uninstall -y {project}"
],
"build_command": [
"python setup.py build",
"PIP_NO_BUILD_ISOLATION=false python -mpip wheel --no-deps --no-index -w {build_cache_dir} {build_dir}"
],
"branches": ["origin/master", "HEAD"],
"branches": [
"origin/master",
"HEAD"
],
"environment_type": "mamba",
"show_commit_url": "https://github.com/tardis-sn/tardis/commit/",
"conda_environment_file": "tardis_env3.yml",
"benchmark_dir": "benchmarks",
"env_dir": ".asv/env",
"results_dir": ".asv/results",
"html_dir": ".asv/html"
}
"html_dir": ".asv/html",
"matrix": {
"env": {
"TARDIS_REF_PATH": "tardis-refdata/atom_data"
}
}
}
18 changes: 9 additions & 9 deletions benchmarks/benchmark_base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import functools
from os import environ as env
from copy import deepcopy
from os.path import dirname, join, realpath
from pathlib import Path

import numpy as np
Expand All @@ -26,14 +26,13 @@ class BenchmarkBase:
timeout = 600

@staticmethod
def get_relative_path(partial_path: str):
path = dirname(realpath(__file__))
targets = Path(partial_path).parts
def get_relative_path(partial_path: str) -> str:
path = Path(__file__).resolve().parent

for target in targets:
path = join(path, target)
for target in Path(partial_path).parts:
path = path / target

return path
return str(path)

def get_absolute_path(self, partial_path):
partial_path = "../" + partial_path
Expand Down Expand Up @@ -61,7 +60,8 @@ def config_rpacket_tracking(self):
@functools.cached_property
def tardis_ref_path(self):
ref_data_path = Path(
Path(__file__).parent.parent, "tardis-refdata"
Path(__file__).parent.parent,
env.get("TARDIS_REF_PATH")
).resolve()
return ref_data_path

Expand All @@ -78,7 +78,7 @@ def atomic_dataset(self) -> AtomData:
@functools.cached_property
def atomic_data_fname(self):
atomic_data_fname = (
f"{self.tardis_ref_path}/atom_data/kurucz_cd23_chianti_H_He.h5"
f"{self.tardis_ref_path}/kurucz_cd23_chianti_H_He.h5"
)

if not Path(atomic_data_fname).exists():
Expand Down

0 comments on commit fad3987

Please sign in to comment.