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 85 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
cc044de
Move table loading responsibility to individual fluxes
austinschneider Jun 4, 2024
fa04cb2
__repr__ and __str__ for InteractionSignature
austinschneider Jun 5, 2024
322d987
Whitespace
austinschneider Jun 5, 2024
8b5bbcd
load_module function
austinschneider Jun 5, 2024
ad97eef
Sketch loading logic for DarkNews
austinschneider Jun 5, 2024
226746d
Sketch DN decay logic and fix some obvious issues in the DN xs logic
austinschneider Jun 6, 2024
e88fee6
Return cross sections and decays
austinschneider Jun 6, 2024
c19596f
Introspect package version in __init__.py
austinschneider Jun 6, 2024
79f1b34
Start writing logic to generically load resources
austinschneider Jun 6, 2024
d5bbec4
Remove material model path method
austinschneider Aug 27, 2024
c9a09d1
Needs functools
austinschneider Aug 28, 2024
844e0cd
import struct. Properly return the module from sys.modules. Call exec…
austinschneider Aug 28, 2024
5940dae
docstrings, type hints, and variable names
austinschneider Aug 28, 2024
e33c191
Move cross sections. Fix string formatting
austinschneider Aug 29, 2024
1642d85
cross_Section -> processes
austinschneider Aug 29, 2024
34976e9
Refactor _get_model_path. Add support for top-level loaders
austinschneider Aug 29, 2024
16a7b61
Fix imports. loader -> logger
austinschneider Aug 29, 2024
b81b555
Fix imports
austinschneider Aug 29, 2024
c9dc192
Fix imports. loader -> logger. Instance checking instead of type chec…
austinschneider Aug 29, 2024
fa099a4
Avoid repeated use of np.append
austinschneider Aug 29, 2024
5fbf8e4
Override logging in our own copy of ModelContainer
austinschneider Aug 29, 2024
811780d
Check for DarkNews.ModelContainer.configure_logger in case it is remo…
austinschneider Aug 29, 2024
0b6f53d
Move detector files
austinschneider Aug 30, 2024
8a39ee4
Move detector files into subfolders
austinschneider Aug 30, 2024
6c7d346
Add load_* methods to siren.utilities
austinschneider Aug 30, 2024
0493255
Refactor model path search to just handle folders. Add special load_ …
austinschneider Aug 30, 2024
b59d9d6
Need to defined is_configured ahead of time
austinschneider Aug 30, 2024
8cb75a5
Pass nuclear targets to ModelContainer. Typo "s"
austinschneider Aug 30, 2024
a271cff
Inherit from a common Interaction class to enable a more concise cons…
austinschneider Aug 30, 2024
a2a3dbb
load_process returns maps from particle type to interactions
austinschneider Sep 1, 2024
5492b69
Loader for CSMS splines
austinschneider Sep 1, 2024
ea69003
Move resources
austinschneider Sep 2, 2024
7e5e5f1
un-capitalize folders
austinschneider Sep 2, 2024
55d8dc6
First pass at Injector wrapper
austinschneider Sep 12, 2024
e9443fb
Remvoe the holder
austinschneider Sep 12, 2024
e01cdca
particle type properties for the processes
austinschneider Sep 12, 2024
6e8a5b1
New access methods for process subclasses
austinschneider Sep 12, 2024
23c169a
Add more accessor method for processes
austinschneider Sep 12, 2024
c97cd10
Additional setters and getters
austinschneider Sep 12, 2024
b4e7f6f
Set primary type when setting interactions
austinschneider Sep 12, 2024
4885486
Additional setters and getters
austinschneider Sep 12, 2024
3b62df2
Produce a random seed by default. Getter for seed
austinschneider Sep 12, 2024
61dabf3
Rework Injector wrapper with @property
austinschneider Sep 12, 2024
324699c
Fix some obvious runtime issues
austinschneider Sep 12, 2024
9cecedb
Replace Injector with python wrapper
austinschneider Sep 12, 2024
aae1f78
Fiducial volume utilities
austinschneider Sep 12, 2024
d1902ef
Setter for number of events. Fix initialization checks
austinschneider Sep 12, 2024
6fd09b9
Remove requirement for target_types
austinschneider Sep 12, 2024
bf999b8
Add constructor with contents to pybindings
austinschneider Sep 12, 2024
990e474
Move examples
austinschneider Sep 14, 2024
1b34751
Utilities for string manipulation (mainly inserting tabs)
austinschneider Sep 14, 2024
bb2776d
A few pythonic changes to dataclasses pybindings. Moving ParticleType…
austinschneider Sep 14, 2024
d02b3b7
Add bindings for ParticleID
austinschneider Sep 14, 2024
41768b9
Clean up ParticleID __str__ and __repr__. Implement != operator
austinschneider Sep 14, 2024
ef147b6
Use lambda in favor of separate function pointer
austinschneider Sep 14, 2024
5d8339a
__str__ and __repr__ for InteractionRecord
austinschneider Sep 14, 2024
e7aeb09
to_str --> to_repr
austinschneider Sep 14, 2024
83e609b
__str__ and __repr__ for CrossSectionDistributionRecord and Secondary…
austinschneider Sep 14, 2024
19778c4
Specify namespace for args of forward declared output functions.
austinschneider Sep 14, 2024
764f63d
Add output functions as friends. More specific namespaces.
austinschneider Sep 14, 2024
4c298f1
__str__ and __repr__ for PrimaryDistributionRecord
austinschneider Sep 14, 2024
aee5431
__str__ and __repr__ for Particle
austinschneider Sep 14, 2024
a597bcb
Move detector files
austinschneider Sep 15, 2024
4cc6e93
Fix paths in visualization to match updated directory structure
austinschneider Sep 15, 2024
1a35e9d
Moving paper plots
austinschneider Sep 15, 2024
fb0bdab
primary_type should be an argument
austinschneider Sep 15, 2024
253954a
Add wrapper for Weighter
austinschneider Sep 15, 2024
ceae573
Re-write the DIS_ATLAS example with the new interface. Still need to …
austinschneider Sep 15, 2024
1622a4a
Utilities for exploring and getting docs
austinschneider Sep 15, 2024
0d41fb1
Rename and fix T2K_NEAR flux script to work with new directory struct…
austinschneider Sep 15, 2024
87a76bc
Enable access to resources through the module / tab-complete
austinschneider Sep 16, 2024
b2eda5e
Add file paths to detector docs
austinschneider Sep 16, 2024
254eb2d
Expose resource loader functions in the resources submodule
austinschneider Sep 16, 2024
bc0a31c
Don't require a version folder if there is a top level loader
austinschneider Sep 18, 2024
2477439
Update DIS_DUNE
austinschneider Sep 19, 2024
a5cb6df
Remove position dist from physical dists
austinschneider Sep 19, 2024
35c05c5
DIS_IceCube
austinschneider Sep 19, 2024
f48fdb3
Fix method name
austinschneider Sep 19, 2024
8bf11d7
Remove old function def. Load detector models correctly.
austinschneider Sep 19, 2024
5ebb901
Fix sampling
austinschneider Sep 19, 2024
1f0cd47
DipolePortal_CCM
austinschneider Sep 19, 2024
7a34462
Add ParticleIDs in InteractionRecord to pybindings
marichavest Oct 11, 2024
00164a1
Updates to cmake
austinschneider Oct 12, 2024
6e56833
FPIC for rk_static
austinschneider Oct 12, 2024
404562c
Update pyproject.toml
austinschneider Oct 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 71 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.3.2 FATAL_ERROR)
cmake_policy(VERSION 3.3.2)
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
cmake_policy(VERSION 3.20)

