Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ If you want to only tests for your machine and not develop, you shouldn't instal

Available packages for bindings:

TANGO: [tango-pyaml](https://github.com/python-accelerator-middle-layer/tango-pyaml)
TANGO: [tango-pyaml](https://github.com/python-accelerator-middle-layer/tango-pyaml)
TANGO or EPICS: [pyaml-cs-oa](https://github.com/python-accelerator-middle-layer/pyaml-cs-oa)

#### Developer Installation
Expand All @@ -29,17 +29,17 @@ TANGO or EPICS: [pyaml-cs-oa](https://github.com/python-accelerator-middle-layer
pip install -e .
```
4. Install the development dependencies and pre-commit hooks

```
pip install -e .[dev]
pre-commit install
```

5. If you want to try the examples using the control system bindings you also need to install those. See:

TANGO: [tango-pyaml](https://github.com/python-accelerator-middle-layer/tango-pyaml)
TANGO: [tango-pyaml](https://github.com/python-accelerator-middle-layer/tango-pyaml)
TANGO or EPICS: [pyaml-cs-oa](https://github.com/python-accelerator-middle-layer/pyaml-cs-oa)

6. If you want to run tests manually using the TANGO bindings without requiring a live machine you can also install the the Dummy TANGO control system available in tests/dummy-cs/tango. It is a simple emulation that allows to check the interface to the control system. The implemented control system doesn't do anything but it is only intended for tests during the development.


Expand Down
25 changes: 20 additions & 5 deletions pyaml/accelerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,25 @@ def live(self) -> ControlSystem:
def design(self) -> Simulator:
return self.__design

@staticmethod
def from_dict(config_dict: dict, ignore_external=False) -> "Accelerator":
"""
Construct an accelerator from a dictionary.
Parameters
----------
config_dict : str
Dictionnary conatining accelerator config
ignore_external: bool
Ignore external modules and return None for object that
cannot be created. pydantic schema that support that an
object is not created should handle None fields.

"""
if ignore_external:
# control systems are external, so remove controls field
config_dict.pop("controls", None)
return Factory.depth_first_build(config_dict, ignore_external)

@staticmethod
def load(
filename: str, use_fast_loader: bool = False, ignore_external=False
Expand Down Expand Up @@ -136,8 +155,4 @@ def load(
rootfolder = os.path.abspath(os.path.dirname(filename))
set_root_folder(rootfolder)
config_dict = load(os.path.basename(filename), None, use_fast_loader)
if ignore_external:
# control systems are external, so remove controls field
config_dict.pop("controls", None)
aml = Factory.depth_first_build(config_dict, ignore_external)
return aml
return Accelerator.from_dict(config_dict)
Loading