Sam Werbalowsky
01/25/2022, 4:57 PMMy Flow - today - today
rather than creating the date range
start_date = Parameter("start_date", default="today")
end_date = Parameter("end_date", default="today")
# this function handles parameter typing and converts today to YYYY-MM-DD
start_date_str = get_date_param_as_string.run(start_date)
end_date_str = get_date_param_as_string.run(end_date)
create_flow_run(
run_name=f"My Flow - {start_date_str.run()}-{end_date_str.run()}",
flow_name="My Flow Name",
project_name=prefect_project,
parameters={"start_date": start_date, "end_date": end_date, "file_type": "file_type"},
)
Kevin Kho
.run()
on the get_param_date
as string? If you do this, I think it will execute during build time instead of runtimeSam Werbalowsky
01/25/2022, 5:01 PMMy Flow - <task: get_param_data_as_string> ….
but I don’t recall exactly whySam Werbalowsky
01/25/2022, 5:01 PMcreate_flow_run
but not in the parameter handling prior to that?Kevin Kho
Sam Werbalowsky
01/25/2022, 5:06 PMKevin Kho
Sam Werbalowsky
01/25/2022, 5:15 PM@task
def get_flow_name(start_date, end_date):
return f'My Flow = {start_date} - {end_date}'
with Flow as flow:
start_date = Param(....)
end_date = Param(....)
flow_name = get_flow_name(start_date, end_date)
create_flow_run(name=flow_name)
Sam Werbalowsky
01/25/2022, 5:15 PMKevin Kho
Sam Werbalowsky
01/25/2022, 5:20 PMKevin Kho
@flow
decorator