fermi-lat / Fermitools-conda

Conda recipe files for the Fermi Sciencetools software analysis package: Fermitools
https://fermi.gsfc.nasa.gov/ssc/data/analysis/
BSD 3-Clause "New" or "Revised" License
34 stars 16 forks source link

ST_Version.py does work with case-insenstive MacOS filesystem #162

Open mstrzys opened 3 months ago

mstrzys commented 3 months ago

Bug Fermipy uses the ST_Version.py module at: mambaforge/base/pkgs/fermitools-2.2.0-py39h10ad0fb_0/lib/python3.9/site-packages/fermitools/ST_Version.py

When launched for the first time the scrips function: _write_release_version(relversion) is triggered, which is supposed to write the release version into a file at the same path with the name: st_version.py

Since the MacOS filesystem (APFS) is case-insensitive the ST_Version.py file is overwritten. This basically cases fermipy to raise an error when launched a second time. As linux filesystem are case-sensitive the bug is not triggered on linux OSs.

Moreover, the version number is read incorrectly e.g.:

In [1]: from fermipy.gtanalysis import GTAnalysis

In [2]: gta = GTAnalysis('analysis_conf.yaml', logging={'verbosity' : 3})
2024-04-04 18:36:42 INFO    GTAnalysis.__init__():
--------------------------------------------------------------------------------
fermipy version 4.2.16
ScienceTools version 4.2.16

Instead of the expected 2.2.0

Suggestion Simplest solution might be to use a different filename for the written output file. I can confirm that is solves the issue on MacOS with the error raised. Still the wrong version number remains.

donhorner commented 2 months ago

This seems like a Fermipy issue and should be reported on the Fermipy tracker. They are a separate organization from the Fermi Science Support Center which distributes the Fermitools.

mstrzys commented 2 months ago

I do use the science tools in combination with fermipy and the example code highlighting the issue is from fermipy. However, the origin of the issue seems to be the file https://github.com/fermi-lat/pyLikelihood/blob/master/python/ST_Version.py more specifically the function def write_release_version(rel_version):

In a case insensitive filesystem, this function will overwrite the program file itself, whereas it is only intended to write a file containing the version number.

Maybe I am mistaken but pylikelihood is part of the science tools not fermipy, isn't it? Or shall I move it to the issue tracker of the pylikelihood subroutines?