Skip to content
Snippets Groups Projects

Public API to set caldb_root (option 2)

Merged Thomas Kluyver requested to merge feat/caldb-root-api-2 into master
2 files
+ 10
4
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -215,10 +215,16 @@ def setup_client(
@@ -215,10 +215,16 @@ def setup_client(
_default_caldb_root = None
_default_caldb_root = None
def set_default_caldb_root(p: Path):
def set_default_caldb_root(p: Path):
 
"""Override the default root directory for constants in CalCat"""
global _default_caldb_root
global _default_caldb_root
_default_caldb_root = p
_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
global _default_caldb_root
if _default_caldb_root is None:
if _default_caldb_root is None:
onc_path = Path("/common/cal/caldb_store")
onc_path = Path("/common/cal/caldb_store")
@@ -265,7 +271,7 @@ class SingleConstant:
@@ -265,7 +271,7 @@ class SingleConstant:
if caldb_root is not None:
if caldb_root is not None:
caldb_root = Path(caldb_root)
caldb_root = Path(caldb_root)
else:
else:
caldb_root = _get_default_caldb_root()
caldb_root = get_default_caldb_root()
return caldb_root / self.path
return caldb_root / self.path
def dataset_obj(self, caldb_root=None) -> h5py.Dataset:
def dataset_obj(self, caldb_root=None) -> h5py.Dataset:
Loading