Skip to content

About

A generic IOC for simple python scripts

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Generic IOC ioc-python

Description

Generic python IOC for simply python script based IOCs

Template Info

This repository was generated by ioc-template

To update to the latest version of the template:

# activate a python virtual environment

pip install copier
cd ioc-python
copier update --trust .

Developer Container

This repository includes a developer container configuration for Visual Studio Code. This allows you to run the Generic IOC locally and debug it. See https://epics-containers.github.io/main/tutorials/dev_container.html.

The developer container runs the ioc-python-developer:latest image that CI publishes with each full release, named in both .devcontainer/devcontainer.json (what the container runs) and .devcontainer/initializeCommand (what is pulled or built): change one and the other must follow. Each time the container starts:

  • .devcontainer/initializeCommand pulls that image on the host. If the pull fails it uses the local image of that name, and if there is none it builds one with ./build.
  • ibek dev sync runs in the container. It compares the project folder with the source the image was built from, brings the support module definitions in line and reports anything that needs a rebuild.

A pre-release tag does not move latest. A repository that has made no full release from this template has no such image, so its first start builds one locally. Changes merged to main after the last release are not in the image: ibek dev sync reports the difference.

An existing container keeps the image it was created from: use "Dev Containers: Rebuild Container" to move it to the image that was pulled. While the container was created from a different image than the one on the machine, usually an older one, the ibek dev commands print a WARNING that says so.

A container starts without the IOC build products when it is created, by the first start or by "Dev Containers: Rebuild Container". .devcontainer/postCreateCommand runs make clean uninstall in /epics/ioc, which links to ioc/ in the project folder, because its build products were built against the support modules of another container. Run make in /epics/ioc to build the IOC: ibek dev status says when that is needed. Source files and the ioc/config link that ibek dev instance makes are kept, and reopening an existing container keeps its build products.

To run the image built from your own tree instead, for example after changing the Dockerfile or on a branch that is far from main, create the marker file and use "Dev Containers: Rebuild Container":

touch .devcontainer/local-build

While that file exists each start builds the image with ./build, which is quick when the layers are cached, instead of pulling it. The build leaves the project folder as it is: .dockerignore keeps the IOC build products and the ioc/config link out of the image. Delete the file to go back to the published image. Git ignores the file.

Channel Access

The vscode developer container auto forwards the channel access ports on the loopback interface. If you have channel access clients running on the host machine, you can connect to the IOC by setting the EPICS_CA_NAME_SERVERS environment variable as follows:

export EPICS_CA_NAME_SERVERS=127.0.0.1:5064
caget IOCNAME:PVNAME

Passing arguments to the python script

Any arguments given to ioc/start.sh are passed on to the startup python script (config/main.py, or $MAIN_PYTHON) and to an override config/start.sh. The simplest way to add arguments in a service's values.yaml is to override the ioc-instance helm chart's command so that start.sh is run directly, and put the arguments in args:

ioc-instance:
  command: [/epics/ioc/start.sh]
  args: [--my-option, value]

Alternatively, keep the chart's default command: [bash, -c] and forward the arguments from the bash -c script (the second entry fills $0):

ioc-instance:
  args:
    - /epics/ioc/start.sh "$@"
    - start.sh
    - --my-option
    - value

A --test first argument makes start.sh check that the script compiles without launching it.

Architectures

The image is published for amd64 and arm64. PyQt5 is amd64 only, as there are no linux aarch64 wheels for it.

About

A generic IOC for simple python scripts

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages