You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description, motivation and use case
I thought harder after the community meeting to try and find a way to simplify configuration. Typically when writing the configuration files, they include devices with highly repeatable config. A "template" could be used to drastically reduce the number of lines in the configuration files.
then this could be expanded when building the storage ring.
Additional context
I have opened a draft PR #442 where I tried to implement something like this. It is definitely not perfect and there are a lot of edge cases that may cause problems.
I think it's a nice idea. I'm wondering if it might be useful to combine with jinja? Or maybe that's already part of the idea?
I have not considered jinja. I do not know anything about it actually.
I think it's quite nice. I only know of it because catap uses it for it's configuration. And then I discovered that the copier template also use it when I started setting that up.
I'm wondering now if it might be possible to generate the templates automatically from the JSON Schema? The JSON Schema is kind of a template. Just a very non user-friendly one... But to extract the JSON Schema is very easy and it might be possible to write a second step that from it produces user-friendly templates?
I agree that it is a good idea. I'm rather against Jinja which already causes me strong headache.
You should find a way to define your template and instanciate it. Not necessary link to a class.
We could imagine to have a template placeholder.
i.e.:
The syntax could be discussed. Here the ${} i propose will conflict with macros, but the idea is there.
Inside the ${ } a python code could be executed rather than a Jinja code. (Jinja code is not convenient at all)
It is rather easy to do directly in python.
Maybe jinja is not the best option then but I think it is anyway worth to investigate if there is some other template standard we can use. Inventing our own syntax for something that already exists feels like it can just mean more maintenance work.
A quick search gave me these options that might be easier but I haven't tried them.
Here the syntax is just python expect for the delimiter, compatible with yaml and our architecture.
IMHO, we don't need something very complex and adding new dependencies is more maintenance as you have to follow them and expect that you will have good support.
For instance what I really dislike in Jinja is that you need to produces a file which is no longer a yaml file neither a Jinja file and you lose code highlighting, code completion, etc, (may be it exits some plugin for vscode to handle this) and you also have to write a model for it.
To me, Variation 2 looks much better from a user's point of view. A con of Variation 1 is that it will trigger an error if the user forgets to put the "|" character next to "template: ".
On the other hand, I find Variation 1's implementation cleaner and less invasive. Both variations though needed to put a special case in either factory.py (Var1) or fileloader.py (Var2).
I personally favor Variaton 2.
The pull requests are not ready to merge but they are in state where the example runs and the implementations can be reviewed before continuing with tests, docs, e.t.c.
Activity
TeresiaOlsson commentedon Sep 18, 2026
I think it's a nice idea. I'm wondering if it might be useful to combine with jinja? Or maybe that's already part of the idea?
kparasch commentedon Sep 18, 2026
I have not considered jinja. I do not know anything about it actually.
TeresiaOlsson commentedon Sep 18, 2026
I think it's quite nice. I only know of it because catap uses it for it's configuration. And then I discovered that the copier template also use it when I started setting that up.
I'm wondering now if it might be possible to generate the templates automatically from the JSON Schema? The JSON Schema is kind of a template. Just a very non user-friendly one... But to extract the JSON Schema is very easy and it might be possible to write a second step that from it produces user-friendly templates?
JeanLucPons commentedon Sep 18, 2026
I agree that it is a good idea. I'm rather against Jinja which already causes me strong headache.
You should find a way to define your template and instanciate it. Not necessary link to a class.
We could imagine to have a template placeholder.
i.e.:
JeanLucPons commentedon Sep 18, 2026
The syntax could be discussed. Here the ${} i propose will conflict with macros, but the idea is there.
Inside the
${ }a python code could be executed rather than a Jinja code. (Jinja code is not convenient at all)It is rather easy to do directly in python.
simoneliuzzo commentedon Sep 18, 2026
I like the template idea!
TeresiaOlsson commentedon Sep 18, 2026
Maybe jinja is not the best option then but I think it is anyway worth to investigate if there is some other template standard we can use. Inventing our own syntax for something that already exists feels like it can just mean more maintenance work.
A quick search gave me these options that might be easier but I haven't tried them.
JeanLucPons commentedon Sep 18, 2026
Here the syntax is just python expect for the delimiter, compatible with yaml and our architecture.
IMHO, we don't need something very complex and adding new dependencies is more maintenance as you have to follow them and expect that you will have good support.
For instance what I really dislike in Jinja is that you need to produces a file which is no longer a yaml file neither a Jinja file and you lose code highlighting, code completion, etc, (may be it exits some plugin for vscode to handle this) and you also have to write a model for it.
TeresiaOlsson commentedon Sep 18, 2026
Mm. I did try the jinja extension in VS code since it's needed for the docs. It didn't work well for me...
kparasch commentedon Sep 28, 2026
I have opened a second pull request to implement a template that is more-or-less what @JeanLucPons proposed here.
variation 1, PR #442 :
variation 2, PR #456 :
To me, Variation 2 looks much better from a user's point of view. A con of Variation 1 is that it will trigger an error if the user forgets to put the "|" character next to "template: ".
On the other hand, I find Variation 1's implementation cleaner and less invasive. Both variations though needed to put a special case in either factory.py (Var1) or fileloader.py (Var2).
I personally favor Variaton 2.
The pull requests are not ready to merge but they are in state where the example runs and the implementations can be reviewed before continuing with tests, docs, e.t.c.
JeanLucPons commentedon Sep 29, 2026
Personally, i prefer the version 2 which looks more standard.