Hi everyone, When I try build deployment I get thi...
# prefect-community
y
Hi everyone, When I try build deployment I get this error:
1
1
RuntimeError: A 'sync_compatible' method was called from a context that was previously async but is now sync. The sync call must be changed to run in a worker thread to support sending the coroutine for 'build_from_flow' to the main thread.
I followed this guide: https://docs.prefect.io/tutorials/deployments/#build-a-deployment-definition Any idea what went wrong? Using prefect 2.3.1 And deployment in scripts looks like this:
Copy code
deployment = Deployment.build_from_flow(
    flow=main,
    name="model_training",
    schedule=IntervalSchedule(interval=timedelta(minutes=5)),
    work_queue_name="ml"
)

deployment.apply()
a
Hi Yusuf! Could you perhaps try using the prefect deployment CLI? way easier, that way you don't have to worry about sync/async - this guide provides many resources to get started https://discourse.prefect.io/t/prefect-deployments-faq/1467
j
If you want to use the Python Deployment file way @yusuf yel, you’re very close. Just pass your interval schedule object to the
schedule
paramater. The work queue name gets passed to
work_queue_name
You can see a guide I wrote here: https://medium.com/the-prefect-blog/deploy-prefect-pipelines-with-python-perfect-68c944a3a89f
👀 1
y
@Jeff Hale Jeff thanks for answering. I can start agent now. But there is another issue which is same issue when I try deployment cli. When I start prefect agent all tasks and flow runs without any error but mlflow artifacts doesn't saves relative path artifacts. I don't think issue was mlflow because I have task which cleans previous mlflow artifacts. That tasks doesn't excute either. Here is my flow and path task.: Edit: I can run my script as regular python file and mlflow artifacts saves like expected.
1
@Anna Geller Thanks for pointing deployment cli. apparently I got all wrong. I was trying deployment in python file and deployment cli. I understand now I got two option for deployment. Thanks.
👍 1
a
Ahh that's indeed a bit confusing, maybe we can make it clearer in the docs, great that you figured it out!
🙌 2