Hello - has anyone successfully been able to pass ...
# ask-community
s
Hello - has anyone successfully been able to pass parameter names into a flow name? I am trying to schedule a flow of flows by doing the following within a flow, but it always creates a flow titled
My Flow - today - today
rather than creating the date range
Copy code
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"},
    )
k
Why are you calling
.run()
on the
get_param_date
as string? If you do this, I think it will execute during build time instead of runtime
s
I think that without that it was showing
My Flow - <task: get_param_data_as_string> ….
but I don’t recall exactly why
Do I want run in the
create_flow_run
but not in the parameter handling prior to that?
k
So f-strings are also evaluated immediately so it you need an expression evaluated as runtime, it should be a task output
s
ok let me try removing the runs and I’ll post what happens
k
You want an intermediate task to construct the run name
s
oh interesting - okay so something like
Copy code
@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)
?
k
Yes exactly
s
cool, thanks, I’ll give it a shot…appreciate the help and promptness as always. There are many gotchas like this, where a very small task is needed. Is this something that Orion addresses by using more native python?
k
I believe so because it’s evaluated at run time inside the
@flow
decorator