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

Neil Natarajan

08/24/2022, 4:49 PM
Is there a way to start a prefect agent via code instead of manually using the CLI?
1
s

Sam Garvis

08/24/2022, 4:51 PM
Like using helm in k8s? Or do you mean in Python?
n

Neil Natarajan

08/24/2022, 4:53 PM
in python
I just want to run a simple flow on an interval schedule locally
But I don't want to have manual intervention in the form of starting an agent
Currently, I am able to create the deployment/work-queue via Python API but I do not know how to start an agent via Python API
j

Jean Luciano

08/24/2022, 4:58 PM
Only ways of starting an agent is with the CLI command or a helm chart.
r

Ryan Peden

08/24/2022, 5:05 PM
Although there are no official docs on running an agent via the Python API, the
OrionAgent
class is documented here:https://docs.prefect.io/api-ref/prefect/agent/#prefect.agent.OrionAgent and you can see how the CLI creates an and runs an agent here: https://github.com/PrefectHQ/prefect/blob/main/src/prefect/cli/agent.py#L113 But note that prefect.utilities.services is not a documented part of Prefect's Python API so it may not be safe to count on it working in perpetuity.
👀 1
n

Neil Natarajan

08/24/2022, 5:07 PM
Thanks, I'll take a look
52 Views