Is there a way to start a prefect agent via code i...
# prefect-community
n
Is there a way to start a prefect agent via code instead of manually using the CLI?
1
s
Like using helm in k8s? Or do you mean in Python?
n
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
Only ways of starting an agent is with the CLI command or a helm chart.
r
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
Thanks, I'll take a look