Rob_C
01/28/2025, 4:41 PMMarvin
01/28/2025, 4:41 PMreceive_input
and send_input
functions. These allow your flow to pause and wait for user input from Prefect's UI. You can define the expected input type using built-in types, pydantic.BaseModel
, or prefect.input.RunInput
classes. This flexibility allows you to dynamically build the input type based on data retrieved from a database.
For more detailed guidance, you can refer to the Prefect documentation on interactive workflows.
If you have a specific scenario or further questions, feel free to ask!Rob_C
01/28/2025, 4:45 PMMarvin
01/28/2025, 4:45 PMRunInput
class. This allows you to define custom input types and even provide default values for fields. Here's a basic example:
python
from prefect import flow, get_run_logger
from prefect.input import RunInput
class UserInput(RunInput):
name: str
age: int
@flow
async def greet_user():
logger = get_run_logger()
user_input = await pause_flow_run(wait_for_input=UserInput.with_initial_data(name="anonymous"))
if user_input.name == "anonymous":
<http://logger.info|logger.info>("Hello, stranger!")
else:
<http://logger.info|logger.info>(f"Hello, {user_input.name}!")
In this example, the flow pauses and waits for user input. The UserInput
class is used to define the expected input fields, and with_initial_data
sets default values.
For more details, you can refer to the Prefect 2.x guide on interactive workflows.Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.
Powered by