Skip to content

About

additional templates and entity models to add to generic IOCs at runtime

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

ibek-runtime-support

A central library of runtime support patterns for otherwise-generic EPICS IOCs. Each pattern is a self-contained set of ibek support files (entity definitions, and any EPICS DB/template they instantiate) that an IOC instance can vendor at a pinned version using ibek pattern.

Vendoring copies a pattern's files into an IOC instance's config/ directory and records exactly which version was taken, with per-file integrity hashes. The IOC then loads that extra support at runtime, with no image rebuild — a generic IOC image gains additional entities/DB without a purpose-built container.

This repo is consumed by the ibek pattern subsystem in epics-containers/ibek. It is one of two central pattern libraries; its sibling ibek-runtime-streamdevice holds StreamDevice device-support patterns (protocol + DB + support). This repo holds the non-StreamDevice runtime additions — entity/DB bundles that layer onto a generic IOC.

What a "pattern" is — the file-set contract

A pattern is a top-level folder named after the pattern. The folder name is the pattern name used on the command line.

A pattern holds an arbitrary file-set, not a fixed shape. The only required member is the ibek support definition; everything else is whatever that definition references:

File Role Required
*.ibek.support.yaml ibek support module: declares the entity_models, their parameters, and which DB/template files to instantiate yes
*.template / *.db EPICS database/template instantiated by the entity optional
*.req autosave request file(s), named <template stem>_positions.req (restored at pass 0) or <template stem>_settings.req (pass 0 and 1) optional
*.pvi.device.yaml PVI device descriptor (UI/PV generation) optional
anything else the support yaml references … optional

There is no hard-coded file shape. The vendoring lock simply hashes a file list, so it already generalises to any combination of the above (or files not yet invented). Add the files your support yaml needs and they are vendored together as a unit.

Each pattern is a top-level folder, for example:

detectorPlugins/
  detectorPlugins.ibek.support.yaml   # entity_models "gdaPlugins" and "detectorPlugins"
  gdaPlugins.template                 # GDA helper records for gdaPlugins
  gdaPluginsStats.xml                 # NDAttributes file for gdaPlugins' NDStats
BL15I-BUILDER/
  BL15I-BUILDER.ibek.support.yaml
  BL15I-SumTheDiode.template

detectorPlugins is the standard AreaDetector plugin set used DLS-wide. Its support yaml declares two entity models, each a curated collection of AreaDetector plugins wired together:

  • gdaPlugins — the full plugin set for GDA (ROIs, stats, std-arrays, process, overlay, ffmpeg file and stream, TIFF/HDF5 file writers, PVA). It replaces the DLS builder object adUtil.gdaPlugins (adUtil 2-44) with the same PV names, parameters, defaults and startup settings, so the IOC presents the same API to GDA.
  • detectorPlugins — the lighter plugin set for Ophyd (PVA, stats, ROI-stat, HDF5).

The plugins these reference are compiled into the AreaDetector IOC image (gdaPlugins also needs ffmpegServer); this pattern adds the ibek entities that instantiate and connect them at runtime. gdaPlugins also ships two files of its own: gdaPlugins.template, the soft records GDA uses alongside the plugins, and gdaPluginsStats.xml, the NDAttributes file its NDStats plugins load from the instance's config/ folder.

Pristine storage

Files in this repo are stored PRISTINE. They contain exactly the content an IOC instance needs, with no provenance header.

ibek pattern (ibek 4.8.0 or later) vendors each file byte-identical to the library at the pinned tag: nothing is injected or rewritten. The instance's runtime-lock.yaml records where the files came from and a sha256 of each, so integrity checking on the consumer side is a trivial sha256(file) == lock.

Earlier ibek releases injected a # Vendored from … header as each file's first line. That breaks any file whose format has no # comment, such as detectorPlugins/gdaPluginsStats.xml, so vendor this library with ibek 4.8.0 or later.

Versioning

Releases are cut as repo-wide semantic-version git tags, written as bare X.Y.Z (0.3.0, 0.4.0, …) as in ibek and ibek-runtime-streamdevice. The repo's first two tags are v0.1.0 and v0.2.0. From 0.3.0 on, pushing a tag creates a GitHub Release automatically, with generated release notes. A tag is an immutable point covering every pattern in the repo at that revision, so name@<tag> always resolves to the same bytes.

There is intentionally no per-pattern version: a single tag versions the whole library. Bump the tag when any pattern changes; consumers opt in to the new content by moving their pin.

On the consumer side, Renovate tracks the pin using the github-releases datasource and raises a PR to bump the pinned version when a new tag is published, keeping IOC instances current without manual edits.

Consumer pin / update workflow

