How do I get the history of a configuration object?

I often want to know who set a configuration parameter. If you just want to know its value then --show config is your friend (you’ll need backslashes \ if you still use [t]csh):

$ runFoo --show config=*apFlux* ...
config.calibrate.initialMeasurement.slots.apFlux='base_CircularApertureFlux_3_0'
config.calibrate.measurement.slots.apFlux='base_CircularApertureFlux_3_0'
config.measurement.slots.apFlux='base_CircularApertureFlux_2'

But if you want to know where it’s set I don’t know a better way than:

  1. Create a file “foo.py” containing

    import lsst.pex.config.history as pcHist
    import pdb
    pdb.set_trace()

  2. Say runFoo -C foo.py ...

  3. At the pdb prompt type

    (pdb) print pcHist.format(root.measurement.slots, ‘apFlux’)
    measurement.slots.apFlux
    base_CircularApertureFlux_3_0 /Users/rhl/LSST/processFile/bin/processFile.py:324 config = ProcessFileConfig()
    /Users/rhl/LSST/processFile/bin/processFile.py:82 doc=SingleFrameMeasurementTask.ConfigClass.doc)
    meas/base/baseMeasurement.py:191 doc="Mapping from algorithms to special aliases in Source."
    meas/base/baseMeasurement.py:159 doc=“the name of the algorithm used to set the source aperture flux slot”)
    base_CircularApertureFlux_2 /Users/rhl/LSST/processFile/bin/processFile.py:335 args = parser.parse_args(namespace=args)
    pex/config/config.py:533 execfile(filename, {}, local)
    ptfConfig.py:10 root.measurement.slots.apFlux = ‘base_CircularApertureFlux_2’

which (in this case) tells me that I set the offending value in ptfConfig.py line 10

My long-dormant bin/configDoc.py script has been pushed to branch u/ktlim/configDoc of pex_config. It may help a little in these situations. Caution: it probably repeats code that’s been incorporated into lsst.pex.config.format and may need other cleanups.