Suggestions for configuration layer #27
Replies: 4 comments 46 replies
-
|
I'm not sure to fully understand. |
Beta Was this translation helpful? Give feedback.
-
|
It's my impression that the most resource intensive aspect of the middle layer is the simulator. So I don't think you gain a lot by doing lazy evaluation since you load the lattice with the first magnet you want to access. Instead you will have to check that your simulator exists every single time you try to access a magnet. Nevertheless, what instantiates the pyaml object is the command Finally, nothing really needs to be changed to dynamically modules. You just need to know where to look in the "sr.yaml" file. |
Beta Was this translation helpful? Give feedback.
-
|
@TeresiaOlsson could you please clarify you needs, with possibly some syntax examples? It is absolutely not clear what you want? What do you mean by configuration classes? Would like something like: |
Beta Was this translation helpful? Give feedback.
-
|
I want to summarise what I understood from the original message of Teresia. In terms of desired requirements, Teresia and colleagues want:
From my understanding: 1. Advantages and disadvantages of the two approaches should be listed in this discussion or in a separate document. Otherwise, this is too difficult to navigate the discussion. I suggest we focus only on this point first in the discussion and keep the other points after this one is discussed. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Edit: for summary, see the post from @gubaidulinvadim
https://github.com/orgs/python-accelerator-middle-layer/discussions/27#discussioncomment-14699670
I'm attempting to go through the two architecture proposals step-by-step and come up with suggestions for how to merge.
The first step I have looked at is the configuration layer.
In addition I have added a suggestion to replace the functionality of the MML AcceleratorObject that Marco and I felt was missing when we tested.
I have made a little example to illustrate the idea. Since it will require discussion and refactoring effort I have put the example in a temporary separate repository. Sorry for the name, I had to come up with some temporary one to use for the example...
Here is the repository with the example:
https://github.com/python-accelerator-middle-layer/aml
What it will replace
I think the idea is a combination of the functionality of
ConfigServiceandYellowPagesfrom theaccmlrepository.It's a replacement of
pyAMLandInstrumentin thepyamlrepository.For historical reasons (and because I had no better idea) I called the class
Acceleratorbut it could also be called registry or something else.The MML AcceleratorObject (AO) and AcceleratorData (AD)
In MML there is the AcceleratorObject (AO) which is a key part of the architecture.
In my view this serves the functionality of a registry. It stores the configuration data and allows the user to browse/modify it as needed. It contains no business logic but only data.
MML also have AcceleratorData (AD) which complements the AO.
I don't think it's entirely clear in MML which type of configuration data should go where but I would say the AO is for static data
(such as PV/attribute names etc) and AD more for dynamic data (operational mode specific application settings etc).
MML has a weird way where information is searched for in various places in some order which we probably should not follow since it is error prone but the idea of static vs dynamic config data I think is a useful one. The example includes no dynamic config data yet since that is mostly for applications.
Both the AO and AD have a defined structure. I would say it is a data model for the configuration which helps the user a lot when figuring out how to set up the configuration for their machine.
For more details, see Appendix III in the MML manual.
In MML all "devices" and applications extract the configuration they need from the AO and AD when they need it.
Benefits
These are what I think are the benefits:
The data models for the configuration are gathered in one place so they are easier to find instead of spread out in different modules.
It is modular. You can create only the config objects you need and skip the rest.
You can create the configuration in different ways: creating config objects directly, read in from different external sources etc.
It works as long as you in the end have a config object with the structure described by the data models.
There is no need to define a type in the configuration for parts where there should be no option to use external modules anyway.
I think parts like
type: pyaml.pyamlandtype: pyaml.instrumentjust clutters the yaml file and makes it more difficult to read.For cases where there are several different data models to choose from, pydantic also has the functionality that it sometimes can figure out itself which option to create based on the given keywords so no type keyword is required. I think we should make use of that where it works to simplify the yaml file.
The big difference
This I think is they key point to discuss.
In this suggestion the devices are not created at initialization of pyAML. I haven't understood the benefits of that? If I have a full configuration set up with many different control modes, lattice models and several operational modes it seems to me like then a lot of objects with business logic need to be created and kept in memory despite that they will not be used during that session?
To me it feels like a better approach to store the configuration data in a registry, and devices are only created at the point when the user needs them and then for the mode the user is asking for.
For example, the part
quadForTuneDesign = sr.design.get_magnets("QForTune")in the ESRF example could instead of retrieving objects that already has been created also create them since the user at that point anyway says that they want the devices in the family "QForTune" for the simulator using the lattice model "design."But maybe there is some benefit of initializing all devices from the start that I haven't understood?
Beta Was this translation helpful? Give feedback.
All reactions