Minimal initial commit of FreePACT code#2920
Conversation
| "matplotlib ~=3.0", | ||
| "pyirf ~=0.13.0" | ||
| "pyirf ~=0.13.0", | ||
| "tensorflow >=2.19.0" |
There was a problem hiding this comment.
I'd add a new extra here called impact or freepact that depnds on tensorflow and iminuit (you need both, right?). So that people can do pip install ctapipe[impact] and that gives them a working environment for impact.
In all you can then depend on ctapipe[impact].
|
It seems current tensorflow does not yet support python 3.14. You can remove the impact requirements from |
|
I.e. after adding the ctapipe/.github/workflows/ci.yml Lines 56 to 61 in 3e1717f |
|
@maxnoe I'm a bit lost what to do here, I can add the tensorflow dependencies for the older versions of python but the failing CI build of 3.14 seems to cancel all the others. |
|
@ParsonsRD you need to make the import of tensorflow actually optional in the code. I.e. you need to replace code like this: import tensorflow as tf
class FreePactReconstructor:
def __init__():
# do something with tfwith something like: try:
import tensorflow as tf:
except ModuleNotFoundError:
tf = None
class FreePactReconstructor:
def __init__(self):
if tf is None:
raise OptionalDependencyMissing("tensorflow")See e.g. how this is done here for matplotlib: ctapipe/src/ctapipe/visualization/mpl_camera.py Lines 102 to 106 in 3e1717f The important thing is that the modules need to be importable without the optional depedency being installed and the error is moved to runtime of the algorithm. |
|
Ugh sorry yes that should have been obvious. I blame on being very tired today :-). |
This is not actually an error but only a deprecation warning. Our test setup by default turns those into exceptions. You can keep this particular warning as a warning by adding a line like this to Lines 158 to 171 in 3574fb1 |
|
For the warnings that come from importing protobuf via tensorflow, I have these in another project: |
| "ignore:__array__ implementation doesn't accept a copy keyword:DeprecationWarning", | ||
| "ignore:Type .* uses PyType_Spec with a metaclass that has custom tp_new:DeprecationWarning", | ||
| "ignore:datetime.datetime.utcfromtimestamp\\(\\):DeprecationWarning", | ||
| "ignore:pyparsing.warnings.PyparsingDeprecationWarning", |
There was a problem hiding this comment.
you need one more colon here. It is <action>:<regex for message>:<category>:
https://docs.python.org/3/library/warnings.html#the-warnings-filter
There was a problem hiding this comment.
Thanks, I couldn't find an explanation of this anywhere and couldn't find a way of testing it without pushing commits
There was a problem hiding this comment.
These warnings are triggered in the oldest-deps build, where we test against the oldest still supported versions of our dependencies. You can test locally by installing the modules at the versions used in CI for this:
ctapipe/.github/workflows/ci.yml
Lines 155 to 157 in 3574fb1
There was a problem hiding this comment.
In this case, it's matplotlib=3.8 raising these warnings.
There was a problem hiding this comment.
If you don't mind, I'll push a commit to update the pyproject
|
|
||
| References | ||
| ---------- | ||
| .. [schwefer24] Schwefer, Parsons, & Hinton, Astroparticle Physics 163 (2024), 103008 |
There was a problem hiding this comment.
We use the bibtex extension for sphinx, please add the reference to the docs/references.bib file and use:
:cite:p:`<bibtex key>`
|
Please remove the |
done |
|
The tests are passing now. You do not need to worry about the pending check, that comes from branch protection rules requiring a certain job which is no longer here since the "impact" extra is now included in that step. Once we are happy to merge here, I'll update the branch protection rules to this new definition. |
|
OK great, thanks for the help in working through the CI issues. I will work through the sonarqube warnings and fix where appropriate. I would also like to have @gschwefer check through this and make sure it is fully compatible with the training files he has created. The other major missing work is to distribute a training code, which is currently a set of notebooks. This can come in a separate PR I think. Or we save it for a larger commit where we spin impact and freepact off into a plugin, which I think should probably be the ultimate goal (assuming Georg feels the same way). |
| # Open the first file to get the subarray description | ||
| # We assume all files have the same subarray | ||
| try: | ||
| with TableLoader( |
There was a problem hiding this comment.
You create a full tableloader here only to get the subarray? If all you need is the subarray, just to SubarrayDescription.from_hdf(...)
|
|
In general, you do not need to transform exceptions into |
|
|
After speaking with @kosack and @maxnoe I created an ImPACT and FreePACT plugin here: If this seems like a better approach, we could close this request. |
|
@ParsonsRD looks mostly good. Didn't have a chance yet to try it out though. Some observations:
|




This is a commit of a simple implementation of the FreePACT code. Updates to the ImPACT code are included from #2705