-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Python bindings for Frame #343
Conversation
92834ea
to
d748885
Compare
Preparatory work for things to come
- Wrappers around readers for ROOT and SIO backends - Wrappers for Frame - Iterator wrapper for more pythonic feel - Basic unittests covering the most important functionality NOTE: The current implementation requires that the <prefix>/include directory is placed on the ROOT_INCLUDE_PATH
- Wrappers around readers for ROOT and SIO backends - Wrappers for Frame - Iterator wrapper for more pythonic feel - Basic unittests covering the most important functionality NOTE: The current implementation requires that the <prefix>/include directory is placed on the ROOT_INCLUDE_PATH
ROOT_INCLUDE_PATH from the environment is necessary for picking up nlohmann json in the dictionary
0a2f73c
to
fbab0d5
Compare
Easier to work with in the python world, especially formatting
@wdconinc @gaede @andresailer @vvolkl @hegner any strong feelings on the python interface here? Anything obvious still missing? |
Does it make sense to include (for documentation purposes?) an example or test case with uproot, awkward, or numpy? |
In principle I think it would. I am a bit hesitant to put it into documentation at the moment, because I am afraid, there will be a few changes still to the format of the root files, before we have a v1.0. E.g., one of the things that I would still like to tackle before that is, #169. The one main issue I see with this, is that documenting this "officially" will tie podio very tightly into an expected file format for root. So I really want to be sure that things are stable, before we essentially make that a sort of interface as well. |
c324cf5
to
49c5cbd
Compare
* Use defaultdict instead of essentially hand-rolling one * Fix cmake configure dependencies again after #343 * Move SIO utilities to existing private utils header * Use sio_utils also for legacy writer
BEGINRELEASENOTES
Frame
based I/Opodio.root_io
andpodio.sio_io
, where aReader
and aWriter
is implemented for each.podio::Frame
. Requires that thepodio/Frame.h
header is available somewhere on theROOT_INCLUDE_PATH
.Frame::get
method for getting collectionsFrameDataT&&
Frame
contents more easilypodio
module. Make CMake generate the__init__.py
with the correct versionmodule
. Additionally also keep anEventStore
wrapper to not break existing code.CMakeLists.txt
that is responsible for building the core and all required I/O librariesENDRELEASENOTES
Frame
Frame
bindings)Details
These are a few implementation and technical details
python
Reader
implementation / interfaceDue to the essentially equivalent interfaces of the c++ readers, the readers are implemented via the
BaseReaderMixin
that essentially defines the complete interface. The backend specific readers simply have to instantiate the approriate c++ reader via PyROOT. The tests follow the same strategy via theReaderTestCaseMixin
base class.The python version of the readers offers a slightly more pythonic access pattern to some of the functionality by some thin wrapper code. The following helper classes facilitate this
FrameCategoryIterator
: the iterator class that grants access to allFrame
s of a given category, returned byReader.get
python
Frame
implementationI could not get roots dictionary generation to swallow the c++ implementation of the
podio::Frame
(segfaults, have to investigate and report upstream). Instead what is currently done is to JIT it viaROOT.gInterpreter.LoadFile('podio/Frame.h')
and then wrap the resulting c++ class into a slightly more accessible python interface. In order to make theFrame
constructible from thecppyy
wrappedstd::unique_ptr<FrameData>
that are returned by the readers, an additionalFrame
constructorFrame(FrameDataT&&)
is necessary, becausecppyy
seems to "swallow" the pointer here somewhere.CMakeLists.txt
refactoringTo enable python bindings more easily, all built shared libraries now have an accompanying dictionary, exposing the necessary c++ classes. To avoid even more code repetition I introduced a
PODIO_ADD_LIB_AND_DICT
function that handles most of the boilerplate.