schemas
Provides schemas used in Plugboard.
This includes:
- Pydantic models for specifying Plugboard objects;
TypeDictdefinitions for constructor**kwargs.
Direction
module-attribute
A type for the direction of optimisation.
ParameterSpec
module-attribute
A union type for all parameter specifications.
CategoricalParameterSpec
Bases: BaseFieldSpec
Specification for a categorical parameter.
See: https://docs.ray.io/en/latest/tune/api/search_space.html.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
Literal['ray.tune.choice']
|
The type of the parameter. |
categories |
list[Any]
|
The categories of the parameter. |
ComponentArgsDict
ComponentArgsSpec
Bases: PlugboardBaseModel
Specification of the Component constructor arguments.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The name of the |
initial_values |
dict[str, Any]
|
Initial values for the |
parameters |
dict[str, Any]
|
Parameters for the |
constraints |
dict[str, Any]
|
Constraints for the |
resources |
Resource | None
|
Resource requirements for the |
ComponentSpec
Bases: PlugboardBaseModel
Specification of a Component.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
str
|
The type of the |
args |
ComponentArgsSpec
|
The arguments for the |
ConfigSpec
Bases: PlugboardBaseModel
Configuration for a Plugboard simulation.
Attributes:
| Name | Type | Description |
|---|---|---|
plugboard |
ProcessConfigSpec
|
A |
ConnectorBuilderArgsDict
ConnectorBuilderArgsSpec
Bases: PlugboardBaseModel
Specification of the Connector constructor arguments.
Attributes:
| Name | Type | Description |
|---|---|---|
parameters |
dict[str, Any]
|
Parameters for the |
ConnectorBuilderSpec
Bases: PlugboardBaseModel
Specification of a ConnectorBuilder.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
str
|
The type of the |
args |
ConnectorBuilderArgsSpec
|
Optional; The arguments for the |
ConnectorMode
Bases: StrEnum
Defines the mode of a connector.
Attributes:
| Name | Type | Description |
|---|---|---|
PIPELINE |
one-in-one-out task queue. |
|
PUBSUB |
one-to-many event distribution. |
ConnectorSocket
Bases: PlugboardBaseModel
ConnectorSocket defines a source or target connection point on a Connector.
There are two typical types of connections in use: those between attributes of components;
and those connecting components with events which they either emit or consume. When connecting
two component attributes together, the entity is the name of the component, and the
descriptor is the name of the attribute. When connecting components with events, the entity
is the name of the event, and the descriptor is either "publishers" or "subscribers" as
appropriate.
Attributes:
| Name | Type | Description |
|---|---|---|
entity |
str
|
The name of the entity. |
descriptor |
str
|
The name of the descriptor on the entity. |
ConnectorSpec
Bases: PlugboardBaseModel
ConnectorSpec defines a connection between two entities.
Attributes:
| Name | Type | Description |
|---|---|---|
source |
ConnectorSocket
|
The source endpoint. |
target |
ConnectorSocket
|
The target endpoint. |
mode |
ConnectorMode
|
The mode of the connector. |
Entity
FloatParameterSpec
Bases: BaseFieldSpec
Specification for a uniform float parameter.
See: https://docs.ray.io/en/latest/tune/api/search_space.html.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
Literal['ray.tune.uniform']
|
The type of the parameter. |
lower |
float
|
The lower bound of the parameter. |
upper |
float
|
The upper bound of the parameter. |
IODirection
IntParameterSpec
Bases: BaseFieldSpec
Specification for a uniform integer parameter.
See: https://docs.ray.io/en/latest/tune/api/search_space.html.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
Literal['ray.tune.randint']
|
The type of the parameter. |
lower |
int
|
The lower bound of the parameter. |
upper |
int
|
The upper bound of the parameter. |
ObjectiveSpec
Bases: BaseFieldSpec
Specification for an objective field.
OptunaSpec
Bases: PlugboardBaseModel
Specification for the Optuna configuration.
See: https://docs.ray.io/en/latest/tune/api/doc/ray.tune.search.optuna.OptunaSearch.html and https://optuna.readthedocs.io/en/stable/reference/index.html for more information on the Optuna configuration.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
Literal['ray.tune.search.optuna.OptunaSearch']
|
The algorithm type to load. |
space |
str | None
|
Optional; A function defining the search space. Use this to define more complex
search spaces that cannot be represented using the built-in parameter types.
The function must accept a |
study_name |
str | None
|
Optional; The name of the study. |
storage |
str | None
|
Optional; The storage URI to save the optimisation results to. |
points_to_evaluate |
list[dict[str, Any]] | None
|
Optional; A list of initial parameter configurations to evaluate first. Each entry is a dict mapping parameter full names to values. Useful for providing a warm start when exploring large or heavily constrained search spaces. |
PlugboardBaseModel
Bases: BaseModel, ABC
Custom base model for Plugboard schemas.
ProcessArgsDict
ProcessArgsSpec
Bases: PlugboardBaseModel
Specification of the Process constructor arguments.
Attributes:
| Name | Type | Description |
|---|---|---|
components |
Annotated[list[ComponentSpec], Len(min_length=1)]
|
Specifies each |
connectors |
list[ConnectorSpec]
|
Specifies the connections between each |
name |
Optional[str]
|
Unique identifier for |
parameters |
dict[str, Any]
|
Parameters for the |
state |
StateBackendSpec
|
Optional; Specifies the |
ProcessConfigSpec
Bases: PlugboardBaseModel
A ProcessSpec within a Plugboard configuration.
Attributes:
| Name | Type | Description |
|---|---|---|
process |
ProcessSpec
|
A |
tune |
TuneSpec | None
|
Optional; A |
ProcessSpec
Bases: PlugboardBaseModel
Specification of a Plugboard Process.
Attributes:
| Name | Type | Description |
|---|---|---|
args |
ProcessArgsSpec
|
The arguments for the |
type |
Literal['plugboard.process.LocalProcess', 'plugboard.process.RayProcess']
|
The type of |
connector_builder |
ConnectorBuilderSpec
|
The |
override_process_type
Override the process type and update connector/state to be compatible.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
process_type
|
Literal['local', 'ray']
|
The process type to use ("local" or "ray") |
required |
Returns:
| Type | Description |
|---|---|
Self
|
A new ProcessSpec with the overridden process type and compatible settings |
Resource
Bases: PlugboardBaseModel
Resource requirements for a component.
Supports specification of CPU, GPU, memory, and custom resources. Values can be specified as numbers or strings with units (e.g., "250m" for 0.25, "10Mi" for 10 * 1024 * 1024).
Attributes:
| Name | Type | Description |
|---|---|---|
cpu |
float
|
CPU requirement (default: 0.001). |
gpu |
float
|
GPU requirement (default: 0). |
memory |
int
|
Memory requirement in bytes as an integer (default: 0). |
resources |
dict[str, float]
|
Custom resource requirements as a dictionary. |
StateBackendArgsDict
StateBackendArgsSpec
Bases: PlugboardBaseModel
Specification of the StateBackend constructor arguments.
Attributes:
| Name | Type | Description |
|---|---|---|
job_id |
Optional[str]
|
The unique id for the job. |
metadata |
dict[str, Any]
|
Metadata for a run. |
StateBackendSpec
Bases: PlugboardBaseModel
Specification of a Plugboard StateBackend.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
str
|
The type of the |
args |
StateBackendArgsSpec
|
The arguments for the |
Status
Bases: StrEnum
Status describes the status of either a Component or a Process.
Attributes:
| Name | Type | Description |
|---|---|---|
CREATED |
The |
|
INIT |
The |
|
RUNNING |
The |
|
WAITING |
The |
|
COMPLETED |
The |
|
FAILED |
The |
|
STOPPED |
The |
TuneArgsDict
TuneArgsSpec
Bases: PlugboardBaseModel
Specification of the arguments for the Tune class.
Attributes:
| Name | Type | Description |
|---|---|---|
objective |
ObjectiveSpec | list[ObjectiveSpec]
|
The location of the objective(s) to optimise for in the |
parameters |
list[ParameterSpec]
|
The parameters to optimise over. |
num_samples |
PositiveInt
|
The number of samples to draw during the optimisation. |
mode |
Direction | list[Direction]
|
The mode of optimisation. For multi-objective optimisation, this should be a list containing a direction for each objective. |
max_concurrent |
PositiveInt | None
|
The maximum number of concurrent trials. |
algorithm |
Union[OptunaSpec]
|
The algorithm to use for the optimisation. |
TuneSpec
Bases: PlugboardBaseModel
Configuration for an optimisation job.
Attributes:
| Name | Type | Description |
|---|---|---|
args |
TuneArgsSpec
|
The arguments for the |
simple_cycles
Find all simple cycles in a directed graph using Johnson's algorithm.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
dict[str, set[str]]
|
A dictionary mapping each vertex to a set of its neighbours. |
required |
Yields:
| Type | Description |
|---|---|
list[str]
|
Each elementary cycle as a list of vertices. |
validate_all_inputs_connected
Check that all component inputs are connected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
process_dict
|
dict[str, Any]
|
The output of |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
List of error messages for unconnected inputs. |
validate_input_events
Check that all components with input events have a matching output event producer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
process_dict
|
dict[str, Any]
|
The output of |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
List of error messages for unmatched input events. |
validate_no_unresolved_cycles
Check for circular connections that are not resolved by initial values.
Circular loops are only valid if there are initial_values set on an
appropriate component input within the loop.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
process_dict
|
dict[str, Any]
|
The output of |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
List of error messages for unresolved circular connections. |
validate_process
Run all registered validators against the given process.
New validators are picked up automatically via the @validator
decorator; this function never needs to be modified directly.
validator
Decorator: register func as a process validator.
Validators are called in registration order when validate_process
is invoked. Raise an exception inside the validator to signal an
invalid process.
Example::
@validator
def check_no_cycles(connectors: ConnectorMap) -> None:
if cycles := _find_cycles(connectors):
raise ValueError(f"Cycle detected involving: {cycles}")