I am not entirely sure if this is an error on my side, but when working with a release version of NuRadioMC, I always get a warning due to Git not finding a repository to read a commit hash from.
$ python3
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import NuRadioReco.utilities.version
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
>>>
The relevant call stack in my specific case is
from NuRadioReco.modules.channelBandPassFilter import channelBandPassFilter
↓
import NuRadioReco.framework.event
↓
from NuRadioReco.utilities import io_utilities, version
As per #924, the herein-imported version.py tries to read the git hash upon loading.
But if I'm not mistaken, this will never work with a release version – the pip-installed package does not come with a .git directory.
Upon researching this, I also found that some code tries to warn the user if no hash is specified but will never actually do so, as all exceptions are caught before in version.py:
|
try: |
|
commit_hash = version.get_NuRadioMC_commit_hash() |
|
self.set_parameter(evp.hash_NuRadioMC, commit_hash) |
|
except: |
|
logger.warning("Event is serialized without commit hash!") |
|
self.set_parameter(evp.hash_NuRadioMC, None) |
Here are my suggestions of what we could do:
- check if we are in a release version before trying to access the hash (speedup!)
- bake in the hash somewhere in the release pipeline
- silence the error by redirecting Git's stderr
And we should do the following:
- make the hash parsing more reliable by using the porcelain
git rev-parse HEAD command instead of git status
- fix the defunct warning mentioned above, either by removing or rewriting it
I'll gladly create a PR, but we first need to decide on how we intend to handle the hashes.
I am not entirely sure if this is an error on my side, but when working with a release version of NuRadioMC, I always get a warning due to Git not finding a repository to read a commit hash from.
The relevant call stack in my specific case is
As per #924, the herein-imported
version.pytries to read the git hash upon loading.But if I'm not mistaken, this will never work with a release version – the pip-installed package does not come with a
.gitdirectory.Upon researching this, I also found that some code tries to warn the user if no hash is specified but will never actually do so, as all exceptions are caught before in
version.py:NuRadioMC/NuRadioReco/framework/event.py
Lines 691 to 696 in 5d309bf
Here are my suggestions of what we could do:
And we should do the following:
git rev-parse HEADcommand instead ofgit statusI'll gladly create a PR, but we first need to decide on how we intend to handle the hashes.