LocalProcess Class
A local process that contains a collection of steps.
Note: This class is marked as 'experimental' and may change in the future.
Initializes the local process.
Constructor
LocalProcess(*, kernel: Kernel, step_info: KernelProcessStepInfo, outgoing_event_queue: Queue[LocalEvent] = None, initialize_task: bool | None = False, event_namespace: str, step_state: KernelProcessStepState, inputs: dict[str, dict[str, Any | None]] = None, initial_inputs: dict[str, dict[str, Any | None]] = None, functions: dict[str, KernelFunction] = None, output_edges: dict[str, list[KernelProcessEdge]] = None, parent_process_id: str | None = None, init_lock: Lock = None, factories: dict[str, Callable])
Keyword-Only Parameters
| Name | Description |
|---|---|
|
kernel
Required
|
|
|
step_info
Required
|
|
|
outgoing_event_queue
Required
|
|
|
initialize_task
Required
|
|
|
event_namespace
Required
|
|
|
step_state
Required
|
|
|
inputs
Required
|
|
|
initial_inputs
Required
|
|
|
functions
Required
|
|
|
output_edges
Required
|
|
|
parent_process_id
Required
|
|
|
init_lock
Required
|
|
|
factories
Required
|
|
Methods
| dispose |
Clean up resources. |
| enqueue_external_messages |
Processes external events that have been sent to the process. |
| enqueue_step_messages |
Processes events emitted by the given step and enqueues them. |
| ensure_initialized |
Ensures the process is initialized lazily (synchronously). |
| get_process_info |
Gets the process information. |
| handle_message |
Handles a LocalMessage that has been sent to the process. |
| initialize_process |
Initializes the input and output edges for the process and initializes the steps. |
| initialize_step |
Initializes the step. |
| internal_execute |
Internal execution logic for the process. |
| run_once |
Starts the process with an initial event and waits for it to finish. |
| send_message |
Sends a message to the process. |
| start |
Starts the process with an initial event. |
| stop |
Stops a running process. |
| to_kernel_process |
Builds a KernelProcess from the current LocalProcess. |
| to_kernel_process_step_info |
Extracts the current state of the step and returns it as a KernelProcessStepInfo. |
dispose
Clean up resources.
dispose()
enqueue_external_messages
Processes external events that have been sent to the process.
enqueue_external_messages(message_channel: Queue[LocalMessage])
Parameters
| Name | Description |
|---|---|
|
message_channel
Required
|
|
enqueue_step_messages
Processes events emitted by the given step and enqueues them.
async enqueue_step_messages(step: LocalStep, message_channel: Queue[LocalMessage])
Parameters
| Name | Description |
|---|---|
|
step
Required
|
|
|
message_channel
Required
|
|
ensure_initialized
Ensures the process is initialized lazily (synchronously).
ensure_initialized()
get_process_info
Gets the process information.
async get_process_info() -> KernelProcess
handle_message
Handles a LocalMessage that has been sent to the process.
async handle_message(message: LocalMessage)
Parameters
| Name | Description |
|---|---|
|
message
Required
|
|
initialize_process
Initializes the input and output edges for the process and initializes the steps.
initialize_process()
initialize_step
Initializes the step.
async initialize_step()
internal_execute
Internal execution logic for the process.
async internal_execute(max_supersteps: int = 100, keep_alive: bool = True)
Parameters
| Name | Description |
|---|---|
|
max_supersteps
|
Default value: 100
|
|
keep_alive
|
Default value: True
|
run_once
Starts the process with an initial event and waits for it to finish.
async run_once(process_event: KernelProcessEvent)
Parameters
| Name | Description |
|---|---|
|
process_event
Required
|
|
send_message
Sends a message to the process.
async send_message(process_event: KernelProcessEvent)
Parameters
| Name | Description |
|---|---|
|
process_event
Required
|
|
start
Starts the process with an initial event.
async start(keep_alive: bool = True)
Parameters
| Name | Description |
|---|---|
|
keep_alive
|
Default value: True
|
stop
Stops a running process.
async stop()
to_kernel_process
Builds a KernelProcess from the current LocalProcess.
async to_kernel_process() -> KernelProcess
to_kernel_process_step_info
Extracts the current state of the step and returns it as a KernelProcessStepInfo.
async to_kernel_process_step_info() -> KernelProcessStepInfo
Attributes
external_event_queue
external_event_queue: Queue
factories
factories: dict[str, Callable]
initialize_task
initialize_task: bool | None
is_experimental
is_experimental = True
kernel
kernel: Kernel
process
process: KernelProcess
process_task
process_task: Task | None
stage_status
stage_status = 'experimental'
step_infos
step_infos: list[KernelProcessStepInfo]
steps
steps: list[LocalStep]