Compiler¶
InvocationNode carries an invocation's semantics and is identified by its
node_id. Its create_id method derives the ID from the function, profile,
operator, and binding role. Node equality and hashing use only the ID.
InvocationGraph orders nodes using the supplied dependency IDs.
InvocationSemanticsBuilder.build derives contracts for one operator.
Compiler creates operator invocations, indexes their publishers, and resolves
their dependencies before selecting and scheduling the graph. Its
invocation_graph method returns the complete graph or a feature-selected graph.
Compile a loaded Spec into a portable execution plan.
Compiler
¶
Own Spec-to-plan strategy without retaining build state.
The compiler expands operators into invocations, resolves dependencies, selects a graph, and determines its schedule. Semantic contracts are derived separately from the Spec.
compile
¶
compile(spec_definition: Spec, features: Collection[str] | None = None, *, signatures: Mapping[str, Signature] | None = None, validate_spec: bool = True) -> plan.ExecutionPlan
Compile a Spec by creating, selecting, scheduling, and serializing its invocations.
Semantic resolution supplies invocation contracts. The compiler resolves their dependencies, then the generic invocation graph supplies the schedule. Plan models validate the resulting portable invocations and stages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec_definition
|
Spec
|
The Spec document to compile. |
required |
features
|
Collection[str] | None
|
Optional collection of output feature identifiers. |
None
|
signatures
|
Mapping[str, Signature] | None
|
Optional return signatures inspected before compilation. |
None
|
validate_spec
|
bool
|
Whether to validate the Spec during compilation. If false, the caller must provide an already validated Spec. |
True
|
Returns:
| Type | Description |
|---|---|
ExecutionPlan
|
A portable execution plan for the selected invocation graph. |
Raises:
| Type | Description |
|---|---|
ValueError
|
The Spec, feature selection, or implementation contract is invalid. |
invocation_graph
classmethod
¶
invocation_graph(spec_definition: Spec, features: Collection[str] | None = None) -> invocation_graph.InvocationGraph
Build the compiler's invocation dependency graph for a Spec and selection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec_definition
|
Spec
|
Spec containing the operator bindings. |
required |
features
|
Collection[str] | None
|
Optional collection of output feature identifiers. |
None
|
Returns:
| Type | Description |
|---|---|
InvocationGraph
|
The invocation dependency graph, restricted to the selected features if provided. |
Raises:
| Type | Description |
|---|---|
ValueError
|
The feature selection is invalid. |