is there a way to test-run a flow locally in Docke...
# ask-community
l
is there a way to test-run a flow locally in Docker, something like
flow.run(run_on_schedule=False)
or using FlowRunner, without using an agent?
Copy code
runner = FlowRunner(flow=built_flow)
with raise_on_exception():
    flow_state = runner.run(return_tasks=built_flow.tasks)
ERROR - prefect.TaskRunner | Unexpected error: KeyError('flow_run_id')
I suppose using the docker agent would have its benefits: • nearly identical to executing in Fargate • quicker startup than Fargate I guess I'm trying to avoid cluttering our Prefect Cloud with flow runs during development.
s
I simply mount my flows into my container and run the flow from inside the container interactively for dev
l
Copy code
storage = Docker(...)
storage.add_flow(flow)
storage = storage.build(push=False)
flow.storage = storage
Is that essentially how you mount the flow in the container?
And then how do you run it interactively, ssh into the container, then execute the
.prefect
file? Or some
docker run ...
command?
s
No,
docker run -v $(pwd):/opt -it <image> /bin/bash
then calling
python <flow_file>.py
. Each flow has a main block to do
flow.run()
(
__name__ == "__main__":
etc)
l
Cool, thanks for the advice!