API#
This is the internal API reference for ibek
ibek
#
- ibek.__version__: str#
Version number as calculated by pypa/setuptools_scm
ibek.globals
#
A few global defintions
- class ibek.globals.T#
A generic Type for use in type hints
alias of TypeVar(‘T’)
ibek.support
#
The Support Class represents a deserialized <MODULE_NAME>.ibek.support.yaml file. It contains a hierarchy of Entity dataclasses.
- class ibek.support.FloatArg(name, description, type='float', default=Undefined)[source]#
An argument with a float value
- class ibek.support.StrArg(name, description, type='str', default=Undefined)[source]#
An argument with a str value
- class ibek.support.IntArg(name, description, type='int', default=Undefined)[source]#
An argument with an int value
- class ibek.support.BoolArg(name, description, type='bool', default=Undefined)[source]#
An argument with an bool value
- class ibek.support.ObjectArg(name, description, type='object', default=Undefined)[source]#
A reference to another entity defined in this IOC
- class ibek.support.IdArg(name, description, type='id', default=Undefined)[source]#
Explicit ID argument that an object can refer to
- class ibek.support.Database(file, include_args=(), define_args='')[source]#
A database file that should be loaded by the startup script and its args
- class ibek.support.EnvironmentVariable(name, value)[source]#
An environment variable that should be set in the startup script
- class ibek.support.Function(name, args, header='', once=False, type='function')[source]#
A script snippet that defines a function to call
- class ibek.support.Once(type='once', value='')[source]#
A script snippet that should for the first occurrence only
- Parameters:
type (Literal) –
value (str) – Startup script snippets defined as Jinja template
- class ibek.support.Value(name, description, value)[source]#
A calculated string value for a definition
- class ibek.support.Definition(name, description, args=(), values=(), databases=(), script=(), env_vars=(), post_ioc_init=())[source]#
A single definition of a class of Entity that an IOC instance may instantiate
- Parameters:
name (str) – Publish Definition as type <module>.<name> for IOC instances
description (str) – Describes the purpose of the definition
args (Sequence) – The arguments IOC instance should supply
values (Sequence) – The values IOC instance should supply
databases (Sequence) – Databases to instantiate
script (Sequence) – Startup script snippets defined as Jinja template or function
env_vars (Sequence) – Environment variables to set in the boot script
post_ioc_init (Sequence) – Entries to add post iocInit(), such as dbpf
- class ibek.support.Support(module, defs)[source]#
Lists the definitions for a support module, this defines what Entities it supports
- Parameters:
module (str) – Support module name, normally the repo name
defs (Sequence) – The definitions an IOC can create using this module
Provides the deserialize entry point.
ibek.ioc
#
Functions for generating an IocInstance derived class from a support module definition YAML file
- class ibek.ioc.Entity[source]#
A baseclass for all generated Entity classes. Provides the deserialize entry point.
- ibek.ioc.make_entity_class(definition: Definition, support: Support) Type[Entity] [source]#
We can get a set of Definitions by deserializing an ibek support module definition YAML file.
This function then creates an Entity derived class from each Definition.
- ibek.ioc.make_entity_classes(support: Support) SimpleNamespace [source]#
Create
Entity
subclasses for allDefinition
objects in the givenSupport
instance, put them in a namespace inibek.modules
and return it
- ibek.ioc.clear_entity_classes()[source]#
Reset the modules namespaces, deserializers and caches of defined Entity subclasses
- class ibek.ioc.IOC(ioc_name, description, entities, generic_ioc_image)[source]#
Used to load an IOC instance entities yaml file into memory using IOC.deserialize(YAML().load(ioc_instance_yaml)).
- Parameters:
Before loading the entities file all Entity classes that it contains must be defined in modules.py. This is achieved by deserializing all support module definitions yaml files used by this IOC and calling make_entity_classes(support_module).
ibek.modules
#
Blank module to be populated with modules, which contain Entity
subclasses
made with make_entity_classes
ibek.render
#
Functions for rendering lines in the boot script using Jinja2
- class ibek.render.Render[source]#
A class for generating snippets of startup script / EPICS DB by using Jinja to combine snippet templates from support module definition yaml with substitution values supplied in ioc entity yaml
- render_text(instance: Entity, text: str, once=False, suffix='') str [source]#
Add in the next line of text, honouring the
once
flag which will only add the line once per IOC.Jinja rendering of values/args has already been done in Entity.__post_init__ but we pass all strings though jinja again to render any other jinja in the IOC (e.g. database and function entries)
once
uses the name of the definition + suffix to track which lines have been rendered already. The suffix can be used where a given Entity has more than one element to render once (e.g. functions)
- render_function(instance: Entity, function: Function) str [source]#
render a Function object that represents a function call in the IOC startup script
- render_script(instance: Entity) str | None [source]#
render the startup script by combining the jinja template from an entity with the arguments from an Entity
- render_database(instance: Entity) str | None [source]#
render the lines required to instantiate database by combining the templates from the Entity’s database list with the arguments from an Entity
- render_environment_variables(instance: Entity) str | None [source]#
render the environment variable elements by combining the jinja template from an entity with the arguments from an Entity
- render_post_ioc_init(instance: Entity) str | None [source]#
render the post-iocInit entries by combining the jinja template from an entity with the arguments from an Entity
- render_elements(ioc: IOC, method: Callable[[Entity], str | None]) str [source]#
Render elements of a given IOC instance based on calling the correct method
- render_script_elements(ioc: IOC) str [source]#
Render all of the startup script entries for a given IOC instance
- render_database_elements(ioc: IOC) str [source]#
Render all of the DBLoadRecords entries for a given IOC instance
ibek.utils
#
A class containing utility functions for passing into the Jinja context.
This allows us to provide simple functions that can be called inside Jinja templates with {{ __utils__.function_name() }}. It also allows us to maintain state between calls to the Jinja templates because we pass a single instance of this class into all Jinja contexts.
- class ibek.utils.Counter(start: int, current: int, stop: int)[source]#
Provides the ability to supply unique numbers to Jinja templates
- class apischema.types.UndefinedType#
A sentinel value that allows detection that a value has not been passed at init