Configuration#
from pyaml.accelerator import Accelerator
SR: Accelerator = Accelerator.load("../../tests/config/EBSTune.yaml")
---------------------------------------------------------------------------
PyAMLConfigException Traceback (most recent call last)
Cell In[1], line 3
1 from pyaml.accelerator import Accelerator
2
----> 3 SR: Accelerator = Accelerator.load("../../tests/config/EBSTune.yaml")
File ~/checkouts/readthedocs.org/user_builds/pyaml/envs/stable/lib/python3.13/site-packages/pyaml/accelerator.py:304, in Accelerator.load(filename, use_fast_loader, ignore_external)
299 except UnsupportedConfigurationRootError as ex:
300 raise PyAMLConfigException(
301 "Accelerator.load() expects a 'pyaml.accelerator' root configuration. "
302 "Use the factory APIs to build sub-elements directly."
303 ) from ex
--> 304 return manager.build(ignore_external=ignore_external)
File ~/checkouts/readthedocs.org/user_builds/pyaml/envs/stable/lib/python3.13/site-packages/pyaml/configuration/manager.py:496, in ConfigurationManager.build(self, ignore_external)
494 set_root_folder(self._build_root)
495 snapshot = ConfigurationManager.strip_runtime_internal_metadata(self._snapshot(include_internal_metadata=True))
--> 496 return Accelerator.from_dict(snapshot, ignore_external=ignore_external)
File ~/checkouts/readthedocs.org/user_builds/pyaml/envs/stable/lib/python3.13/site-packages/pyaml/accelerator.py:275, in Accelerator.from_dict(config_dict, ignore_external)
273 # Ensure factory is clean before building a new accelerator
274 Factory.clear()
--> 275 return Factory.depth_first_build(config_dict, ignore_external)
File ~/checkouts/readthedocs.org/user_builds/pyaml/envs/stable/lib/python3.13/site-packages/pyaml/configuration/factory.py:194, in PyAMLFactory.depth_first_build(self, d, ignore_external)
191 # Do not recurse dict defined in ConfigModel
192 # pydantic use TypedDict not usable with isinstance
193 if str(fieldType) != "<class 'dict'>":
--> 194 obj = self.depth_first_build(value, ignore_external)
195 # Replace the inner dict by the object itself
196 d[key] = obj
File ~/checkouts/readthedocs.org/user_builds/pyaml/envs/stable/lib/python3.13/site-packages/pyaml/configuration/factory.py:177, in PyAMLFactory.depth_first_build(self, d, ignore_external)
175 for _index, e in enumerate(d):
176 if isinstance(e, dict) or isinstance(e, list):
--> 177 obj = self.depth_first_build(e, ignore_external)
178 l.append(obj)
179 else:
File ~/checkouts/readthedocs.org/user_builds/pyaml/envs/stable/lib/python3.13/site-packages/pyaml/configuration/factory.py:184, in PyAMLFactory.depth_first_build(self, d, ignore_external)
181 return l
183 elif isinstance(d, dict):
--> 184 _, config_cls, *_ = self.get_infos(d, ignore_external)
186 for key, value in d.items():
187 if not key == "__fieldlocations__":
File ~/checkouts/readthedocs.org/user_builds/pyaml/envs/stable/lib/python3.13/site-packages/pyaml/configuration/factory.py:84, in PyAMLFactory.get_infos(self, d, ignore_external)
81 except ModuleNotFoundError as ex:
82 if not ignore_external:
83 # Discard module not found stack trace
---> 84 raise PyAMLConfigException(
85 "Module referenced in type cannot be found:" + f"'{module_str}' {location_str}"
86 ) from None
87 else:
88 return None
PyAMLConfigException: Module referenced in type cannot be found:'tango.pyaml.controlsystem' /home/docs/checkouts/readthedocs.org/user_builds/pyaml/checkouts/stable/tests/config/EBSTune.yaml at line 12, column 5.
pyaml/tests/config/EBSTune.yaml is an example pyAML yaml configuration file that defines:
a 6GeV Storage ring with
1 array (family) of quadrupoles used for tune correction
1 tune device
controlled by Tango
simulated with AT
It looks like this:
type: pyaml.accelerator
name: sr
energy: 6e9
simulators:
- type: pyaml.lattice.simulator
lattice: sr/lattices/ebs.mat
name: design
controls:
- type: tango.pyaml.controlsystem
tango_host: ebs-simu-3:10000
name: live
data_folder: /data/store
arrays:
- type: pyaml.arrays.magnet
name: QForTune
elements:
- QD2A-C03
- QD2E-C04
- QD2A-C05
- ...
devices:
- type: pyaml.magnet.quadrupole
name: QD2A-C03
model:
type: pyaml.magnet.linear_model
calibration_factor: 1.002096389
crosstalk: 0.99912
curve:
type: pyaml.configuration.csvcurve
file: sr/magnet_models/QD2_strength.csv
unit: 1/m
powerconverter:
type: tango.pyaml.attribute
attribute: srmag/vps-qd2/c03-a/current
unit: A
- ...
- ...
- ...
- type: pyaml.diagnostics.tune_monitor
name: BETATRON_TUNE
tune_h:
type: tango.pyaml.attribute_read_only
attribute: srdiag/tune/tune_h
unit: mm
tune_v:
type: tango.pyaml.attribute_read_only
attribute: srdiag/tune/tune_v
unit: mm