https://prefect.io logo
Title
s

Sven Teresniak

07/17/2020, 8:47 AM
I have a flow that periodically checks a $thing for some $state. If the check fails I need to run a registered flow. What is the most elegant way to schedule a flow run from within another flow? Writing a query like the
run.py
from the CLI code?
client = Client()
    result = client.graphql(query)
I don't want to use
prefect run server …
from a shell task. I like it pythonic https://docs.prefect.io/api/latest/client/client.html seems perfect. But it states
Client for communication with Prefect Cloud
On the other hand: prefect CLI uses the
Client
class for non-cloud schedules as well… 🙂
e

emre

07/17/2020, 9:12 AM
Im pretty sure
Client
works with prefect server as well. It’s probably just the documentation that is not updated, since prefect server is a more recent addition than prefect cloud. That being said, check this out: https://docs.prefect.io/api/latest/tasks/prefect.html#flowruntask Implicitly uses the
Client
of your flow to trigger a flow run via graphql.
s

Sven Teresniak

07/17/2020, 9:15 AM
that's perfect. thank you very much.
🤘 1