<@ULVA73B9P> best practice ? is workflows and cont...
# ask-marvin
o
@Marvin best practice ? is workflows and containing workflow definitions a folder inside src or a seperate folder in project wrt prefect?
m
thought for 110.1 seconds
Short answer: both work — Prefect 3.x doesn’t enforce a specific layout. Choose the standard Python packaging approach your team already uses. What we usually recommend: - Use the src layout so your flows are an importable package. - Keep tests/config separate and install your project in editable mode during development. Example structure:
Copy code
my-project/
├── src/
│   └── my_project/
│       ├── __init__.py
│       ├── flows.py        # @flow definitions
│       └── tasks.py
├── tests/
│   ├── test_flows.py
│   └── conftest.py
├── config/
│   ├── dev.yaml
│   └── prod.yaml
├── pyproject.toml
└── deploy.py               # optional — calls .from_source(...).deploy(...)
Key points: - Prefect only needs to import your flow and resolve the entrypoint; it doesn’t care if it’s under src/ or a top-level flows/ folder. - If you use a top-level folder (e.g., flows/), make it a package (add init.py) and ensure it’s on PYTHONPATH in your runtime. - In Prefect 3.x deployments, use `flow.from_source(...).deploy(...)`; the
entrypoint
is the path to the file and flow function relative to the source root, e.g.
src/my_project/flows.py:my_flow
. Helpful references: - Deploy flows with Python (.deploy) - Store and retrieve flow code (Git/local/etc.) - Write and run workflows If you share your repo layout, I’m happy to suggest concrete entrypoints and a minimal deploy script.