From 2d82a478dbae74ce20239d8cc145c6d7d9726898 Mon Sep 17 00:00:00 2001 From: Joran Angevaare Date: Sun, 15 Aug 2021 17:47:22 +0200 Subject: [PATCH] Allow database to not be initialized --- straxen/contexts.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/straxen/contexts.py b/straxen/contexts.py index 2b0ef2e6c..c027733e3 100644 --- a/straxen/contexts.py +++ b/straxen/contexts.py @@ -2,6 +2,7 @@ import strax import straxen from copy import deepcopy +from warnings import warn common_opts = dict( register_all=[ @@ -219,6 +220,7 @@ def xenonnt_led(**kwargs): st.register([straxen.DAQReader, straxen.LEDCalibration]) return st + def xenonnt_simulation( output_folder='./strax_data', cmt_run_id_sim=None, @@ -234,7 +236,7 @@ def xenonnt_simulation( drift_time_gate='electron_drift_time_gate', drift_velocity_liquid='electron_drift_velocity', electron_lifetime_liquid='elife_conf'), - **kwargs): + **kwargs): """ The most generic context that allows for setting full divergent settings for simulation purposes @@ -286,7 +288,10 @@ def xenonnt_simulation( **straxen.contexts.xnt_common_config,), **straxen.contexts.xnt_common_opts, **kwargs) st.register(wfsim.RawRecordsFromFaxNT) - st.apply_cmt_version(f'global_{cmt_version}') + if straxen.utilix_is_configured(): + st.apply_cmt_version(f'global_{cmt_version}') + else: + warn(f'Bad context as we cannot set CMT since we have no database access') if _forbid_creation_of is not None: st.context_config['forbid_creation_of'] += strax.to_str_tuple(_forbid_creation_of)