prefect.input.run_input
This module contains functions that allow sending type-checked RunInput
data
to flows at runtime. Flows can send back responses, establishing two-way
channels with senders. These functions are particularly useful for systems that
require ongoing data transfer or need to react to input quickly.
real-time interaction and efficient data handling. It’s designed to facilitate
dynamic communication within distributed or microservices-oriented systems,
making it ideal for scenarios requiring continuous data synchronization and
processing. It’s particularly useful for systems that require ongoing data
input and output.
The following is an example of two flows. One sends a random number to the
other and waits for a response. The other receives the number, squares it, and
sends the result back. The sender flow then prints the result.
Sender flow:
Functions
keyset_from_paused_state
- state
: the state to get the keyset for
keyset_from_base_key
- base_key
: the base key to get the keyset for
-
- Dict[str, str]: the keyset
run_input_subclass_from_type
RunInput
subclass from the given type.
send_input
receive_input
Classes
RunInputMetadata
BaseRunInput
Methods:
keyset_from_type
load
- keyset
: the keyset to load the input for- flow_run_id
: the flow run ID to load the input for
load_from_flow_run_input
- flow_run_input
: the flow run input to load the input for
metadata
respond
save
- keyset
: the keyset to save the input for- flow_run_id
: the flow run ID to save the input for
send_to
with_initial_data
RunInput
subclass with the given initial data as field
defaults.
Args:
- description
: a description to show when resuming a flow run that requires input- kwargs
: the initial data to populate the subclass
RunInput
Methods:
keyset_from_type
load
- keyset
: the keyset to load the input for- flow_run_id
: the flow run ID to load the input for
load_from_flow_run_input
- flow_run_input
: the flow run input to load the input for
metadata
receive
respond
save
- keyset
: the keyset to save the input for- flow_run_id
: the flow run ID to save the input for
send_to
subclass_from_base_model_type
RunInput
subclass from the given pydantic.BaseModel
subclass.
Args:
- model_cls
: the class from which to create the newRunInput
subclass
with_initial_data
RunInput
subclass with the given initial data as field
defaults.
Args:
- description
: a description to show when resuming a flow run that requires input- kwargs
: the initial data to populate the subclass
AutomaticRunInput
Methods:
keyset_from_type
load
- keyset
: the keyset to load the input for- flow_run_id
: the flow run ID to load the input for
load
- keyset
: the keyset to load the input for- flow_run_id
: the flow run ID to load the input for
load_from_flow_run_input
- flow_run_input
: the flow run input to load the input for
metadata
receive
respond
save
- keyset
: the keyset to save the input for- flow_run_id
: the flow run ID to save the input for
send_to
subclass_from_type
AutomaticRunInput
subclass from the given type.
This method uses the type’s name as a key prefix to identify related
flow run inputs. This helps in ensuring that values saved under a type
(like List[int]) are retrievable under the generic type name (like “list”).
with_initial_data
RunInput
subclass with the given initial data as field
defaults.
Args:
- description
: a description to show when resuming a flow run that requires input- kwargs
: the initial data to populate the subclass