Question: Property handling of external config file
There were a couple of times I found myself wishing I could set a Property<std::string>
both directly and from the contents of a file. As an example, usually we setup pythia from a .cmd
file somewhere on disk (https://github.com/HEP-FCC/k4Gen/blob/main/k4Gen/src/components/PythiaInterface.h#L54)
At times, it would be useful to be able to directly set the contents of the pythiacard, like:
PythiaInterface().pythiacard = """
! 1) Settings used in the main program.
Main:numberOfEvents = 100 ! number of events to generate
Main:timesAllowErrors = 3 ! how many aborts before run stops
! 2) Settings related to output in init(), next() and stat() functions.
Init:showChangedSettings = on ! list changed settings
Init:showChangedParticleData = off ! list changed particle data
...
"""
An additional benefit of this way would be that the complete configuration is saved thanks to the joboptionssvc, while the path to the cmd file may be specific to a certain machine, and so the contents are harder to recreate.
A simple workaround to be able to work with both file contents and file paths is of course to just use open
in the options.py, maybe conditional on wether there the string ends in ".cmd"
.
A second options would be to use two separate, exclusive properties for path and content with some logic to e.g. raise an error when a user tries to set both.
I was wondering if there are solutions for this issues out there already? And if not, if you see potential for Gaudi implementing something like a ConfigFileProperty
that handles these issues in a smart way?
Cheers!