Project

General

Profile

Feature #10828

Python fhicl interface

Added by Herbert Greenlee almost 4 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Start date:
11/05/2015
Due date:
% Done:

100%

Estimated time:
Spent time:
Duration:

Description

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.

CMakeLists.txt (283 Bytes) CMakeLists.txt Kyle Knoepfel, 04/17/2017 08:48 AM
fclmodule.cxx (12.5 KB) fclmodule.cxx Kyle Knoepfel, 04/17/2017 08:48 AM

Related issues

Related to art - Feature #16342: Facility to convert fhicl::ParameterSets from art/ROOT file to Python dictionaryAccepted2017-04-26

History

#1 Updated by Marc Paterno over 3 years ago

  • Status changed from New to Feedback

We would like to meet to discuss more details about the requirements, such as what dependencies are acceptable for this new facility. We will follow up through email.

#2 Updated by Kyle Knoepfel over 2 years ago

The attached files have been provided by Herb for creating a Python dictionary from a C++ fhicl::ParameterSet object.

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 public.

Your code is a big step forward.

#3 Updated by Herbert Greenlee over 2 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.

https://cdcvs.fnal.gov/redmine/projects/ubutil/repository/raw/fclmodule/fclmodule.cxx?rev=feature%2Fgreenlee_pset_walk

#4 Updated by Kyle Knoepfel over 2 years ago

Excellent, Herb. Thank you. Yes, we will make the ParameterSet::walk method public.

#5 Updated by Kyle Knoepfel over 2 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 fhicl-cpp.

#6 Updated by Kyle Knoepfel over 2 years ago

  • Related to Feature #16342: Facility to convert fhicl::ParameterSets from art/ROOT file to Python dictionary added

#7 Updated by Kyle Knoepfel over 2 years ago

We have added an additional issue that refers to part 2 of this request. After we have finished migrating Herb's module to fhicl-cpp, which addresses parts 1 and 3, we will mark this issue as resolved.

#8 Updated by Kyle Knoepfel over 2 years ago

  • Target version set to 1209

#9 Updated by Kyle Knoepfel over 2 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.

#10 Updated by Kyle Knoepfel over 2 years ago

  • Status changed from Assigned to Resolved
  • % Done changed from 80 to 100

Implemented with commit fhicl-cpp:b4cc5ad. The extension module is called fhicl, and PYTHONPATH is appropriately set whenever the fhiclcpp UPS product is set up.

#11 Updated by Kyle Knoepfel about 2 years ago

  • Target version changed from 1209 to 2.07.01

#12 Updated by Kyle Knoepfel about 2 years ago

  • Status changed from Resolved to Closed

#13 Updated by Kyle Knoepfel about 2 years ago

  • Project changed from art to fhicl-cpp


Also available in: Atom PDF