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

Mohit Singhal

11/21/2022, 6:27 AM
Hi Everyone, I am not getting how to set "name" parameter in run_deployment. Can anyone please help me here?
From doc I get this name: The deployment name in the form: '<flow-name>/<deployment-name>' now flow-name is the name of parent flow or the flow hich we want to run and what will be there in deployment-name and also I want to try it locally
m

Mohit Singhal

11/21/2022, 6:39 AM
I am not sure
but I am getting below error when I tried giving flow name to be the name of flow which I want to run and deployment-name as "local"
read_deployment_by_name response = await self._client.get(f"/deployments/name/{name}")
raise prefect.exceptions.ObjectNotFound(http_exc=e) from e prefect.exceptions.ObjectNotFound
t

Tim Galvin

11/21/2022, 6:47 AM
Can you share your code as a whole that is creating the error?
m

Mohit Singhal

11/21/2022, 6:50 AM
sure
this is one file
Copy code
from datetime import date
from prefect import flow,task
from prefect.deployments import run_deployment
from prefect_dask.task_runners import DaskTaskRunner
from cust_test import Firstrun






@flow(task_runner=DaskTaskRunner())
@flow(name="testing")
def parent():
    deployment_name: str = "local-process"
    run_deployment(name="test/local-process",flow_run_name="parallel")
    #run_deployment.submit(flow_run_name="parallel")

if __name__ == "__main__":
    parent()
and in cust_test.py
Copy code
from datetime import date
from prefect import flow,task
from prefect.deployments import run_deployment
from prefect_dask.task_runners import DaskTaskRunner

@task()
def e():
    print(12)

@flow(name="test")
def Firstrun():
    e()


if __name__ == "__main__":
    Firstrun()
now hen i am running the first file containing parent flow it is giving me error
h

Howard

11/21/2022, 6:54 AM
Did you build deployment? I just saw flow
m

Mohit Singhal

11/21/2022, 6:54 AM
do we need to build it while running locally as well?
I am new to prefect and don't know
Copy code
from my_project.flows import my_flow
from prefect.deployments import Deployment

deployment = Deployment.build_from_flow(
    flow=my_flow,
    name="example-deployment", 
    version=1, 
    work_queue_name="demo",
)
deployment.apply()
do i need to run above code in .py file
h

Howard

11/21/2022, 7:09 AM
I'm new to prefect too. But I think you should build a deployment, And then run_deployment("FLOWNAME/DEPLOYMENT")
Copy code
# cust_test.py
Copy code
from prefect import flow,task

@task()
def e():
    print(12)

@flow(name="my_flow")
def Firstrun():
    e()


if __name__ == "__main__":
    Firstrun()
Copy code
# dep.py
from cust_test import Firstrun
from prefect.deployments import Deployment, run_deployment

deployment = Deployment.build_from_flow(
    flow=Firstrun,
    name="my_deployment", 
    version=1
)
deployment.apply()
run_deployment("my_flow/my_deployment")
just my opinion
I'm running with a local orion server, actually it's not truly "locally" as you mentioned, so i'm not sure
m

Mohit Singhal

11/21/2022, 7:53 AM
Thanks for your quick reply
will try it at my end
3 Views