Christian Petersen
09/15/2022, 7:56 AMprefect agent start -q 'foo'
for example, Iβd like to create and apply deployments using the Deployment.build_from_flow
syntax described here https://docs.prefect.io/concepts/deployments/#create-a-deployment-from-a-python-object .
Then I want this python script to run before I start the agentβ¦
from prefect.deployments import Deployment
from flows.deployments.example_script import flow_name
deployment = Deployment.build_from_flow(
flow=flow_name,
name="Test",
work_queue_name="test",
)
deployment.apply()
Iβve tried running it standalone and in Docker but I get a Attribute Error module 'flows.deployments.example_script.flow_name' has no attribute 'name'
If I use setattr(flow_name, 'name', 'something)'
before the definition of deployment
then I donβt get this exact error but this ValueError: Could not determine flow's file location.
Iβm unsure of where to begin and would love any sort of helpMathijs Carlu
09/15/2022, 8:27 AMChristian Petersen
09/15/2022, 8:32 AM@task()
decorators, and use these in one function encapsulated by @flow()
python pre-start.py
Mathijs Carlu
09/15/2022, 9:02 AM.
βββ deploy.py
βββ flows
βββ __init__.py
βββ deployments
βββ __init__.py
βββ example_script.py
deploy.py contains the same code as you gave above, example_script looks like this:
from prefect import task, flow
@task
def function_one():
pass
@task
def function_two():
pass
@flow
def flow_name():
function_one()
function_two()
Christian Petersen
09/15/2022, 9:32 AM