https://prefect.io logo
#prefect-community
Title
# prefect-community
l

Lee Briggs

03/25/2022, 9:27 PM
still wrapping my head around some concepts here, so bear with me. I've got a a working prototype up and running which uses a flask webapp to dispatch flows to prefect cloud. Currently, I'm seeding the data (ie the tasks and flows to run) with a "bootstrap" script that needs to run before the webapp is launched, but I'd like it really to be a "batteries included" experience. How are people generally solving this? I could have a "setup" page in my flask app, but I don't want to get super involved for now
k

Kevin Kho

03/25/2022, 11:19 PM
So your flask webapp can trigger already registered flows if you do:
Copy code
Client().create_flow_run()
or you can even use the GraphQL API with native requests As long as you register already, then you don’t need to send flow and task code. Does that make sense?
l

Lee Briggs

03/26/2022, 4:16 PM
yep, that's basically what I'm doing now. The only thing I'm struggling with is getting the flow id in order to trigger it
k

Kevin Kho

03/26/2022, 4:30 PM
Ahh I see. So you can invoke a task by calling
task.run()
. For example:
Copy code
@task
def abc():
    return 1

abc.run()
This calls the Python under the hood. So I suggest you use the
create_flow_run
built-in task because the inputs are project name and flow name and it finds the id for you to trigger
Docs here. So I suggest
create_flow_run.run(project_name=…,flow_name=…)
l

Lee Briggs

03/26/2022, 4:47 PM
oh man, can't believe I missed that! I've been hardcoding the uuid, I'll read the docs better next time. thank you!
k

Kevin Kho

03/26/2022, 5:56 PM
Oh no worries! This one is not straightforward. You can read the source code of that task too if you want.
7 Views