Skip to content

Commit

Permalink
error out if path not found
Browse files Browse the repository at this point in the history
  • Loading branch information
scarlehoff committed Dec 13, 2023
1 parent 4888a93 commit 3b7d9a1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
5 changes: 5 additions & 0 deletions validphys2/src/validphys/datafiles/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import pathlib

path_vpdata = pathlib.Path(__file__).parent
path_commondata = pathlib.Path(__file__).with_name('commondata')
path_theorydb = pathlib.Path(__file__).with_name('theory.db')
15 changes: 10 additions & 5 deletions validphys2/src/validphys/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
peek_commondata_metadata,
)
from validphys.utils import tempfile_cleaner
from validphys.datafiles import path_vpdata

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -148,12 +149,16 @@ def _get_nnpdf_profile(profile_path=None):
profile_dict.setdefault("validphys_cache_path", share_folder / "vp-cache")
profile_dict.setdefault("theories_path", share_folder / "theories")

datafiles = pathlib.Path(__file__).parent / "datafiles"
# And set the data_path to validphys/datafiles unless the profile says otherwise
profile_dict.setdefault("data_path", path_vpdata)

if datafiles.exists():
# If datafiles does not exist, fallback to legacy
profile_dict.setdefault("data_path", datafiles)
return profile_dict
# Before returning, do a quick check:
if not path_vpdata.exists():
raise FileNotFoundError(
f"The data path {path_vpdata} could not be found. This is either a bug or a broken installation. Please reinstall nnpdf and retry or report the problem"
)

return profile_dict

# Legacy branch, if the above was not able to fill in `nnprofile.yaml`,
# then let's try to find it in the old location
Expand Down

0 comments on commit 3b7d9a1

Please sign in to comment.