mxcubecore.ipc.events¶
The IPCServer’s events: whitelist: which HardwareObject signals are forwarded as IPCEvents, and (optionally) the declared types of their positional arguments.
HardwareObject signals are undeclared - self.emit(“valueChanged”, value) can pass anything - so unlike a whitelisted method, an event’s payload can’t be introspected. Each events: entry may therefore declare it explicitly, one Python type expression per positional signal argument:
- role: diffractometer.omega
signal: valueChanged
method: diffractometer.omega.valueChanged
args: [float]
args is turned into a JSON schema (via pydantic’s TypeAdapter, like a method’s response_schema) and published through _describe, and every emission is checked against it - a mismatch is logged as a warning (the event is still forwarded), so the declaration can’t silently drift from what the HardwareObject actually emits. Entries without args are forwarded unchanged and described with args_schema: null.
See IPC_FORMAT.md section 5.
Functions
|
Resolve and validate the configured events: list once at IPCServer startup, failing fast like build_whitelist(): an unresolvable role, an invalid args declaration, or two entries sharing a method name raises IPCWhitelistError immediately. |
|
The events half of _describe: per forwarded event, where it comes from and the JSON schema of its params.args (null if the entry doesn't declare args). |
|
Turn a config type expression ("float", "Optional[float]", "dict[str, Any]", "int | None", "mxcubecore.model.foo.Bar", ...) into the type it names - without eval(): only the names in _TYPE_NAMES and fully-qualified importable paths are accepted. |
Classes
|
One resolved events: entry. |
- class mxcubecore.ipc.events.EventEntry(method: str, role: str, signal: str, sender: Any, args: Tuple[str, ...] | None, args_adapter: TypeAdapter | None)[source]¶
Bases:
objectOne resolved events: entry. args_adapter validates a whole positional-args tuple; it (and args) are None when the entry doesn’t declare args.
- Parameters:
- mxcubecore.ipc.events.build_events(beamline: Any, events_cfg: List[Dict[str, Any]]) Dict[str, EventEntry][source]¶
Resolve and validate the configured events: list once at IPCServer startup, failing fast like build_whitelist(): an unresolvable role, an invalid args declaration, or two entries sharing a method name raises IPCWhitelistError immediately.
- mxcubecore.ipc.events.describe_events(entries: Dict[str, EventEntry]) Dict[str, Dict[str, Any]][source]¶
The events half of _describe: per forwarded event, where it comes from and the JSON schema of its params.args (null if the entry doesn’t declare args).
- mxcubecore.ipc.events.parse_type(expression: str) Any[source]¶
Turn a config type expression (“float”, “Optional[float]”, “dict[str, Any]”, “int | None”, “mxcubecore.model.foo.Bar”, …) into the type it names - without eval(): only the names in _TYPE_NAMES and fully-qualified importable paths are accepted.