https://prefect.io logo
Title
v

Vladislav

09/21/2022, 12:55 PM
Hi! New to prefect, trying to create a deployment locally with Orion UI and flow source code from my pycharm project with conda environment. But every time face the same exception ‘flow could not be retrieved from deployment’. Tried all tips from the chat, e.g. absolute path, but every time get this error + ‘script encountered an exception’. When i run the flow as a python file, everything works fine. I think there is a problem somewhere with deployment
2
j

Jeff Hale

09/21/2022, 1:00 PM
Can you please share a minimum reproducible example with your cli deployment build command and your flow code and file name?
v

Vladislav

09/21/2022, 1:10 PM
prefect deployment build flow.py:snowflake_lte_process
prefect deployment apply snowflake_lte_process-deployment.yaml
prefect agent start -q 'default'
Then the flow appears in deployment, but i can’t run the deployment nether via prefect cli nor via the UI ’Run” button in orion. All files are stored in the same project folder. I can share the flow code but can the code be an issue here? Because running it s a python file works fine, terminal returns ‘all states completed’
j

Jeff Hale

09/21/2022, 1:12 PM
What version of Prefect are you using?
v

Vladislav

09/21/2022, 1:13 PM
2.4.0
https://github.com/PrefectHQ/prefect/pull/6554 probably the clue is somewhere here? May be it’s not possible to run the flow from local file system and i always need a remote storage?
j

Jeff Hale

09/21/2022, 1:32 PM
The CLI command that you shared to build the flow doesn’t use any remote storage, so if the flow is showing up in the local Orion server UI - I assume that’s what you mean by “the flow appears in deployment” and you are using the local Orion server UI to manually run a flow and you have an agent running for the default work queue, it should work. Nothing is jumping out at me as to why it wouldn’t work. Is your deployment yaml file in the same folder as your flow.py file?
v

Vladislav

09/21/2022, 1:33 PM
yes
j

Jeff Hale

09/21/2022, 1:37 PM
I have a thought- try renaming your flow.py file and rebuilding/applying (you can make those one step with
-a
flag on the build command if you like). I think naming the file flow.py might be messing up the import of the flow.
v

Vladislav

09/21/2022, 1:40 PM
thanks a lot. i’ll try again and share the results later!
👍 1
It seems that the problem was in the flow.py file - i called the function decorated with the
@flow
at the end of the file (as i’ve seen in examples), smth like
``@flow`
def final_function():
final_function()
I don’t know why, but removing the function call helped. Thanks for your help, Jeff!!!
🎉 1
j

Jeff Hale

09/21/2022, 3:58 PM
Good to hear! Putting the function call into an
if __name__ =='__main__':
block would also fix, then, probably.
🙌 1