Skip to content

simple inheritance in yaml files through load_budget

Lee McCuller requested to merge lee-mcculler/pygwinc:inheritance into master

The inheritance should be used to make IFO variants that load either the canonical IFO's or other variants. They have a top-level attribute in their yaml "inherit: <load_name>" where load name is either a path or a canonical budget. Upon seeing the inherit key, it is deleted, and its target is loaded using load_budget recursively. Then, the ifo of the targeted budget is Struct.update'd with the remainder of the source yaml, and subsituted into the target budget and returned. See the diff on gwinc/__init__.py for that logic.

To do this, the Struct.update() call had to be improved a bit. It now is more fully recursive through sub-lists and it is more pedantic about checking that source and target types are similar containers. See diffs on gwinc/struct.py for that. A couple other things were improved in struct as well. Struct.update now handles "None" values in a special way, in that they are always overwritten if in the target, but never assign in the source. This is necessary so that subelements of lists like Suspension.Stage can be recursively updated in a sane manner.

There are a couple of tests now in the test/ folder, so check those out to see how Suspension.Stage is handled.

Uses and requires MR !126 (merged) for the tests to run

Merge request reports