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

build_events(beamline, events_cfg)

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.

describe_events(entries)

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).

parse_type(expression)

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

EventEntry(method, role, signal, sender, ...)

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: object

One resolved events: entry. args_adapter validates a whole positional-args tuple; it (and args) are None when the entry doesn’t declare args.

Parameters:
  • method (str)

  • role (str)

  • signal (str)

  • sender (Any)

  • args (Tuple[str, ...] | None)

  • args_adapter (TypeAdapter | None)

check_args(args: Tuple[Any, ...]) → None[source]

Log a warning if args doesn’t match the declared types.

Parameters:

args (Tuple[Any, ...])

Return type:

None

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.

Parameters:
Return type:

Dict[str, EventEntry]

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).

Parameters:

entries (Dict[str, EventEntry])

Return type:

Dict[str, Dict[str, Any]]

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.

Parameters:

expression (str)

Return type:

Any