Skip to content

Build yaml file from python

When configuring blocks using python, users currently interact directly with underlying objects and configure blocks directly. This direct access to the underlying code results changes to the underlying code to potentially break user code, making development difficult. In order to separate the user-facing code and the code that configures blocks, the YAML configuration file can be used as an intermediary step.

The function ConfigText.addBlock(name, **kwargs) was added to the TextConfiguration class and allows a block and its options to be added to the internal representation of the YAML file. The options for the last added block can also be set by calling setOptions(**kwargs). Since the configuration information is only stored until the blocks are ready to be configured, it is possible to transform the internal YAML representation beforehand to account for changes with the underlying code without the user being affected. This model is based on a web API: users use SDK in their code to pass JSON data to a web API, the API transforms the data as needed and passes the data to the back-end and does something.

To completely decouple the user code from the underlying code, some additional changes will be required.

A unit test was added to the integration tests that compares a config sequence created with data/for_compare.yaml and the config sequence created using the python commands.

Other change:

  • For block options of type float, allow user to set options of type int as well (e.g. muon pT).

Potentially breaking change:

  • the type is checked when calling ConfigBlock.setOptionValue(). I do not expect this to break anything, though. The type check can be dropped if this is a problem.
Edited by Joseph Earl Lambert

Merge request reports