Hi everyone, I'am using Prefect version: 3.1.1 and...
# ask-community
s
Hi everyone, I'am using Prefect version: 3.1.1 and I’ve been encountering an intermittent issue with my Prefect deployments, and I’m hoping someone can help clarify why this might be happening and how to best address it. Here's the context: When I execute a deployment, the flow sometimes enters a
Crashed
state. The logs show the following error:
Copy code
ERROR   | prefect.engine - Engine execution of flow run '<run-id>' exited with unexpected exception
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Lenovo\\AppData\\Local\\Temp\\<temp-folder>\\orchestration\\subflows_definition\\coordinador_downloads.py'
This suggests that the deployment is unable to locate the required file in the temporary directory. Interestingly, if I restart Prefect (both the Server and Workers) and rerun the same deployment, it executes successfully without issues. Logs for the successful run show:
Copy code
INFO    | Task run 'run_script-f9b' - Successfully ran script ...
INFO    | Flow run '<run-id>' - Finished in state Completed()
Why might the flow enter a
Crashed
state with a
FileNotFoundError
for code stored in a temporary directory? Could this be related to my use of
LocalFileSystem
storage on Windows? What happens during a Prefect restart that resolves the issue? Is it forcing a re-synchronization of the code between the Server and Worker? Are there best practices or configurations I can apply to prevent this kind of issue in a Windows environment?
b
Hi Sebastian! Thanks for adding this helpful context. How are you deploying your code? Are you using
.deploy()
?
.serve()
?
prefect deploy
in the CLI?
s
Hi, when deploying my code, I use
serve()
after I define all my flows and the parameters for each deployment to run
In a production environment, what are the key differences between using
.deploy()
,
.serve()
, and the
prefect deploy
CLI for managing deployments? Which approach is recommended for ensuring reliable and scalable flow execution in production?
b
Hi, when deploying my code, I use
serve()
after I define all my flows and the parameters for each deployment to run
Mind sharing a snippet of how you've setup your
.serve()?
👀
In a production environment, what are the key differences between using
.deploy()
,
.serve()
, and the
prefect deploy
CLI for managing deployments?
In short,
.serve()
is suitable for running flows on static infrastructure. Both
.deploy()
and
prefect deploy
are best for deploying flows to dynamic infrastructure, with
.deploy()
offering a more programmatic approach using the Python SDK, and
prefect deploy
using a yaml-based approach that is more static and declarative. All in all, each option is production-ready.