Skip to content

Commit 7fdb3ce

Browse files
Merge remote-tracking branch 'origin/main' into 366-feature-add-generic-elementholder-collection-access
2 parents e8afe1a + 47be3c0 commit 7fdb3ce

34 files changed

Lines changed: 100 additions & 12462 deletions

‎.github/workflows/dt4acc-integration.yml‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ jobs:
6060
python -m pip install -e ".[test]"
6161
python -m pip install "ophyd-async[tango, ca, pva]"
6262
python -m pip install --no-deps \
63-
"tango-pyaml @ git+https://github.com/python-accelerator-middle-layer/tango-pyaml.git" \
64-
"pyaml-cs-oa @ git+https://github.com/python-accelerator-middle-layer/pyaml-cs-oa.git"
63+
"tango-pyaml @ git+https://github.com/python-accelerator-middle-layer/tango-pyaml.git@1f010735bd675ad2f918958abd0396cb6766f14e" \
64+
"pyaml-cs-oa @ git+https://github.com/python-accelerator-middle-layer/pyaml-cs-oa.git@0.2.0"
6565
python -c "import tango; import tango.pyaml; import pyaml_cs_oa"
6666
6767
- name: Log in to GitLab registry
@@ -85,9 +85,12 @@ jobs:
8585
LOG_FILE="${RUNNER_TEMP}/dt4acc-twin.log"
8686
PID_FILE="${RUNNER_TEMP}/dt4acc-twin.pid"
8787
88+
ACCEL_SETUP_FILE=$(python -c "from pyaml_test_lattice import configurations; print(configurations['dt4acc/fodo_1gev_6d_dt4acc_tango.json'])")
89+
LATTICE_FILE=$(python -c "from pyaml_test_lattice import lattices; print(lattices['fodo_1gev_6d.json'])")
90+
8891
bash tests/integration/start_dt4acc_twin.sh \
89-
--accelerator-setup-file "${GITHUB_WORKSPACE}/tests/integration/data/fodo_1gev_6d/fodo_1gev_6d_dt4acc.json" \
90-
--lattice-file "${GITHUB_WORKSPACE}/tests/integration/data/fodo_1gev_6d/fodo_1gev_6d.json" \
92+
--accelerator-setup-file "${ACCEL_SETUP_FILE}" \
93+
--lattice-file "${LATTICE_FILE}" \
9194
--tango-host "${TANGO_HOST%:*}" \
9295
--tango-port "${TANGO_HOST##*:}" \
9396
--sif "${RUNNER_TEMP}/apptainer/dt4acc-soleil-twin.sif" \

‎pyaml/bpm/bpm.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
"""Beam-position monitor elements and their runtime interfaces."""
22

33
import copy
4-
from typing import Self
4+
from typing import TYPE_CHECKING, Self
55

66
from ..common.abstract import ReadFloatArray, ReadWriteFloatArray, ReadWriteFloatScalar
77
from ..common.element import Element, __pyaml_repr__
88
from ..common.exception import PyAMLException
99
from ..validation import DynamicValidation, register_schema
1010

11+
if TYPE_CHECKING:
12+
from ..common.holders.element_holder import ElementHolder
13+
1114
PYAMLCLASS = "BPM"
1215

1316

@@ -176,7 +179,7 @@ def attach(
176179
obj._peer = peer
177180
return obj
178181

179-
def _fill_device(self, holder) -> None:
182+
def _fill_device(self, holder: "ElementHolder") -> None:
180183
holder._fill_bpm(self)
181184

182185
def get_pos_devices(self) -> list[str | None]:

‎pyaml/common/element.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,12 @@ def attached_to(self) -> str:
268268
"""
269269
return "None" if self._peer is None else f"{self._peer.__class__.__name__}:{self._peer.name()}"
270270

271+
def _fill_device(self, holder: "ElementHolder"):
272+
"""
273+
Add this element to a holder (Simultor or ControlSystem)
274+
"""
275+
raise PyAMLException(f"__fill_device() is not implemented for {self.__class__.__name__}")
276+
271277
def post_init(self):
272278
"""
273279
Perform post-construction initialization after attachment.

‎pyaml/configuration/unbound_element.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@
66
known and the concrete element can be instantiated.
77
"""
88

9+
from typing import TYPE_CHECKING
10+
911
from pydantic import BaseModel
1012

1113
from ..common.element import Element
1214
from ..common.exception import PyAMLConfigException
1315

16+
if TYPE_CHECKING:
17+
from ..common.holders.element_holder import ElementHolder
18+
1419

1520
class UnboundElement(Element):
1621
"""
@@ -54,7 +59,7 @@ def __repr__(self):
5459
self._module_name,
5560
)
5661

57-
def _fill_device(self, holder) -> None:
62+
def _fill_device(self, holder: "ElementHolder") -> None:
5863
holder._fill_unbound_element(self)
5964