if(${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin")
set(MACOSX TRUE)
Expand All @@ -11,13 +11,14 @@ SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake ${CMAKE_CURRENT_LIST_DIR}/
message(STATUS "CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}")
message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")

set(CIBUILDWHEEL $ENV{CIBUILDWHEEL})
set(CIBUILDWHEEL "$ENV{CIBUILDWHEEL}")
message(STATUS "CIBUILDWHEEL: ${CIBUILDWHEEL}")
if(${CIBUILDWHEEL})
set(CI_INSTALL_PREFIX $ENV{CI_INSTALL_PREFIX})
if(CIBUILDWHEEL STREQUAL "1")
set(CI_INSTALL_PREFIX "$ENV{CI_INSTALL_PREFIX}")
message(STATUS "CI_INSTALL_PREFIX: ${CI_INSTALL_PREFIX}")
endif()


# parse pyproject.toml for the version
include(pyproject)

Expand All @@ -31,21 +32,31 @@ SET(CMAKE_CXX_STANDARD 14)
SET(CMAKE_C_STANDARD 99)

# set the build type and appropriate flags
option(CMAKE_BUILD_TYPE "" "Release")
set(_FLAGS "-O2 -Wall -fPIC")
set(_FLAGS_DEBUG "-g -O0 -Wall -fPIC")
set(_FLAGS_RELEASE "-O2 -Wall -fPIC -s")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()

# Create an interface library for SIREN compile options
add_library(siren_compile_options INTERFACE)

# Specify the compile options
target_compile_options(siren_compile_options INTERFACE
-O2
-Wall
-fPIC
$<$<CONFIG:Debug>:-g>
$<$<CONFIG:Debug>:-O0>
$<$<CONFIG:Release>:-O2>
$<$<CONFIG:Release>:-s>
)

# Conditionally add -stdlib=libc++ for Clang
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(_FLAGS "${_FLAGS} -stdlib=libc++")
set(_FLAGS_DEBUG "${_FLAGS_DEBUG} -stdlib=libc++")
set(_FLAGS_RELEASE "${_FLAGS_RELEASE} -stdlib=libc++")
target_compile_options(siren_compile_options INTERFACE -stdlib=libc++)
endif()
set(CMAKE_CXX_FLAGS ${_FLAGS})
set(CMAKE_CXX_FLAGS_DEBUG ${_FLAGS_DEBUG})
set(CMAKE_CXX_FLAGS_RELEASE ${_FLAGS_RELEASE})

# override install locations when building python extensions
if(DEFINED SKBUILD)
if(DEFINED SKBUILD_PLATLIB_DIR)
cmake_path(RELATIVE_PATH SKBUILD_HEADERS_DIR BASE_DIRECTORY ${SKBUILD_PLATLIB_DIR} OUTPUT_VARIABLE CMAKE_INSTALL_INCLUDEDIR)
cmake_path(RELATIVE_PATH SKBUILD_PLATLIB_DIR BASE_DIRECTORY ${SKBUILD_PLATLIB_DIR} OUTPUT_VARIABLE CMAKE_INSTALL_LIBDIR)
message(STATUS "Setting include dir to: ${CMAKE_INSTALL_INCLUDEDIR}")
Expand All @@ -63,12 +74,42 @@ include(pybind11)

# load project dependencies
include(rk)
if(TARGET rk_static)
target_link_libraries(rk_static INTERFACE siren_compile_options)
endif()
if(TARGET rk_shared)
target_link_libraries(rk_shared INTERFACE siren_compile_options)
endif()
include(cereal)
if(TARGET cereal)
target_link_libraries(cereal INTERFACE siren_compile_options)
endif()
include(delabella)
if(TARGET delabella_static)
target_link_libraries(delabella_static INTERFACE siren_compile_options)
endif()
if(TARGET delabella_shared)
target_link_libraries(delabella_shared INTERFACE siren_compile_options)
endif()
include(CFITSIO)
include(photospline)
if(TARGET photospline)
target_link_libraries(photospline INTERFACE siren_compile_options)
endif()
include(googletest)
if(TARGET gtest)
target_link_libraries(gtest INTERFACE siren_compile_options)
endif()
if(TARGET gtest_main)
target_link_libraries(gtest_main INTERFACE siren_compile_options)
endif()
if(TARGET gmock)
target_link_libraries(gmock INTERFACE siren_compile_options)
endif()
include(NamedType)
if(TARGET NamedType)
target_link_libraries(NamedType INTERFACE siren_compile_options)
endif()

# load macros for googletest
include(testing)
Expand All @@ -87,8 +128,9 @@ add_subdirectory(projects/injection)
# define the target library
add_library(SIREN SHARED)
set_property(TARGET SIREN PROPERTY POSITION_INDEPENDENT_CODE ON)
target_link_libraries(SIREN INTERFACE siren_compile_options)

if(${MACOSX})
if(DEFINED MACOSX AND MACOSX)
if(CMAKE_VERSION VERSION_LESS 3.13)
target_link_libraries(SIREN PUBLIC "$<$<PLATFORM_ID:Darwin>:LINKER:-undefined,dynamic_lookup>")
else()
Expand Down Expand Up @@ -127,12 +169,15 @@ target_link_libraries(SIREN
)
endif()

# Export siren_compile_options
install(TARGETS siren_compile_options EXPORT ${PROJECT_NAME}Config)

# define the install path normally or for python package
if(DEFINED SKBUILD)
if(DEFINED SKBUILD_PLATLIB_DIR)
set_target_properties(SIREN PROPERTIES
BUILD_WITH_INSTALL_RPATH FALSE
LINK_FLAGS "-Wl,-rpath,\\\$ORIGIN")
if(${CIBUILDWHEEL})
if(DEFINED CIBUILDWHEEL AND CIBUILDWHEEL)
message(STATUS "Setting SIREN install lib dir to: ${CI_INSTALL_PREFIX}/lib")
message(STATUS "Setting SIREN install include dir to: ${CI_INSTALL_PREFIX}/include")
install(TARGETS SIREN
Expand Down Expand Up @@ -183,7 +228,7 @@ else()
endif()

# optionally package runtime dependencies
if((DEFINED SKBUILD) AND (PACKAGE_SHARED_DEPS))
if((DEFINED SKBUILD_PLATLIB_DIR) AND (PACKAGE_SHARED_DEPS))
install(CODE "set(SIREN_LIB_FILE \"${PROJECT_BINARY_DIR}/${CMAKE_SHARED_MODULE_PREFIX}SIREN${CMAKE_SHARED_MODULE_SUFFIX}\")")
install(CODE "set(PYTHON_DEP_LIB_DESTINATION \"${SKBUILD_PLATLIB_DIR}/siren.libs/\")")
install(CODE [[
Expand All @@ -209,7 +254,7 @@ if((DEFINED SKBUILD) AND (PACKAGE_SHARED_DEPS))
endif()

# install the python extensions
if(DEFINED SKBUILD)
if(DEFINED SKBUILD_PLATLIB_DIR)
install(TARGETS utilities
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/siren)
install(TARGETS math
Expand Down Expand Up @@ -241,15 +286,18 @@ write_basic_package_version_file(
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
export(EXPORT ${PROJECT_NAME}Config FILE ${PROJECT_NAME}Config.cmake)
export(EXPORT ${PROJECT_NAME}Config FILE "${PROJECT_NAME}Config.cmake"
NAMESPACE ${PROJECT_NAME}::)

# Make importable from install location
set(_config_dir share/${PROJECT_NAME}/cmake)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION ${_config_dir}
)
install(EXPORT ${PROJECT_NAME}Config
DESTINATION ${_config_dir}
FILE "${PROJECT_NAME}Config.cmake"
NAMESPACE ${PROJECT_NAME}::
DESTINATION "${_config_dir}"
)

MESSAGE("")
Expand Down
5 changes: 4 additions & 1 deletion projects/dataclasses/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ target_include_directories(SIREN_dataclasses PUBLIC
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/SIREN/dataclasses/>
)

target_link_libraries(SIREN_dataclasses PUBLIC
target_link_libraries(SIREN_dataclasses
INTERFACE
siren_compile_options
PUBLIC
photospline
SIREN_serialization
SIREN_utilities
Expand Down
Loading