XENONnT / straxen

Streaming analysis for XENON
BSD 3-Clause "New" or "Revised" License
20 stars 32 forks source link

Tolerate more exceptions when can not import admix #1367

Closed dachengx closed 5 months ago

dachengx commented 5 months ago

Before you submit this PR: make sure to put all operations-related information in a wiki-note, a PR should be about code and is publicly accessible

What does the code in this PR do / what does it improve?

Previously, when importing without utilix configuration, we will get an error:

>>> import straxen
2024-04-22 13:55:52,425 - utilix - WARNING - Could not load a configuration file. You can create one at /home/xudc/.xenon_config, or set a custom path using

export XENON_CONFIG=path/to/your/config

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/xudc/straxen/straxen/__init__.py", line 26, in <module>
    from . import storage
  File "/home/xudc/straxen/straxen/storage/__init__.py", line 4, in <module>
    from . import rucio_remote
  File "/home/xudc/straxen/straxen/storage/rucio_remote.py", line 11, in <module>
    import admix
  File "/opt/miniconda3/envs/XENONnT_2024.03.1/lib/python3.9/site-packages/admix/__init__.py", line 20, in <module>  
    logger = get_logger()
  File "/opt/miniconda3/envs/XENONnT_2024.03.1/lib/python3.9/site-packages/admix/__init__.py", line 13, in get_logger
    ch.setLevel(uconfig.logging_level)
AttributeError: 'NoneType' object has no attribute 'logging_level'

This PR includes AttributeError also into the exception to capture this error.

Can you briefly describe how it works?

Can you give a minimal working example (or illustrate with a figure)?

Please include the following if applicable:

Notes on testing

All italic comments can be removed from this template.

coveralls commented 5 months ago

Coverage Status

coverage: 91.4% (+0.02%) from 91.379% when pulling 7556c156b513efdb6643b50e0fc6953f9ba95bfa on admix_import into 37e043a127c5746d100784cf15ca9a172cd65da9 on master.