Select which pattern files an instance vendors#
This is an advanced option. Most instances vendor exactly what a pattern’s
ibek.manifest.yaml lists, as described in
Vendor runtime support; stay with that unless an instance needs a
different set of files.
A selection changes the manifest’s file-set for one instance only. It can:
add pattern files that the manifest leaves out, such as a simulation template in a pattern’s
sim/folder;narrow the manifest’s files, for example to one or two templates from a large pattern, by file name or by entity model;
place a selected file at a destination path you choose.
The selection is recorded in the instance’s runtime-lock.yaml, so update,
restore and check keep the same file-set.
Add a pattern with a selection#
ibek pattern add ibek-runtime-streamdevice:CryoconM14@0.6.0 services/my-ioc \
--include 'sim/(.*_sim\.py)=sim/\1' \
--exclude 'M14_system\.template'
--include SRC=DEST vendors every pattern file whose path matches the regular
expression SRC to DEST. --exclude SRC stops the manifest from vendoring
files that match SRC. Both options can be given more than once.
SRC and DEST work as they do in the manifest (see the
manifest reference):
SRCis matched withre.fullmatchagainst the file’s path relative to the pattern folder.A
DESTwhose last part has a file extension is the destination file.SRCmust then match exactly one file. For example,sim/x_sim\.template=config/x.templateplacessim/x_sim.templateatconfig/x.template.Any other
DESTis a folder, and the file keeps its path relative to the pattern beneath it. For example,sim/.*=configplacessim/x.pyatconfig/sim/x.py. EndDESTwith/to use a folder whose name has an extension:sim/.*=config/sim.d/placessim/x.pyatconfig/sim.d/sim/x.py.A
DESTcontaining\1or\g<name>is the complete destination path, built from the regex groups. For example,sim/(.*)=config/\1placessim/x.pyatconfig/x.py.
DEST is relative to the instance root. ibek splits the argument at its last
=, so the regular expression may contain =.
The command above records:
version: 2
patterns:
CryoconM14:
version: 0.6.0
source: github.com/epics-containers/ibek-runtime-streamdevice
select:
include:
- src: sim/(.*_sim\.py)
dest: sim/\1
exclude:
- M14_system\.template
files:
config/CryoconM14.ibek.support.yaml: sha256:...
config/M14.protocol: sha256:...
config/M14_sensor.template: sha256:...
sim/CryoconM14_sim.py: sha256:...
Narrow to named files or models#
--only FILE vendors only the named pattern files, and --model NAME only the
files the named entity models load:
ibek pattern add ibek-runtime-support:BL21I@0.4.0 services/my-ioc \
--model TTHBumpstripMonitor
ibek pattern add ibek-runtime-streamdevice:CryoconM14@0.6.0 services/my-ioc \
--only M14.protocol --only M14_sensor.template \
--only M14_sensor.pvi.device.yaml
The pattern’s
*.ibek.support.yamlis always vendored, whole and unmodified.--onlytakes a path relative to the pattern folder, exactly as it appears there. It must be a file the manifest vendors; add any other file with--include. A name the pattern does not vendor is an error that lists the files it does vendor.--onlyvendors nothing it is not given: list the model’s templates, its pvi device file (*.pvi.device.yaml), its autosave request files (*.req) and the protocol files its templates use.--modeltakes the model’sdatabases[].fileentries and itspvi.yaml_pathfrom the support YAML, and those of the models it instantiates throughsub_entities. Each matches the pattern file at that path, or else the one pattern file with that base name; a base name that several pattern files share is an error. A name that matches no file the pattern vendors is not vendored:$(ADCORE)/db/NDStats.templatecomes from the image unless the pattern itself holds anNDStats.template. A name given as a Jinja expression names no single file, so--modelrefuses it; use--only.For each database file
--modelkeeps, it also keeps the autosave request files<stem>_settings.reqand<stem>_positions.reqthat the manifest vendors, whichibek runtime generate-autosavepairs with<stem>.template.--modelalso vendors every protocol file the manifest vendors: each file whose name ends in.protoor.protocol. A pattern with no manifest vendors every file, so this is every protocol file in the pattern. StreamDevice templates name their protocol inside a record link, not in the support YAML, so--modelcannot tell which protocol a model needs, and a manifest has no protocol destination to go by, so protocol files are recognised by suffix.An unknown model is an error that lists the pattern’s models. A pattern whose support YAMLs declare models of one name in two modules needs the model given as
module.name.
Both options can be given more than once, and together: ibek vendors the files
of all of them. They cannot be combined with --exclude. --include works
alongside them, and every file an include rule places is vendored.
The first command records:
version: 4
patterns:
BL21I:
version: 0.4.0
source: github.com/epics-containers/ibek-runtime-support
select:
models:
- TTHBumpstripMonitor
files:
config/BL21I.ibek.support.yaml: sha256:...
config/BL21I_TTH_Bumpstrip_Monitor.template: sha256:...
update resolves models against the release it vendors, so a model whose
template a later release renames still gets the right file. only names files
literally: if a later release removes one, update fails and writes nothing.
restore vendors the same files again.
The support YAML still defines every model of the pattern. An entity whose
model’s database files, or pvi device file when pvi generation is on, were not
vendored fails ibek runtime generate2, naming the model and the
ibek pattern add --model to re-add it with. generate2 checks this when the
instance’s runtime-lock.yaml sits beside its config folder; it warns and
skips the check when it cannot read that lock. It checks only files given as
plain file names, since a path such as $(ADCORE)/db/NDStats.template names a
file in a support module and a Jinja expression names no single file. A file at
the root of the config folder counts as vendored. A plain file name that the
image supplies, rather than the pattern, is reported as missing too; runtime
patterns name only their own files that way. The database files of a disabled
entity, or of a disabled database, are not checked.
How files are chosen#
ibek considers each file in the pattern folder in this order:
It tries the
includerules in order. The first match decides where the file goes, even if the manifest would place the file somewhere else or leave it out.If no
includerule matches, ibek tries the manifest’s rules, also in order. If a manifest rule matches but anexcluderegular expression also matches, ibek does not vendor the file.ibek does not vendor a file that matches none of the rules.
If the selection has
onlyormodels, ibek keeps, of the files the manifest placed, the support YAML and the files they name.
To vendor only a few files from a large pattern, --only and --model are
simplest. Excluding everything and including the files you need also works,
and lets you choose each file’s destination:
ibek pattern add ibek-runtime-streamdevice:CryoconM14@0.6.0 services/my-ioc \
--exclude '.*' \
--include 'CryoconM14\.ibek\.support\.yaml=config' \
--include 'M14\.protocol=config' \
--include 'M14_sensor\.template=config' \
--include 'M14_sensor\.pvi\.device\.yaml=config'
Every part of a selection must have an effect. ibek fails, and writes no files, if any of these is true:
an
includerule matches no file;an
excludeexpression drops no file that the manifest would vendor;after the selection, no files remain to vendor.
The same rule applies on update. If a later pattern version renames or removes
a selected file, update the selection in the same change.
The manifest’s destination rules also apply to a selection. A
*.ibek.support.yaml file must be placed directly under config/, and two
files cannot use the same destination. At boot, ibek runtime place-files uses
only protocol, database and template files placed directly under config/. A
file selected into another folder, such as the simulator above, is vendored and
checked but is not placed in the IOC.
Change or remove a selection#
add records the selection given on its command line and replaces any
selection that the pattern already has. Other patterns in the lock keep their
selections and files. To change a selection, run add again with the complete
new set of options. To remove it, run add with no --include, --exclude,
--only or --model options.
ibek removes the pattern’s files that are no longer in the file-set. This
includes a file or folder the new file-set needs to replace, such as a folder
at config/x.template when the new selection writes a file there. ibek refuses
the change, and writes nothing, if such a file or folder holds anything the
pattern did not vendor.
You can also edit select: in runtime-lock.yaml and run
ibek pattern update. ibek then vendors the files for the edited selection and
removes files that are no longer in the file-set. A lock with a selection must
have version: 2 or above, and one whose selection has only or models must
have version: 4.
Lock versions#
ibek writes the lowest lock version that can hold the lock’s content:
Version |
Adds |
Written when |
|---|---|---|
1 |
|
no later feature is used |
2 |
|
any pattern has a selection |
3 |
top-level |
the lock records a schema URL |
4 |
|
any pattern’s selection has |
Each version is the one before plus its keys, so a lock that uses none of a
version’s keys reads the same to every ibek that reads the lower version, and
ibek rewrites it byte for byte. An ibek that cannot apply a key refuses the
lock with unsupported lock version N. It does not vendor or check a
different file-set from the one recorded. Instances that use a selection need
an ibek that reads its version, including in pre-commit and CI.