<post_deployment.py>
from prefect.deployments import Deployment
from src.flows import test_flow
my_deployment = Deployment.build_from_flow(
flow=test_flow,
name="Test",
work_queue_name=Test,
description="Important:\n"
)
my_deployment.apply()
I am on windows machine. When I run python post_deployment.py , it posts the deployment at server, I am using local postgres as server database. So far so good. As soon as I run the flow from UI, I get following error.
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\USER\\AppData\\Local\\Temp\\tmp8dz374otprefect\\containers\\prefect-agent\\src\\flows\\test_flow.py'
prefect.exceptions.ScriptError: Script at 'containers\\prefect-agent\\src\\flows\\vessel_notification.py'
My src\ and post.deployment.py folder are in same directory.
Project_dir
|
----src/
-----flow
------testflow.py
----post_deployment.py
when I debug I see following value under my deployment
Not sure why it is trying to locate the file C:\\Users\\USER\\AppData\\Local\\Temp\\tmp8dz374otprefect instead of getting from path variable set in deployment
Please help!!
Have you set up an environment variable for Prefect Home? I’ve encountered errors in the past (self-hosted on Windows) revolving around entry points until I dictated the path where Prefect considers its home (and stores the DB).
@jbmclry Thanks for the reply. I figured out the issue. We have all our deployment in post_deployment.py file, It appears Prefect expect to post these deployment from same directory where this file is located…so it can build correct path and entrypoint. I have changed my code to generate always path and entrypoint with respect to post_deployment.py where all flows have been imported as module and flow function. This way I do not need to ensure that I am in same directory where post_deployment.py file is there and I can run command python /some/path/post_deployment.py instead doing cd to post_deployment.py directory .