All consumer commands run against an IOC instance directory (services/<instance>/ in a services repo). ibek pattern writes the vendored files into the instance's config/, and writes runtime-lock.yaml + ioc.schema.json at the instance root (not in config/, which is the ≤ 1 MiB K8s ConfigMap and holds runtime inputs only).

Add a pattern (pin a version)

The qualified name <library>:<pattern>@<tag> selects the library, pattern and version:

ibek pattern add ibek-runtime-support:[email protected] services/bl01t-di-cam-01

This:

  1. fetches the pattern's file-set at tag v0.1.0,
  2. writes each file, byte-identical, into services/bl01t-di-cam-01/config/,
  3. records version, source and a per-file sha256 in services/bl01t-di-cam-01/runtime-lock.yaml,
  4. merges the pattern's entity models into the instance's services/bl01t-di-cam-01/ioc.schema.json (the image's published schema with the vendored entities grafted in) and points config/ioc.yaml's first line at it (# yaml-language-server: $schema=../ioc.schema.json).

You then reference the entity in config/ioc.yaml (the entity type is <module>.<entity_model>):

entities:
  - type: detectorPlugins.gdaPlugins
    P: BL01T-DI-CAM-01
    CAM: DET.DET
    PORTPREFIX: D

The resulting runtime-lock.yaml looks like:

version: 1
patterns:
  detectorPlugins:
    version: v0.1.0
    source: github.com/epics-containers/ibek-runtime-support
    files:
      config/detectorPlugins.ibek.support.yaml: "sha256:…"
      config/gdaPlugins.template: "sha256:…"
      config/gdaPluginsStats.xml: "sha256:…"

(a hash value may be "DIRTY # <reason>" for a deliberately locally-modified file).

Update a pin

ibek pattern update detectorPlugins services/bl01t-di-cam-01 -v v0.2.0
# or update every pinned pattern to its latest resolvable version:
ibek pattern update services/bl01t-di-cam-01

Check integrity (CI / pre-commit)

ibek pattern check services/bl01t-di-cam-01

Re-hashes each vendored file and fails if it drifts from runtime-lock.yaml. Allow intentional local edits with --allow-dirty (or IBEK_ALLOW_DIRTY=1); such files must be marked DIRTY in the lock.

Restore vendored files

ibek pattern restore detectorPlugins services/bl01t-di-cam-01   # one pattern
ibek pattern restore services/bl01t-di-cam-01                   # all patterns

Rewrites the vendored files from the locked version, discarding local edits.

Inspect the merged schema

ibek pattern schema services/bl01t-di-cam-01

Regenerates the instance's self-contained ioc.schema.json (the image's published base schema with the vendored/local entities merged in). If the image has not published a schema, this is reported and skipped — it is not an error.

Beamline support modules

The soft-record support of a DLS beamline support module (for example BL15I-BUILDER) lives in this library as a runtime pattern named after the module: msi templates whose records come only from EPICS base and stock support modules such as asyn, calc and busy, so nothing needs compiling. These patterns are never built into a generic IOC image. Each IOC instance that uses one adds it for itself:

ibek pattern add ibek-runtime-support:BL15I-BUILDER@<tag> services/<instance>

The pattern keeps the module's name, entity model names and parameter names, so an existing ioc.yaml validates unchanged once the pattern is vendored, provided it uses only entity models the pattern carries. A pattern may carry only some of its module's templates (BL15I-BUILDER carries one); add the others to the pattern as they are wanted.

Beamline code that must be compiled — SNL programs, aSub routines, device support — cannot be a runtime pattern. It stays in ibek-support-dls.

Support that belongs to one instance alone can instead go straight into that instance's config/ as a *.ibek.support.yaml. It is not recorded in runtime-lock.yaml (it is editable, not vendored) but is merged into that instance's ioc.schema.json alongside the vendored patterns when you run ibek pattern schema services/<instance> after adding or changing it.

Adding a new pattern

  1. Create a top-level folder named after the pattern, e.g. mydetector/.
  2. Drop in the file-set:
    • mydetector.ibek.support.yaml — the ibek support module (module name, one or more entity_models with their parameters and sub_entities/databases),
    • any *.template/*.db/*.req files that support yaml references.
  3. Keep every file pristine: exactly the content an IOC instance needs.
  4. Validate locally by vendoring into a scratch IOC instance: ibek pattern add ibek-runtime-support:mydetector@HEAD <instance> (or test against a branch) and run ibek pattern check.
  5. Open a PR. Once merged, cut a new semver tag (bare X.Y.Z) so consumers can pin the new pattern; Renovate will then offer the bump downstream.

License

Apache License 2.0.

About

additional templates and entity models to add to generic IOCs at runtime

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors