I build deployment object using: prefect.deploymen...
# prefect-community
t
I build deployment object using: prefect.deployments.Deployment.build_from_flow(), but this object does not have apply() method? how should I deploy a flow from Python instead of CLI?
1
c
What version of prefect are you using?
t
@Cole Murray Hi Cole, I'm using the 2.2.0
c
Based on the error message, it looks like it is being run in an async context. You might need to call await on the object or alter your code to run in a sync context: https://github.com/PrefectHQ/prefect/blob/main/src/prefect/deployments.py#L469 https://github.com/PrefectHQ/prefect/blob/main/src/prefect/deployments.py#L426 Could you paste any other relevant code?
t
Hi @Cole Murray below are the simple test code i used: import prefect from prefect import flow, task from prefect.deployments import Deployment @flow() def dynamic_parameter(): return 1
a
if you’re running on notebook, you need to do
deployment = await Deployment.build_from_flow()
t
Hi @Andrew Huang, thanks for your response, I got below error with await......
a
I think you’re supposed to run deployments in py scripts, not notebook
t
@Andrew Huang yeah, it works in py script..... anyway, do we no longer have equivalent of flow.register() in Prefect 1.0? That one works perfectly in the notebook.
a
not that I know of. perhaps you can submit an issue to Github as a feature request?
👍 1
t
@Andrew Huang Good idea....sorry i supposed you are of Prefect developer team.
a
XD actually I am (but I don’t work on deployments)
😁 1