Skip to main content

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:
  • - state: the state to get the keyset for

keyset_from_base_key

Get the keyset for the given base key. Args:
  • - base_key: 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.

asend_input

Send input to a flow run asynchronously.

send_input

Send input to a flow run.

receive_input

Classes

RunInputMetadata

BaseRunInput

Methods:

aload

Load the run input response from the given key asynchronously. Args:
  • - keyset: the keyset to load the input for
  • - flow_run_id: the flow run ID to load the input for

arespond

Respond to the sender of this input asynchronously.

asave

Save the run input response to the given key asynchronously. Args:
  • - keyset: the keyset to save the input for
  • - flow_run_id: the flow run ID to save the input for

asend_to

Send this input to a flow run asynchronously.

keyset_from_type

load

Load the run input response from the given key. Args:
  • - 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

Load the run input from a FlowRunInput object. Args:
  • - flow_run_input: the flow run input to load the input for

metadata

respond

Respond to the sender of this input.

save

Save the run input response to the given key. Args:
  • - keyset: the keyset to save the input for
  • - flow_run_id: the flow run ID to save the input for

send_to

Send this input to a flow run.

with_initial_data

Create a new 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:

aload

Load the run input response from the given key asynchronously. Args:
  • - keyset: the keyset to load the input for
  • - flow_run_id: the flow run ID to load the input for

arespond

Respond to the sender of this input asynchronously.

asave

Save the run input response to the given key asynchronously. Args:
  • - keyset: the keyset to save the input for
  • - flow_run_id: the flow run ID to save the input for

asend_to

Send this input to a flow run asynchronously.

keyset_from_type

load

Load the run input response from the given key. Args:
  • - 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

Load the run input from a FlowRunInput object. Args:
  • - flow_run_input: the flow run input to load the input for

metadata

receive

respond

Respond to the sender of this input.

save

Save the run input response to the given key. Args:
  • - keyset: the keyset to save the input for
  • - flow_run_id: the flow run ID to save the input for

send_to

Send this input to a flow run.

subclass_from_base_model_type

Create a new RunInput subclass from the given pydantic.BaseModel subclass. Args:
  • - model_cls: the class from which to create the new RunInput subclass

with_initial_data

Create a new 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:

aload

Load the run input response from the given key asynchronously. Args:
  • - keyset: the keyset to load the input for
  • - flow_run_id: the flow run ID to load the input for

aload

Load the run input response from the given key asynchronously. Args:
  • - keyset: the keyset to load the input for
  • - flow_run_id: the flow run ID to load the input for

arespond

Respond to the sender of this input asynchronously.

asave

Save the run input response to the given key asynchronously. Args:
  • - keyset: the keyset to save the input for
  • - flow_run_id: the flow run ID to save the input for

asend_to

Send this input to a flow run asynchronously.

keyset_from_type

load

Load the run input response from the given key. Args:
  • - keyset: the keyset to load the input for
  • - flow_run_id: the flow run ID to load the input for

load

Load the run input response from the given key. Args:
  • - 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

Load the run input from a FlowRunInput object. Args:
  • - flow_run_input: the flow run input to load the input for

metadata

receive

respond

Respond to the sender of this input.

save

Save the run input response to the given key. Args:
  • - keyset: the keyset to save the input for
  • - flow_run_id: the flow run ID to save the input for

send_to

Send this input to a flow run.

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”).

with_initial_data

Create a new 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

GetInputHandler

Methods:

anext

Get the next input asynchronously.

filter_for_inputs

Filter for inputs asynchronously.

filter_for_inputs_sync

Filter for inputs synchronously.

next

Get the next input.

to_instance

GetAutomaticInputHandler

Methods:

anext

Get the next input asynchronously.

filter_for_inputs

Filter for inputs asynchronously.

filter_for_inputs_sync

Filter for inputs synchronously.

next

Get the next input.

to_instance