Learn how to set up Prefect for development, experimentation and code contributions.
uv
for dependency management when developing. Refer to the uv
docs for installation instructions.
To set up a virtual environment and install a development version of prefect
:
prefect
was install correctly:
pre-commit
and pre-push
hooks to run with every commit:
pre-commit
hooks against all files:
uv
, you can run commands with the projectβs dependencies by prefixing the command with uv run
.tests/
directory of the repository.
You can run the test suite with pytest
:
nvm use
from the root of the Prefect repository to initialize the proper version of npm
and node
.
Start a development UI that reloads on code changes:
prefect server start
:
src/prefect/server/database/orm_models.py
.
For example, to add a new column to the flow_run
table, add a new column to the FlowRun
model:
PREFECT_API_DATABASE_CONNECTION_URL
is set to.
See how to set the database connection URL for each database type.
To generate a new migration file, run:
add_flow_run_new_column
add_flow_run_new_column_idx
rename_flow_run_old_column_to_new_column
--autogenerate
flag automatically generates a migration file based on the changes to the models.
--autogenerate
--autogenerate
generates a migration file based on the changes to the models.
However, it is not perfect. Check the file to ensure it only includes the desired changes.src/prefect/server/database/migrations/versions/
directory. Each database type has its
own subdirectory. For example, the SQLite migrations are stored in src/prefect/server/database/migrations/versions/sqlite/
.
After inspecting the migration file, apply the migration to the database by running:
MIGRATION-NOTES.md
to
document the changes.