jeff n

    jeff n

    1 year ago
    Hello all. I have a flow that can take parameters such as db table and pull data from that table generically. How do I register the same flow to run in prefect cloud with different parameters. For instances the flow pulls from
    projects
    with one set of runs and
    accounts
    with another set of runs but both of the runs are the same flow code and need to run separately.
    nicholas

    nicholas

    1 year ago
    Hi @jeff n - are you running this flow on some sort of schedule or are you planning to run it only ad-hoc?
    jeff n

    jeff n

    1 year ago
    It will be run on a schedule @nicholas
    nicholas

    nicholas

    1 year ago
    Perfect! Prefect has a great way to handle that scenario using varying parameter clocks. So you could do something like this:
    clock1 = clocks.CronClock("1 * * * *", parameter_defaults={"foo": "bar"})
    clock2 = clocks.CronClock("2 * * * *", parameter_defaults={"foo": "batz"})
    
    schedule = Schedule(clocks=[clock1, clock2])
    
    flow.schedule = schedule
    That will let you override any defaults you set on the parameters based on the schedule (and you can kick off ad-hoc runs using the defaults or by passing parameters at any time outside the schedule!)
    jeff n

    jeff n

    1 year ago
    ah ok. Didn’t think of using schedules.
    @nicholas how will that look in the UI? Will it be just 1 flow that has lots of scheduled times?
    nicholas

    nicholas

    1 year ago
    That’s correct @jeff n