Hi! New to prefect, trying to create a deployment ...
# prefect-community
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
Can you please share a minimum reproducible example with your cli deployment build command and your flow code and file name?
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’
What version of Prefect are you using?
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?
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?
I have a thought- try renaming your flow.py file and rebuilding/applying (you can make those one step with
flag on the build command if you like). I think naming the file flow.py might be messing up the import of the flow.
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
at the end of the file (as i’ve seen in examples), smth like
def final_function():
I don’t know why, but removing the function call helped. Thanks for your help, Jeff!!!
🎉 1
Good to hear! Putting the function call into an
Copy code
if __name__ =='__main__':
block would also fix, then, probably.
🙌 1