diff --git a/src/cal_tools/calcat_interface2.py b/src/cal_tools/calcat_interface2.py index 4a0e3ea124528bc4770efc63bc9f0ecdff618152..9e819c5bb9adc39ecf944863932f6457c6304944 100644 --- a/src/cal_tools/calcat_interface2.py +++ b/src/cal_tools/calcat_interface2.py @@ -215,10 +215,16 @@ def setup_client( _default_caldb_root = None def set_default_caldb_root(p: Path): + """Override the default root directory for constants in CalCat""" global _default_caldb_root _default_caldb_root = p -def _get_default_caldb_root(): +def get_default_caldb_root(): + """Get the root directory for constants in CalCat. + + The default location is different on Maxwell & ONC; this checks which one + exists. Calling ``set_default_caldb_root()`` overrides this. + """ global _default_caldb_root if _default_caldb_root is None: onc_path = Path("/common/cal/caldb_store") @@ -265,7 +271,7 @@ class SingleConstant: if caldb_root is not None: caldb_root = Path(caldb_root) else: - caldb_root = _get_default_caldb_root() + caldb_root = get_default_caldb_root() return caldb_root / self.path def dataset_obj(self, caldb_root=None) -> h5py.Dataset: diff --git a/src/cal_tools/constants.py b/src/cal_tools/constants.py index cd4abb00f819ef75f2da7b3315adaf4f863bd3c6..21b047c003b5c8c0541479e2b75aeefc9c3f85e3 100644 --- a/src/cal_tools/constants.py +++ b/src/cal_tools/constants.py @@ -11,7 +11,7 @@ import numpy as np import h5py from calibration_client import CalibrationClient -from cal_tools.calcat_interface2 import _get_default_caldb_root, get_client +from cal_tools.calcat_interface2 import get_default_caldb_root, get_client from cal_tools.tools import run_prop_seq_from_path from cal_tools.restful_config import calibration_client @@ -187,7 +187,7 @@ def inject_ccv(const_src, ccv_root, report_to=None): 'file_path': str(report_path) } - const_dest = _get_default_caldb_root() / const_rel_path / const_filename + const_dest = get_default_caldb_root() / const_rel_path / const_filename const_dest.parent.mkdir(parents=True, exist_ok=True) copyfile(const_src, const_dest)