https://prefect.io logo
Title
a

Alfie

07/18/2020, 9:57 AM
Hi folks, I encounter another issue: I’ve created a flow template and register multiple flow instances with different parameters. But I cannot find a way to retrieve back those parameter details from those flows. Anyone can help on it?
n

nicholas

07/18/2020, 3:27 PM
@Alfie can you provide a minimum example of what you’re trying to do that isn’t working?
a

Alfie

07/19/2020, 1:52 AM
Hi @nicholas, I think I had some misunderstanding on the flow, so please ignore the question. I have a flow which can take some parameters, and I can call flow.run() and pass in them, as described in the doc: *prefect.core.flow.Flow.run*(parameters=None, run_on_schedule=None, runner_cls=None, **kwargs) I also want to register the flow in Prefect core with parameters, but I do not figure out how to pass in the parameters via flow.register(). So what’s the correct way to achieve that?
Read more doc, seems parameters should be provided to flow_run but not flow directly. But I do not figure out how to give flow_run a cron schedule. I want each flow_run has it’s own schedule
j

Julian

07/19/2020, 9:49 AM
Here is an example, where a flow runs with 2 schedules (each 5 /20 minutes), each providing a different default parameter. When started with the 5 minute schedule, parameter freq will be set to 5.
clock_5m = clocks.CronClock("*/5 * * * *", parameter_defaults={'frequency': '5'})
    clock_20m = clocks.CronClock("*/20 * * * *", parameter_defaults={'frequency': '20'})
    schedule = Schedule(clocks=[clock_5m, clock_20m])

    with Flow("base_stats", schedule=schedule) as flow:
        freq = Parameter("frequency", required=False)
        bounds = get_time_bounds(freq)

    flow.register()
a

Alfie

07/19/2020, 2:33 PM
thanks @Julian! But you have to define all the possible schedules at first, right? My case needs more flexibility
j

Julian

07/19/2020, 6:00 PM
you can use flows to triger new flow_runs using the FlowRunTask. Actually you can override this Task (maybe this works even with the current version and i didn't figure it out) to start new flows with parameters calculated on runtime
a

Alfie

07/20/2020, 8:53 AM
thanks @Julian