Python fhicl interface
Python interface should be able to:
1. Parse a fcl file or text string representing a fhicl parameter set into something like a python dictionary.
2. Read fhicl parameter sets from an artroot file sqlite database and produce a python dictionary.
3. Encode a python dictionary representing a fhicl parameter set into parseable fcl text.
#2 Updated by Kyle Knoepfel almost 4 years ago
The attached files have been provided by Herb for creating a Python dictionary from a C++
Herb, the code contains what we would hope to see--a final dictionary that is independent of the
fhiclcpp details. We would be in a better position to take on this facility if you could convert the code to using the
fhicl::detail::ParameterSetWalker interface, which admittedly is not well-known. You would write a derived class (e.g.
PSetToPythonDict), which overrides functions for processing FHiCL atoms, sequences, and tables. After the derived class is defined, you could do (e.g.):
PSetToPythonDict converter; pset.walk(converter); PyObject* pset_dict = converter.result();
without having to do any explicit tree-walking yourself.
Unfortunately, we do not have the effort available to make this conversion ourselves. However, by making this conversion, we can then adopt the code and guarantee that any future changes made in the
fhicl::ParameterSet implementation will be appropriately reflected in the Python dictionary.
Please look at the documentation in
fhiclcpp/detail/ParameterSetWalker.h and/or contact us with questions. Note that the
fhicl::ParameterSet::walk method is currently
private (and spelled with a trailing underscore). However, there is no reason it cannot be made
Your code is a big step forward.
#3 Updated by Herbert Greenlee almost 4 years ago
As requested, I made another version of fclmodule.cxx which is implemented using ParameterSetWalker. This implementation has the problem that ParameterSet method "walk_" is private (had to use "#define private public").
The updated version is saved in redmine git repository ubutil on branch feature/greenlee_pset_walk.
#5 Updated by Kyle Knoepfel almost 4 years ago
- Status changed from Feedback to Accepted
We intend to move item 2 to its own issue since it involves moving some
art infrastructure to
canvas, as well as new development. Items 1 and 3 are provided by the code that Herb provided. We will integrate Herb's Python extension module to
fhicl-cpp, which also involves moving the Python dependency from
canvas down to
#9 Updated by Kyle Knoepfel over 3 years ago
- Status changed from Accepted to Assigned
- Assignee set to Kyle Knoepfel
- % Done changed from 0 to 80
- SSI Package - added
Largely implemented with commit fhicl-cpp:2ce61ba.
Some discussion is required regarding how the module library should be packaged/"set up" for use.