Robert Banick
08/22/2023, 1:07 PMMarvin
08/22/2023, 1:08 PMRobert Banick
08/22/2023, 1:12 PMprefect.deployments.deployments
the available code seems tailored to agents; I am looking for Python API code that interacts well with workers and ideally examples of such code in action.Marvin
08/22/2023, 1:13 PMrun_deployment
function.
python
from prefect.deployments import run_deployment
def main():
response = run_deployment(name="flow-name/deployment-name")
print(response)
if __name__ == "__main__":
main()
In this example, run_deployment
is used to create a flow run from a deployment. The name
parameter should be the name of your flow/deployment.
You'll need to configure agents and work pools that can create flow runs for deployments in remote environments. PREFECT_API_URL
must be set for the environment in which your agent is running. If you want the agent to communicate with Prefect Cloud from a remote execution environment such as a VM or Docker container, you must configure PREFECT_API_URL
in that environment.
When you've configured deployment.yaml
for a deployment, you can create the deployment on the API by running the prefect deployment apply
Prefect CLI command.
bash
$ prefect deployment apply catfacts_flow-deployment.yaml
In this example, prefect deployment apply
is used to create a deployment from a deployment.yaml
file. The catfacts_flow-deployment.yaml
is just an example name for the yaml file.
Once the deployment has been created, you'll see it in the Prefect UI and can inspect it using the CLI.
bash
$ prefect deployment ls
In this example, prefect deployment ls
is used to list all deployments.
I hope this helps, and remember, even in the vastness of the universe, your question matters... to someone, I'm sure.Nate
08/22/2023, 3:05 PMRobert Banick
08/22/2023, 3:06 PMNate
08/22/2023, 3:06 PMcan’t really transition to workers until that’s upcould I ask why? just out of curiosity / for the data point
Robert Banick
08/22/2023, 3:10 PMNate
08/22/2023, 3:12 PMRobert Banick
08/22/2023, 3:21 PMNate
08/22/2023, 3:29 PMpull
steps are great for arbitrary runtime setup (inject a bunch of sensitive env with a script maybe)
• as a work pool creator (devops / admin etc), you can do things like enforce a finite set of values on infra fields / set custom and template-able defaults for deployment creators, in same vein as
It configures most elements of the deployment automatically• (not the most public concept but) all those deployment steps like
prefect.deployments.steps.run_shell_script
are just fully qualified function names, which means, you can just write your own steps if you want to like my_org.deployments.steps.retrieve_vault_secrets
or somethingRobert Banick
08/22/2023, 3:42 PMNate
08/22/2023, 3:42 PMRobert Banick
08/22/2023, 3:42 PMNate
08/22/2023, 3:43 PMMarvin
08/22/2023, 3:44 PMRobert Banick
08/22/2023, 3:45 PM