Skip to content

Commit f8d2413

Browse files
committed
Remove test code from device_manager module
1 parent e14259d commit f8d2413

File tree

1 file changed

+0
-174
lines changed

1 file changed

+0
-174
lines changed

src/dodal/device_manager.py

Lines changed: 0 additions & 174 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import typing
55
import warnings
66
from collections.abc import Callable, Iterable, Mapping, MutableMapping
7-
from concurrent import futures
87
from functools import cached_property, wraps
98
from inspect import Parameter
109
from types import NoneType
@@ -17,41 +16,24 @@
1716
ParamSpec,
1817
Self,
1918
TypeVar,
20-
cast,
2119
)
2220

2321
from bluesky.run_engine import (
2422
get_bluesky_event_loop,
2523
)
26-
from ophyd import EpicsMotor
2724
from ophyd.sim import make_fake_device
28-
from ophyd_async.core import PathProvider
29-
from ophyd_async.epics.adsimdetector import SimDetector
30-
from ophyd_async.epics.motor import Motor
3125

32-
from dodal.common.beamlines.beamline_utils import (
33-
set_beamline as set_utils_beamline,
34-
)
3526
from dodal.common.beamlines.beamline_utils import (
3627
wait_for_connection,
3728
)
38-
from dodal.common.beamlines.device_helpers import DET_SUFFIX, HDF5_SUFFIX
39-
from dodal.devices import motors
40-
from dodal.devices.motors import XThetaStage
41-
from dodal.log import set_beamline as set_log_beamline
4229
from dodal.utils import (
4330
AnyDevice,
44-
BeamlinePrefix,
4531
OphydV1Device,
4632
OphydV2Device,
4733
SkipType,
4834
)
4935

50-
BL = "adsim"
5136
DEFAULT_TIMEOUT = 30
52-
PREFIX = BeamlinePrefix("t01")
53-
set_log_beamline(BL)
54-
set_utils_beamline(BL)
5537

5638
T = TypeVar("T")
5739
Args = ParamSpec("Args")
@@ -622,159 +604,3 @@ def _build_order(
622604

623605
def __repr__(self) -> str:
624606
return f"<DeviceManager: {len(self._factories)} devices>"
625-
626-
627-
devices = DeviceManager()
628-
629-
630-
@devices.factory(skip=True, timeout=13, mock=True, use_factory_name=False)
631-
def stage() -> XThetaStage:
632-
"""Build the stage"""
633-
return XThetaStage(
634-
f"{PREFIX.beamline_prefix}-MO-SIMC-01:", x_infix="M1", theta_infix="M2"
635-
)
636-
637-
638-
@devices.factory(skip=stage.skip)
639-
def det(path_provider: PathProvider) -> SimDetector:
640-
return SimDetector(
641-
f"{PREFIX.beamline_prefix}-DI-CAM-01:",
642-
path_provider=path_provider,
643-
drv_suffix=DET_SUFFIX,
644-
fileio_suffix=HDF5_SUFFIX,
645-
)
646-
647-
648-
@devices.factory(mock=True)
649-
def base(base_x, base_y: motors.Motor) -> Motor:
650-
# print(base_x)
651-
# print(base_y)
652-
return f"{base_x} - {base_y}"
653-
654-
655-
@devices.factory
656-
def base_x() -> motors.Motor:
657-
# raise ValueError("Not a base_x")
658-
return "base_x motor"
659-
660-
661-
@devices.factory(skip=True)
662-
def base_y(path_provider) -> motors.Motor:
663-
# print(f"Using {path_provider=}")
664-
return "base_y motor"
665-
666-
667-
@devices.factory
668-
def optional(base_x, base_z=42):
669-
return (base_x, base_z)
670-
671-
672-
@devices.factory
673-
def unknown():
674-
# raise ValueError("Unknown error")
675-
return "unknown device"
676-
677-
678-
@devices.factory
679-
def one(): ...
680-
681-
682-
@devices.factory
683-
def two(one): ...
684-
685-
686-
@devices.factory
687-
def three(one, two): ...
688-
689-
690-
@devices.factory
691-
def four(one, two, three):
692-
return 4
693-
694-
695-
others = DeviceManager()
696-
697-
698-
@others.factory
699-
def circ_1(circ_2): ...
700-
701-
702-
@others.factory
703-
def circ_2(circ_1): ...
704-
705-
706-
@devices.v1_init(factory=EpicsMotor, prefix=f"{PREFIX.beamline_prefix}-MO-SIMC-01:M1")
707-
def old_motor(motor: EpicsMotor, foo: int = 42):
708-
print(f"Built {motor.name} with {foo=}")
709-
710-
711-
if __name__ == "__main__":
712-
# for name, factory in devices._factories.items():
713-
# print(name, factory, factory.dependencies)
714-
# print(devices._build_order({"path_provider": ["42"]}))
715-
716-
# print(devices["stage"])
717-
# print(devices["unknown"])
718-
# print(devices.build_all(fixtures={"path_provider": "numtracker"}))
719-
# print(devices._required_fixtures((devices["base"], devices["base_y"])))
720-
# print(devices._expand_dependencies([devices["base"]]))
721-
# print(devices._expand_dependencies(list(devices._factories.values())))
722-
# print(devices._build_order({"base": devices["base"]}))
723-
724-
# print(
725-
# "build_all",
726-
# devices.build_all({"path_provider": "all_nt", "base_y": "other base_y"}),
727-
# )
728-
# print(
729-
# "build_some",
730-
# devices.build_devices(
731-
# base, det, stage, unknown, fixtures={"path_provider": "numtracker"}
732-
# ),
733-
# )
734-
735-
# print("base", optional)
736-
# print("base_y", base_y)
737-
# print("b1", b1 := base.build(path_provider="num_track"))
738-
# print("b2", b2 := base(base_x="base_x motor", base_y="base_y motor"))
739-
# print("b1 is b2", b1 is b2)
740-
741-
# print("unknown()", unknown())
742-
# print("unknown.build()", unknown.build())
743-
744-
# print("circular", circ_1.build())
745-
746-
# print("optional deps", optional.dependencies)
747-
# print("optional optional deps", optional.optional_dependencies)
748-
# print("optional build", optional.build())
749-
# print("optional with override", optional.build(base_z=14))
750-
# print("optional without override", optional(17))
751-
# print("optional override required", optional.build(base_x=19))
752-
753-
# valid, errs = devices.build_all(
754-
# fixtures={"base_x": 19, "path_provider": "numtrack"}
755-
# )
756-
# print(valid)
757-
# print(errs)
758-
759-
# valid, errs = devices.build_devices(
760-
# base_x, base, optional, fixtures={"base_x": "19", "path_provider": "nt_pp"}
761-
# )
762-
# print(valid)
763-
# print(errs)
764-
765-
# print(base_x())
766-
767-
# res = devices.build_all(fixtures={"path_provider": "nt_path_provider"})
768-
# print(res)
769-
# conn = res.connect()
770-
# print(conn)
771-
772-
# res = four.build()
773-
# print(res)
774-
775-
# devices.build_devices(circ_1, circ_2)
776-
777-
# print(old_motor.dependencies)
778-
print(old_motor.build(mock=False))
779-
780-
# res = others.build_all()

0 commit comments

Comments
 (0)