Contributing Guide
All contributions, bug reports, bug fixes, documentation improvements, and enhancements are welcome.
All contributors and maintainers to this project should abide by the Contributor Code of Conduct.
Learn more about the contributors' roles in the Roles page.
This document describes how to contribute to DAG Factory, covering:
- Overview of how to contribute
- How to set up the local development environment
- Running tests
- Pre-commit and linting
- Authoring the documentation
- Releasing
Overview of how to contribute
To contribute to the DAG Factory project:
- Please create a GitHub Issue describing a bug, enhancement, or feature request.
- Open a branch off of the
main
branch and create a Pull Request into themain
branch from your feature branch. - Link your issue to the pull request.
- After you complete development on your feature branch, request a review. A maintainer will merge your PR after all reviewers approve it.
Set up a local development environment
Requirements
Clone the DAG Factory repository and change the current working directory to the repo's root directory:
After cloning the project, there are two options for setting up the local development environment:
- Use a Python virtual environment, or
- Use Docker
Using a Python virtual environment for local development
-
Install the project dependencies:
-
Activate the local python environment:
-
Set Apache Airflow® home to the
dev/
, so you can see DAG Factory example DAGs. Disable loading Airflow standard example DAGs:
Then, run Airflow in standalone mode; the command below will create a new user (if it does not exist) and run the necessary Airflow component (webserver, scheduler and triggered):
Note: By default, Airflow will use sqlite as a database; you can override this by setting the variable
AIRFLOW__DATABASE__SQL_ALCHEMY_CONN
to the SQL connection string.
After Airflow is running, you can access the Airflow UI at http://localhost:8080
.
Note: whenever you want to start the development server, you need to activate the
virtualenv
and set theenvironment variables
Use Docker for local development
It is also possible to build the development environment using Docker:
After the sandbox is running, you can access the Airflow UI at http://localhost:8080
.
This approach builds a DAG Factory wheel, so if there are code changes, you must stop and restart the containers:
Testing application with hatch
The tests are developed using PyTest and run using hatch.
The pyproject. toml file currently defines a matrix of supported versions of Python and Airflow against which a user can run the tests.
Run unit tests
To run unit tests using Python 3.10 and Airflow 2.5, use the following:
It is also possible to run the tests using all the matrix combinations, by using:
Run integration tests
Note: these tests create local Python virtual environments in a hatch-managed directory. They also use the user-defined
AIRFLOW_HOME
, overriding any pre-existingairflow.cfg
andairflow.db
files.
First, set the following environment variables:
export AIRFLOW_HOME=$(pwd)/dev/
export CONFIG_ROOT_DIR=`pwd`"/dev/dags"
export PYTHONPATH=dev/dags:$PYTHONPATH
To run the integration tests using Python 3.9 and Airflow 2.9, use
Pre-Commit and linting
We use pre-commit to run several checks on the code before committing. To install pre-commit hooks, run:
To run the checks manually, run the following:
Pre-commit runs several static checks, including Black and Ruff. It is also possible to run them using hatch
:
Write docs
We use Markdown to author DAG Factory documentation.
Similar to running tests, we also use hatch to manage the documentation.
To build and serve the documentation locally:
To release the documentation with the current project version and set it to the latest:
Releasing
We currently use hatch for building and distributing dag-factory
.
We use GitHub actions to create and deploy new releases. To create a new release, update the latest release version.
It is possible to update the version either by using hatch:
Note: You can update the version in several different ways. To learn more, check out the hatch docs.
Or by manually updating the value of __version__
in dagfactory/__init__.py
.
Make sure the CHANGELOG file is up-to-date.
Create a release using the GitHub UI. GitHub will update the package directly to PyPI.
If you're a project maintainer in PyPI, it is also possible to create a release manually, by authenticating to PyPI and running the commands: