s

    Sam Werbalowsky

    8 months ago
    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
    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

    Kevin Kho

    8 months ago
    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

    Sam Werbalowsky

    8 months ago
    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?
    Kevin Kho

    Kevin Kho

    8 months ago
    So f-strings are also evaluated immediately so it you need an expression evaluated as runtime, it should be a task output
    s

    Sam Werbalowsky

    8 months ago
    ok let me try removing the runs and I’ll post what happens
    Kevin Kho

    Kevin Kho

    8 months ago
    You want an intermediate task to construct the run name
    s

    Sam Werbalowsky

    8 months ago
    oh interesting - okay so something like
    @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)
    ?
    Kevin Kho

    Kevin Kho

    8 months ago
    Yes exactly
    s

    Sam Werbalowsky

    8 months ago
    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?
    Kevin Kho

    Kevin Kho

    8 months ago
    I believe so because it’s evaluated at run time inside the
    @flow
    decorator