How to schedule local scripts without keeping flow.serve() running or using Docker? #19422
-
|
Hi Prefect team and community, I’m new here and I was trying to run local Python flows (i.e., scripts on my filesystem, no Git/Docker) using Prefect 3’s (version 3.6.1+2.gd96416c96b) deployment system, but I’m hitting a usability gap: ✅ flow.serve() works perfectly for development — it registers the deployment and starts an embedded worker. ❌ But as soon as I Ctrl+C the python deploy.py process, new flow runs become "Late" because the embedded worker is gone ( Although I can do actions on UI, but the flow will not be running, another discussion also reporting this: #16150 ). I don't know whether this behavior is as expected. 🚫 The new prefect.deploy(...) / flow.deploy() API requires either a Docker image or remote storage (e.g., GitHub), which is overkill for simple local automation. I’d like a way to: I checked this was possible in earlier versions with Deployment.build_from_flow(...).apply() + process work pool. but looks like it's not an available approach in Prefect 3.6+? May I ask what is the best practice for local script scheduling & deployment? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
|
hi @TomMonkeyMan - have you checked this? if you use e.g. from pathlib import Path
from prefect import flow
@flow(log_prints=True)
def my_flow(name: str = "world"):
print(f"Hello {name}! I'm a flow from a Python script!")
if __name__ == "__main__":
my_flow.from_source(
source=str(Path(__file__).parent),
entrypoint="example.py:my_flow",
).deploy(
name="my-deployment",
parameters=dict(name="Marvin"),
work_pool_name="local",
) |
Beta Was this translation helpful? Give feedback.
hi @TomMonkeyMan - have you checked this?
if you use
from_sourceand refer to a local filepath, you don't need remote storage or an imagee.g.