6065
def instantiate(self, holder) -> Element:

‎pyaml/diagnostics/tune_monitor.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"""
77

88
import copy
9-
from typing import Self
9+
from typing import TYPE_CHECKING, Self
1010

1111
from numpy.typing import NDArray
1212

@@ -15,6 +15,9 @@
1515
from ..validation import DynamicValidation, register_schema
1616
from .atune_monitor import ABetatronTuneMonitor
1717

18+
if TYPE_CHECKING:
19+
from ..common.holders.element_holder import ElementHolder
20+
1821
PYAMLCLASS = "BetatronTuneMonitor"
1922

2023

@@ -90,7 +93,7 @@ def set_harmonic(self, h: int):
9093
"""
9194
self._h = float(h)
9295

93-
def _fill_device(self, holder) -> None:
96+
def _fill_device(self, holder: "ElementHolder") -> None:
9497
holder._fill_betatron_tune_monitor(self)
9598

9699
@property

‎pyaml/magnet/cfm_magnet.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
provide separate strength and hardware access for those components.
66
"""
77

8+
from typing import TYPE_CHECKING
9+
810
from scipy.constants import speed_of_light
911

1012
from ..common import abstract
@@ -24,6 +26,9 @@
2426
from .skewsext import SkewSext
2527
from .vcorrector import VCorrector
2628

29+
if TYPE_CHECKING:
30+
from ..common.holders.element_holder import ElementHolder
31+
2732
_fmap: dict = {
2833
"B0": HCorrector,
2934
"A0": VCorrector,
@@ -131,7 +136,7 @@ def __init__(
131136
# Attach
132137
self._peer = peer
133138

134-
def _fill_device(self, holder) -> None:
139+
def _fill_device(self, holder: "ElementHolder") -> None:
135140
holder._fill_combined_function_magnet(self)
136141

137142
def get_model_name(self) -> str:

‎pyaml/magnet/magnet.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"""
77

88
import copy
9-
from typing import Self
9+
from typing import TYPE_CHECKING, Self
1010

1111
import numpy as np
1212
from scipy.constants import speed_of_light
@@ -16,6 +16,9 @@
1616
from ..common.element import Element
1717
from .model import MagnetModel
1818

19+
if TYPE_CHECKING:
20+
from ..common.holders.element_holder import ElementHolder
21+
1922

2023
class Magnet(Element):
2124
"""
@@ -131,7 +134,7 @@ def attach(
131134
obj._peer = peer
132135
return obj
133136

134-
def _fill_device(self, holder) -> None:
137+
def _fill_device(self, holder: "ElementHolder") -> None:
135138
holder._fill_magnet(self)
136139

137140
def set_energy(self, energy: float):

‎pyaml/magnet/serialized_magnet.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
This module defines magnet elements composed of multiple serialized magnets.
55
"""
66

7+
from typing import TYPE_CHECKING
8+
79
import numpy as np
810
from scipy.constants import speed_of_light
911

@@ -16,6 +18,9 @@
1618
from .magnet import Magnet
1719
from .model import MagnetModel
1820

21+
if TYPE_CHECKING:
22+
from ..common.holders.element_holder import ElementHolder
23+
1924
# Define the main class name for this module
2025
PYAMLCLASS = "SerializedMagnets"
2126

@@ -257,7 +262,7 @@ def __init__(
257262
# Attach
258263
self._peer = peer
259264

260-
def _fill_device(self, holder) -> None:
265+
def _fill_device(self, holder: "ElementHolder") -> None:
261266
holder._fill_serialized_magnets(self)
262267

263268
def __create_virtual_magnet(self, name: str) -> Magnet:

‎pyaml/rf/rf_plant.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@
77
"""
88

99
import copy
10-
from typing import Self
10+
from typing import TYPE_CHECKING, Self
1111

1212
from .. import PyAMLException
1313
from ..common import abstract
1414
from ..common.element import Element, __pyaml_repr__
1515
from ..validation import DynamicValidation, register_schema
1616
from .rf_transmitter import RFTransmitter
1717

18+
if TYPE_CHECKING:
19+
from ..common.holders.element_holder import ElementHolder
20+
1821
# Define the main class name for this module
1922
PYAMLCLASS = "RFPlant"
2023

@@ -115,7 +118,7 @@ def attach(
115118
obj._peer = peer
116119
return obj
117120

118-
def _fill_device(self, holder) -> None:
121+
def _fill_device(self, holder: "ElementHolder") -> None:
119122
holder._fill_rf_plant(self)
120123

121124

‎pyproject.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ cs-oa-tango = [
5050
test = [
5151
"pytest>=7.4",
5252
"pytest-cov>=3.0",
53+
"pyaml-test-lattice @ git+https://github.com/python-accelerator-middle-layer/pyaml-test-lattice.git@main",
5354
]
5455
doc = [
5556
"sphinx ~= 8.1",

0 commit comments

Comments
 (0)