Skip to content

Feature: template in configuration file, 2nd variation - #456

Draft
kparasch wants to merge 1 commit into
mainfrom
feature/configuration-template-var2
Draft

kparasch wants to merge 1 commit into
mainfrom
feature/configuration-template-var2

Conversation

@kparasch

@kparasch kparasch commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

An unfinished example of a Template category in accelerator that allows generation of devices from templates. Uses a "template resolver" to generate from templates.

Due to the way files are expanded. An "ugly" solution was used to make sure templates have been loaded before the rest of the file. It is unclear if a more elegant solution can be found.

The template class uses the standard python string ".format" function to replace text and generate the template. Internally, it serializes a config dictionary to a yaml string, makes the replacement, and then de-serializes the yaml string into a new config dictionary.

example config with template:

class: pyaml.accelerator.Accelerator
machine: sr
facility: PETRAIII
energy: 6e9
controls:
 - class: tango.pyaml.controlsystem.TangoControlSystem
   tango_host: ebs-simu-3:10000
   name: live
   catalog:
     class: tango.pyaml.tango_catalog.TangoCatalog
     disconnected: True
devices:
- ${template:SHI,SHI,01}
- ${template:SHI,SHI,02}
- ${template:SHI,SHI,03}
templates:
  - name: SHI
    parameters:
      - sh_name
      - ii
    config:
      class: pyaml.magnet.hcorrector.HCorrector
      name: "{sh_name}-{ii}"
      model:
        class: pyaml.magnet.linear_model.LinearMagnetModel
        unit: rad
        hardware_unit: str
        calibration_factor: 1.0
        powerconverter: tango/MAGNET/{sh_name}-{ii}/B1L

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant