I have a flow that periodically checks a $thing fo...
# ask-community
s
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?
Copy 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
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
that's perfect. thank you very much.
🤘 1