Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tolerate more exceptions when can not import admix #1367

Merged
merged 2 commits into from
Apr 22, 2024
Merged

Conversation

dachengx
Copy link
Collaborator

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:

  • Update the docstring(s)
  • Update the documentation
  • Tests to check the (new) code is working as desired.
  • Does it solve one of the open issues on github?

Notes on testing

  • Until the automated tests pass, please mark the PR as a draft.
  • On the XENONnT fork we test with database access, on private forks there is no database access for security considerations.

All italic comments can be removed from this template.

@dachengx dachengx requested a review from yuema137 April 22, 2024 18:00
@dachengx dachengx marked this pull request as ready for review April 22, 2024 18:00
@coveralls
Copy link

coveralls commented Apr 22, 2024

Coverage Status

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

@dachengx dachengx merged commit 55c15eb into master Apr 22, 2024
8 checks passed
@dachengx dachengx deleted the admix_import branch April 22, 2024 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants