Theonymfi Anogeianaki
12/16/2025, 1:57 PMMarvin
12/16/2025, 1:57 PMMarvin
12/16/2025, 2:06 PM/home/circleci/project/flows.py:my_flow (via prefect deploy or Python), that absolute path is baked into the deployment and used at run time.
- Or if you don’t configure storage/pull steps (e.g., flow.from_source(...)), your code is never cloned into the ECS container; even a relative entrypoint will fail because the file isn’t there.
- In push pools, there isn’t a “CircleCI workspace” in the container. The container only sees what’s in the image + what Prefect pulls at runtime via pull steps. The working directory defaults to the image’s WORKDIR (e.g., /opt/prefect in Prefect images) unless you set it with a pull step.
How to fix it (pick one)
1) Recommended: deploy from a source repo (Git) with a relative entrypoint
- Use flow.from_source(...) so Prefect creates the right pull steps and a relative entrypoint; Prefect will clone your repo into the container at run time and set the working directory accordingly.
from prefect import flow
@flow
def my_flow():
print("Hello from ECS!")
# Run this from CircleCI or locally
flow.from_source(
source="<https://github.com/your-org/your-repo.git>",
entrypoint="src/flows.py:my_flow" # RELATIVE path inside the repo
).deploy(
name="ecs-deployment",
work_pool_name="your-ecs-push-pool",
# optionally pin an image:
# image="prefecthq/prefect:3.1-python3.11"
)
2) Alternatively: bake code into your image and keep the entrypoint relative
- COPY your code into the image at a known path (e.g., /opt/prefect/app) and set WORKDIR there in the Dockerfile.
- Keep your deployment entrypoint relative (e.g., src/flows.py:my_flow) so the engine resolves it relative to the WORKDIR.
- If you need to, add a set_working_directory pull step to point to that folder.
Quick checks to confirm the problem
- Inspect your deployment to see what Prefect will try to load:
prefect deployment inspect <flow-name>/<deployment-name>
Look for:
- entrypoint: should be relative like src/flows.py:my_flow, not /home/circleci/project/...
- pull steps: should include a Git clone (if using from_source) or a set_working_directory pointing to where code lives
- path: for storage-based deployments, you’ll see $STORAGE_BASE_PATH (that’s correct)
If your entrypoint is absolute (contains /home/circleci/project), redeploy with a relative entrypoint and either:
- use flow.from_source(...), or
- ensure your image contains the code and the working directory matches where the code is copied.
Notes specific to ECS push pools
- There isn’t a dedicated “working_dir” job variable in the ECS push pool config. Working directory is determined by your image’s WORKDIR or by adding a set_working_directory pull step.
- The engine resolves the flow using a relative entrypoint and the working directory set at runtime (via pull steps), not the CI path.
If you can share:
- How you created the deployment (Python flow.from_source(...).deploy(...) or prefect deploy)
- The exact entrypoint string you used
- Whether you’re using a custom image or the Prefect image
- Your prefect.yaml (if applicable)
…I can point out the precise line to change.
Useful docs
- Serverless (ECS) deployments: https://docs.prefect.io/v3/how-to-guides/deployment_infra/serverless/
- Store and retrieve flow code (from_source, pull steps): https://docs.prefect.io/v3/how-to-guides/deployments/store-flow-code/
- Pull steps API reference (git_clone, set_working_directory, etc.): https://docs.prefect.io/v3/api-ref/python/prefect-deployments-steps-pull/Theonymfi Anogeianaki
12/16/2025, 2:17 PMWORKDIR /app
should i then add in the prefect.yaml the following?
...
pull:
- prefect.deployments.steps.set_working_directory:
directory: /app
deployments:
....
will this override the circle ci path?Marvin
12/16/2025, 2:17 PMMarvin
12/16/2025, 2:18 PMpull:
- prefect.deployments.steps.set_working_directory:
directory: /app
- If code is pulled at runtime (recommended for push pools):
- Use flow.from_source(..., entrypoint="src/flows.py:my_flow") so Prefect generates the correct pull steps and a relative entrypoint.
- Optionally add set_working_directory to point to the folder where the code ends up. With from_source, Prefect handles this for you and you typically don’t need to hardcode /app.
Verify and fix the root cause
- Inspect your deployment:
prefect deployment inspect <flow-name>/<deployment-name>
- entrypoint should be relative like src/flows.py:my_flow (not /home/circleci/project/…)
- pull steps should exist if you’re not baking code into the image
- If you see an absolute CircleCI path in entrypoint, redeploy with a relative entrypoint (and either bake code into the image at /app or use from_source so the code is cloned into the container).
Docs
- Serverless (ECS) deployments: https://docs.prefect.io/v3/how-to-guides/deployment_infra/serverless/
- Store and retrieve flow code (from_source, pull steps): https://docs.prefect.io/v3/how-to-guides/deployments/store-flow-code/
- Pull steps reference (set_working_directory, git_clone, etc.): https://docs.prefect.io/v3/api-ref/python/prefect-deployments-steps-pull/
If you share your current prefect.yaml (entrypoint and pull sections) and whether your code is in the image or pulled from Git, I can suggest the exact minimal edits.