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
5 changes: 5 additions & 0 deletions docs/how-to/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ Basics

Advanced
-------

.. toctree::
:maxdepth: 1

Run tests using the BESSYII virtual accelerator <../notebooks/run_bessy_virtual_accelerator>
45 changes: 15 additions & 30 deletions docs/notebooks/control_system.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@
"pip install pyaml-oa-cs \n",
"\n",
"If the above packages are installed the examples below will work \n",
"\n",
"Different accelerators, with different magnet names can operate with their own control system within the same script\n"
"\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "ae7657cc",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -65,21 +64,21 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "86dec08e",
"metadata": {},
"outputs": [],
"source": [
"# work with TANGO\n",
"# SR_Tango: Accelerator = Accelerator.load(\"../../tests/config/EBSTune.yaml\")"
"SR_Tango: Accelerator = Accelerator.load(\"../../tests/config/EBSTune.yaml\")"
]
},
{
"cell_type": "markdown",
"id": "a61409b3",
"metadata": {},
"source": [
"Assuming these lines are present in ../../tests/config/EBSTuneOA.yaml\n",
"Assuming these lines are present in ../../tests/config/EBSTuneOATango.yaml\n",
"```\n",
"type: pyaml.accelerator\n",
"name: sr\n",
Expand All @@ -97,24 +96,13 @@
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "637bc8cf",
"cell_type": "markdown",
"id": "588bafd1",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"20 Jan 2026, 13:33:59 | WARNING | OA control system binding for PyAML initialized with name 'live' and prefix='//ebs-simu-3:10000/'\n"
]
}
],
"source": [
"# work with Ophyd-Asynch - tango\n",
"SR_OphydAsynch_Tango: Accelerator = Accelerator.load(\n",
" \"../../tests/config/EBSTuneOATango.yaml\"\n",
")"
"this works with Ophyd-Asynch - tango:\n",
"\n",
"SR_OphydAsynch_Tango: Accelerator = Accelerator.load(\"../../tests/config/EBSTuneOATango.yaml\")"
]
},
{
Expand All @@ -140,16 +128,13 @@
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "c1b749c1",
"cell_type": "markdown",
"id": "b2da995b",
"metadata": {},
"outputs": [],
"source": [
"# work with Ophyd-Asynch - tango\n",
"# SR_OphydAsynch_Epics: Accelerator = Accelerator.load(\n",
"# \"../../tests/config/EBSTuneOAEpics.yaml\"\n",
"# )"
"This work with Ophyd-Asynch - epics :\n",
"\n",
"SR_OphydAsynch_Epics: Accelerator = Accelerator.load(\"../../examples/BESSY2_example/BESSY2Tune.yaml\")"
]
}
],
Expand Down
168 changes: 168 additions & 0 deletions docs/notebooks/developper_install_instructions.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "29636569",
"metadata": {},
"source": [
"# developper installation instructions\n",
"\n",
"## prepare \n",
"cd work_dir\n",
"\n",
"deactivate existing python venv\n",
"\n",
"preconditions: \n",
"verify python version > 3.11 \n",
"verify github keys, or follow link to set them up \n",
"\n",
"## clone repositories for local development\n",
"```bash\n",
"git clone https://github.com/python-accelerator-middle-layer/tango-pyaml.git \n",
"git clone https://github.com/python-accelerator-middle-layer/pyaml.git \n",
"git clone https://github.com/python-accelerator-middle-layer/pyaml-cs-oa.git # optional\n",
"```\n",
"\n",
"## create virtual environment\n",
"python -m venv pyaml_venv \n",
"source ./pyaml_venv/bin/activate \n",
"pip install --upgrade pip \n",
"\n",
"## use latest pyAML version rather than latest release\n",
"```bash\n",
"cd pyaml \n",
"git submodule update --init --recursive \n",
"pip install -e . \n",
"cd .. \n",
"```\n",
"\n",
"## install tango-pyaml \n",
"\n",
"notice: do not do \"pip install -e .\" it does not work\n",
"\n",
"```bash\n",
"cd tango-pyaml \n",
"pip install . \n",
"cd .. \n",
"```\n",
"\n",
"[//]: # (OR latest ophid asych) \n",
"[//]: # (cd ../pyaml-cs-oa/ )\n",
"[//]: # (pip install -e . )\n",
"[//]: # (pip install -e .[dev] (very very long ~10 min on Simone's laptop) )\n",
"[//]: # (pre-commit install )\n",
"\n",
"## install dummy tango control system\n",
"\n",
"this will emulate device as in tango, but will not modify any beam dynamics value. only read/write of device attribute will be updated. read-only values will all return zero.\n",
"\n",
"```bash\n",
"cd pyaml\n",
"pip install ./tests/dummy_cs/tango-pyaml\n",
"cd ..\n",
"```\n",
"\n",
"## install virtual accelerator \n",
"SOLEIL will provide virtual accelerator installation scenario\n",
"\n",
"\n",
"## expected output\n",
"The output of pip list should be similar to: \n",
"```bash\n",
"accelerator-middle-layer 0.1.1 /Users/liuzzo/Desktop/test installation/pyaml \n",
"accelerator-toolbox 0.7.1 \n",
"annotated-types 0.7.0 \n",
"contourpy 1.3.3 \n",
"cycler 0.12.1 \n",
"docstring_parser 0.17.0 \n",
"fonttools 4.61.1 \n",
"h5py 3.15.1 \n",
"kiwisolver 1.4.9 \n",
"matplotlib 3.10.8 \n",
"numpy 2.3.5 \n",
"packaging 25.0 \n",
"pillow 12.0.0 \n",
"pip 25.3 \n",
"psutil 7.1.3 \n",
"pydantic 2.12.5 \n",
"pydantic_core 2.41.5 \n",
"pyparsing 3.2.5 \n",
"pytango 10.1.1 \n",
"python-dateutil 2.9.0.post0 \n",
"PyYAML 6.0.3 \n",
"scipy 1.16.3 \n",
"six 1.17.0 \n",
"tango-pyaml 0.3.1 \n",
"typing_extensions 4.15.0 \n",
"typing-inspection 0.4.2 \n",
"```\n",
"\n",
"## test that the installation is working correctly by running a pyAML example script\n",
"```bash\n",
"python ./pyaml/examples/ESRF_tune_example/esrf_tune_example.py \n",
"```\n",
"\n",
"## look at documentation to further test existing features\n",
"https://pyaml.readthedocs.io/en/latest/?badge=latest \n",
"\n",
"## example of development of pyaml documentation \n",
"```bash\n",
"cd pyaml\n",
"```\n",
"## create a new branch\n",
"```bash\n",
"git checkout -b doc-devnotebook\n",
"```\n",
"\n",
"## push the branch to remote\n",
"```bash\n",
"git push -u origin doc-devnotebook\n",
"```\n",
"\n",
"## modify something or add a file\n",
"```bash\n",
"edit ./pyaml/docs/notebooks/developper_install_instructions.ipynb \n",
"save\n",
"```\n",
"\n",
"## add file to git revision \n",
"```bash\n",
"git add docs/notebooks/developper_install_instructions.ipynb \n",
"```\n",
"\n",
"## test your code developments locally (in this example, build teh documentation locally)\n",
"```bash\n",
"pip install sphinx \n",
"pip install myst_nb \n",
"pip install pydata_sphinx_theme \n",
"python -m sphinx -b html docs ./docs/_build -d ./docs/_build \n",
"```\n",
"\n",
"## commit change\n",
"```bash\n",
"git commit ./docs/notebooks/developper_install_instructions.ipynb -m'some draft notes'\n",
"```\n",
"## push to remote\n",
"```bash\n",
"git push\n",
"```\n",
"### open a pull request to accept your change:\n",
"in a browser navigate to: https://github.com/python-accelerator-middle-layer/pyaml \n",
"click on \"compare and pull request\" \n",
"Add some description and click on Create pull request. \n",
"\n",
"The pull request page will open \n",
"Add reviewers to your pull request: in order to be approved, 2 positive reviews are needed. \n",
"\n",
"\n"
]
}
],
"metadata": {
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
95 changes: 95 additions & 0 deletions docs/notebooks/run_bessy_virtual_accelerator.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "712267c5",
"metadata": {},
"source": [
"if ARM-based macos (M1, M2, M3....)\n",
"server:\n",
"1) brew install qemu lima\n",
"2) limactl start --rosetta --vm-type=vz --network=vzNAT template://apptainer\n",
"3) press enter\n",
"\n",
"if Intel-based macos\n",
"server:\n",
"1) brew install lima\n",
"2) limactl start --vm-type=vz --network=vzNAT template://apptainer\n",
"3) press enter\n",
"\n",
"To start container:\n",
"1) limactl shell apptainer \n",
"2) apptainer run oras://registry.hzdr.de/digital-twins-for-accelerators/containers/pyat-softioc-digital-twin:v0-1-2-bessy.2475331\n",
"\n",
"\n",
"Stopping container:\n",
"1) limactl stop apptainer\n",
"2) limactl delete apptainer\n"
]
},
{
"cell_type": "markdown",
"id": "157e78da",
"metadata": {},
"source": [
"to get address we need pvlist. On another terminal:\n",
"1) limactl shell apptainer # to go in VM\n",
"2) apptainer run oras://registry.hzdr.de/digital-twins-for-accelerators/epics-tools:v0-1-0.2028728`\n",
"3) pvlist\n",
"4) pvlist 192.168.5.15:5075 (replace the address with the one printed by the command above after tcp@)"
]
},
{
"cell_type": "markdown",
"id": "78eca7cd",
"metadata": {},
"source": [
"# create an environment\n",
"python -m venv bessy2_pyaml\n",
"source bessy2_pyaml/bin/activate\n",
"\n",
"# clone repositories from main (not latest release)\n",
"git clone https://github.com/python-accelerator-middle-layer/pyaml.git\n",
"git clone https://github.com/python-accelerator-middle-layer/pyaml-cs-oa.git\n",
"\n",
"# install locally (need to modify the pyaml configuration)\n",
"cd pyaml\n",
"pip install -e . \n",
"\n",
"cd pyaml-cs-oa\n",
"pip install -e . \n",
"\n",
"pip install aioca\n",
"\n",
"change the pyaml configuration file ./pyaml/examples/BESSY2_example/BESSY2Orbit.yaml at line 11 with the correct prefix (replace pons: by your prefix)\n",
"change the pyaml configuration file ./pyaml/examples/BESSY2_example/BESSY2Tune.yaml at line 11 with the correct prefix (replace pons: by your prefix)\n",
"change the pyaml configuration file ./pyaml/examples/BESSY2_example/BESSY2Chroma.yaml at line 11 with the correct prefix (replace pons: by your prefix)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1a5d310f",
"metadata": {
"vscode": {
"languageId": "plaintext"
}
},
"outputs": [],
"source": [
"navigate to the folder ./pyaml/examples/BESSY2_example/\n",
"run the file bessy2-orbit.py\n",
"(this will take sometime to compute the ORM)\n",
"run the file bessy2-tune.py\n",
"run the file bessy2-chroma.py\n"
]
}
],
"metadata": {
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
15 changes: 15 additions & 0 deletions docs/tutorial/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Tutorials
=============

Here you can find step-by-step guides with explainations for both new and experienced users.

Basics
-------

.. toctree::
:maxdepth: 1

How to correct tunes

Advanced
-------
Loading