run_input
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:
Receiver flow:
Functions
keyset_from_paused_state
Get the keyset for the given Paused state.
Args:
-
: the state to get the keyset for
keyset_from_base_key
Get the keyset for the given base key.
Args:
-
: the base key to get the keyset for
Returns:
-
- Dict[str, str]: the keyset
run_input_subclass_from_type
Create a new RunInput
subclass from the given type.
receive_input
Classes
RunInputMetadata
BaseRunInput
Methods:
metadata
keyset_from_type
load_from_flow_run_input
Load the run input from a FlowRunInput object.
Args:
-
: the flow run input to load the input for
with_initial_data
Create a new RunInput
subclass with the given initial data as field
defaults.
Args:
-
: a description to show when resuming a flow run that requires input-
: the initial data to populate the subclass
RunInput
Methods:
receive
subclass_from_base_model_type
Create a new RunInput
subclass from the given pydantic.BaseModel
subclass.
Args:
-
: the class from which to create the newRunInput
subclass
AutomaticRunInput
Methods:
subclass_from_type
Create a new 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”).
receive
GetInputHandler
Methods:
to_instance
GetAutomaticInputHandler
Methods: