<@ULVA73B9P> is there a way I can use `flow.serve`...
# ask-marvin
a
@Marvin is there a way I can use
flow.serve
in cases where I want to run the
flow-runs
as standalone containers?
m
Yes, you can use
flow.serve
to run
flow-runs
as standalone containers. Prefect's
.serve
method allows you to elevate a flow to a deployment that listens for scheduled work to execute as a local process. This "local" process can be in a Docker container, which can be on any machine with Docker installed. To achieve this, you can package your flow code and dependencies into a Docker container using a Dockerfile. Once your flow is containerized, you can run it on any machine with Docker. Here's a link to the Prefect documentation that provides a detailed example on how to serve flows in a long-lived Docker container. For reference, Prefect's top-level API includes
serve
, which is part of the offerings for managing flow deployments.
n
this answer seems misleading
flow-runs
as standalone containers?
makes it sound like you want each flow run in its own container, which would not be conducive to
.serve
because
.serve
will start a long lived process that listens for and executes scheduled runs so you can put .serve in a long-lived container if you want flow runs to be executed as subprocesses in that one container, but if you want a container per flow run (dynamic dispatch) then you'll want a docker work pool and a docker worker that submits each flow run as a container
a
Hi @Nate thank you for the support, so for context we were on
2.7
version of
Prefect
and now I’m migrating to
3.2
. Now the problem is in the previous version we were using
Prefect.infrastructure.DockerContainer
for each flow run and this doesn’t seem to be available anymore which is why I raised this question.
n
ah yeah so in 3.x agents / infra blocks are removed, so you'll want to use a docker work pool to have flow runs execute on their own containers
🙌 1