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

New Python interface #71

Draft
wants to merge 94 commits into
base: main
Choose a base branch
from
Draft

New Python interface #71

wants to merge 94 commits into from

Conversation

austinschneider
Copy link
Collaborator

This PR moves logic for loading fluxes, cross sections, and detector models into the resources directory. With the idea that the logic for manipulating files, importing other packages, building tables, etc. should be relegated to python code that lives outside of siren itself. This changes the way we treat the tabulated fluxes a little bit since we don't expect the code within the resources directory to generate a file for us, but rather we expect it to return a siren.distributions.PrimaryEnergyDistribution object (that in this case happens to be a tabulated flux). This also involves essentially decoupling DarkNews from siren, since all the DarkNews-specific logic would then live within a file in the resources directory. Finally for the detector models, this means that a detector model can now take parameters since we're always calling a function to load the detector model rather than just pointing to a file.

@austinschneider austinschneider added the enhancement New feature or request label Jun 5, 2024
@austinschneider austinschneider requested a review from nickkamp1 June 5, 2024 15:23
@austinschneider austinschneider self-assigned this Jun 5, 2024
@austinschneider
Copy link
Collaborator Author

It's been a while since I have touched on the DarkNews loading logic in detail, and it still remains untested end-to-end, but I think the logic is mostly there. It might be worth looking through the contents of resources/Processes/DarkNewsTables now @nickkamp1 just to see that everything makes sense there.

austinschneider and others added 27 commits September 15, 2024 16:34
* Injector serialization via pickle working

* Remove cruft

* Undo addition to DecaySignature

* Remove printouts in DetectorModel serialization

* Remove unnecessary cereal macros

* Revert changes to link ordering

* Remove comments

* Don't need global FPIC now that it is handled with an INTERFACE target

* Attempt to perform explicit template instantiation for interpolator templates

* CMake fixes

* Improve logic for finding cfitsio. Make an IMPORT target for cfitsio

* Use lists for find_path

* Search all paths in secondary searches

* Remove printouts

* Remove redundant paths for find_library

* Link photospline with CFITSIO. Use generator expressions for -s and -stdlib=libc++

* Set policies for macos

* Use photospline from icecube git repo. Update photospline and cereal

* Remove printouts

* Upgrade pybind11

* Use shared_ptr for compatibility of classes without a default constructor

* Pickle weighter

* Move external headers

* pybind11 used in pickle serialization

* Pickle serialization for dataclasses

* Revert "Upgrade pybind11"

This reverts commit add5a6a.
…DarkNews tables and objects. still some issues in the pickling
@nickkamp1
Copy link
Collaborator

nickkamp1 commented Oct 24, 2024

@austinschneider I made some changes to get example 1 working, but example 2 is a bit trickier. I now am able to save and load the cross section and decay tables, but I have not been able to pickle the (py)DarkNewsCrossSection and (py)DarkNewsDecay objects themselves. I am a bit unclear on what changed in our serialization scheme w.r.t. the trampoline classes that would have produced errors like:

File "/n/holylfs05/LABS/arguelles_delgado_lab/Everyone/nkamp/spack/var/spack/environments/lienv/.spack-env/view/lib/python3.10/site-packages/siren/_util.py", line 1003, in SaveDarkNewsProcesses
pickle.dump(dec,f)
_pickle.PicklingError: Can't pickle <class 'DarkNewsDecay.PyDarkNewsDecay'>: import of module 'DarkNewsDecay' failed

Do you have any ideas as to what changed? I still see the get_representation functions in the trampoline classes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants