epics-containers / ibek

IOC Builder for EPICS and Kubernetes
https://epics-containers.github.io/ibek
Apache License 2.0
10 stars 4 forks source link

Allow inclusion of repeated patterns in support yaml #211

Open gilesknap opened 2 months ago

gilesknap commented 2 months ago

The dls-plc module is an example of why this is needed. It's builder.py translation to dls-plc.ibek.support.yaml comes out at 12000 lines.

This is because there are many arguments relating to interlocks that are repeated in each of the definitions.

If instead we could write those arguments down once and include them then the file would be much more maintainable. We can use yaml references for this purpose. https://medium.com/@kinghuang/docker-compose-anchors-aliases-extensions-a1e4105d70bd

Thus the argument list would become List[Arg | List[Arg]] And the definitions list would maybe look like:

thing:
  args: &thing_args
    - type: str
      name: P
    - type: str
      name: Q

other_thing:
  args:
    - *thing_args
    - type: str
      name: R

Although maybe we should have a separate top level dictionary item as a peer to 'defs' that declares shared argument lists. Also need to think about whether other things like database declarations and startup script lines would also want to support this kind of thing.

gilesknap commented 2 weeks ago

in 3.0.0b6 we have radically adjusted the schema in order to support yaml anchors and aliases in args (now called parameters).

I've experimented with the 12000 line dlsPLC and reduced it to around 5000 lines.

Leaving this open as a reminder to complete the translation of dlsPLC and add a test to verify that the aliased form loads in as exactly the same object graph.