2015-03-08 00:00:46 +03:00
# Contributing
Contributions are welcome and are greatly appreciated! Every
little bit helps, and credit will always be given.
2016-03-21 21:04:32 +03:00
# Table of Contents
* [TOC ](#table-of-contents )
* [Types of Contributions ](#types-of-contribution )
- [Report Bugs ](#report-bugs )
- [Fix Bugs ](#fix-bugs )
- [Implement Features ](#implement-features )
- [Improve Documentation ](#improve-documentation )
- [Submit Feedback ](#submit-feedback )
* [Documentation ](#documentation )
* [Development and Testing ](#development-and-testing )
- [Setting up a development environment ](#setting-up-a-development-environment )
- [Pull requests guidelines ](#pull-requests-guidelines )
- [Testing Locally ](#testing-locally )
* [Changing the Metadata Database ](#changing-the-metadata-database )
2015-03-08 00:00:46 +03:00
## Types of Contributions
### Report Bugs
2016-06-23 22:36:17 +03:00
Report bugs through [Apache Jira ](https://issues.apache.org/jira/browse/AIRFLOW )
2015-03-08 00:00:46 +03:00
2016-06-23 22:36:17 +03:00
Please report relevant information and preferably code that exhibits
the problem.
2015-03-08 00:00:46 +03:00
### Fix Bugs
2016-12-25 16:40:46 +03:00
Look through the Jira issues for bugs. Anything is open to whoever wants
2016-06-23 22:36:17 +03:00
to implement it.
2015-03-08 00:00:46 +03:00
### Implement Features
2018-02-22 00:00:54 +03:00
Look through the [Apache Jira ](https://issues.apache.org/jira/browse/AIRFLOW ) for features. Any unassigned "Improvement" issue is open to whoever wants to implement it.
2015-03-08 00:00:46 +03:00
2015-08-11 00:48:59 +03:00
We've created the operators, hooks, macros and executors we needed, but we
2015-03-08 00:00:46 +03:00
made sure that this part of Airflow is extensible. New operators,
2018-03-03 01:27:41 +03:00
hooks, macros and executors are very welcomed!
2015-03-08 00:00:46 +03:00
2016-03-21 21:04:32 +03:00
### Improve Documentation
2015-03-08 00:00:46 +03:00
Airflow could always use better documentation,
whether as part of the official Airflow docs,
in docstrings, `docs/*.rst` or even on the web as blog posts or
articles.
### Submit Feedback
2018-02-22 00:00:54 +03:00
The best way to send feedback is to open an issue on [Apache Jira ](https://issues.apache.org/jira/browse/AIRFLOW )
2015-03-08 00:00:46 +03:00
If you are proposing a feature:
- Explain in detail how it would work.
- Keep the scope as narrow as possible, to make it easier to
implement.
- Remember that this is a volunteer-driven project, and that
contributions are welcome :)
2016-03-21 21:04:32 +03:00
## Documentation
2018-02-16 14:38:54 +03:00
The latest API documentation is usually available [here ](https://airflow.incubator.apache.org/ ).
2016-12-25 16:40:46 +03:00
To generate a local version, you need to have installed airflow with
2016-06-23 22:36:17 +03:00
the `doc` extra. In that case you can generate the doc by running:
2015-03-08 00:00:46 +03:00
2016-03-21 21:04:32 +03:00
cd docs & & ./build.sh
## Development and Testing
2015-03-08 00:00:46 +03:00
2016-03-21 21:04:32 +03:00
### Setting up a development environment
2015-03-08 00:00:46 +03:00
2016-07-06 11:37:28 +03:00
Please install python(2.7.x or 3.4.x), mysql, and libxml by using system-level package
managers like yum, apt-get for Linux, or homebrew for Mac OS at first.
It is usually best to work in a virtualenv and tox. Install development requirements:
2015-03-08 00:00:46 +03:00
2015-11-12 12:53:31 +03:00
cd $AIRFLOW_HOME
virtualenv env
source env/bin/activate
2016-03-21 21:04:32 +03:00
pip install -e .[devel]
2016-07-06 11:37:28 +03:00
tox
2015-03-08 00:00:46 +03:00
2016-03-21 21:04:32 +03:00
Feel free to customize based on the extras available in [setup.py ](./setup.py )
2015-03-08 00:00:46 +03:00
2016-03-21 21:04:32 +03:00
### Pull Request Guidelines
2015-03-08 00:00:46 +03:00
2015-08-11 00:48:59 +03:00
Before you submit a pull request from your forked repo, check that it
2015-03-08 00:00:46 +03:00
meets these guidelines:
2016-02-25 21:59:31 +03:00
1. The pull request should include tests, either as doctests, unit tests, or
2016-12-25 16:40:46 +03:00
both. The airflow repo uses [Travis CI ](https://travis-ci.org/apache/incubator-airflow )
to run the tests and [codecov ](https://codecov.io/gh/apache/incubator-airflow )
to track coverage. You can set up both for free on your fork. It will
help you making sure you do not break the build with your PR and that you help
2016-06-23 22:36:17 +03:00
increase coverage.
2016-12-25 16:40:46 +03:00
2. Please [rebase your fork ](http://stackoverflow.com/a/7244456/1110993 ),
squash commits, and resolve all conflicts.
3. Every pull request should have an associated
[JIRA ](https://issues.apache.org/jira/browse/AIRFLOW/?selectedTab=com.atlassian.jira.jira-projects-plugin:summary-panel ).
The JIRA link should also be contained in the PR description.
4. Preface your commit's subject & PR's title with ** [AIRFLOW-XXX]**
where *XXX* is the JIRA number. We compose release notes (i.e. for Airflow releases) from all commit titles in a release.
By placing the JIRA number in the commit title and hence in the release notes,
Airflow users can look into JIRA and Github PRs for more details about a particular change.
5. Add an [Apache License ](http://www.apache.org/legal/src-headers.html )
header to all new files
6. If the pull request adds functionality, the docs should be updated as part
2016-02-25 21:59:31 +03:00
of the same PR. Doc string are often sufficient. Make sure to follow the
2016-12-25 16:40:46 +03:00
Sphinx compatible standards.
7. The pull request should work for Python 2.7 and 3.4. If you need help
2016-02-25 21:59:31 +03:00
writing code that works in both Python 2 and 3, see the documentation at the
[Python-Future project ](http://python-future.org ) (the future package is an
Airflow requirement and should be used where possible).
2016-12-25 16:40:46 +03:00
8. As Airflow grows as a project, we try to enforce a more consistent
style and try to follow the Python community guidelines. We track this
using [landscape.io ](https://landscape.io/github/apache/incubator-airflow/ ),
which you can setup on your fork as well to check before you submit your
PR. We currently enforce most [PEP8 ](https://www.python.org/dev/peps/pep-0008/ )
and a few other linting rules. It is usually a good idea to lint locally
as well using [flake8 ](https://flake8.readthedocs.org/en/latest/ )
2017-12-22 15:56:18 +03:00
using `flake8 airflow tests` . `git diff upstream/master -u -- "*.py" | flake8 --diff` will return any changed files in your branch that require linting.
2016-12-25 16:40:46 +03:00
9. Please read this excellent [article ](http://chris.beams.io/posts/git-commit/ ) on
2016-06-23 22:36:17 +03:00
commit messages and adhere to them. It makes the lives of those who
come after you a lot easier.
2015-08-28 19:44:04 +03:00
2016-03-21 21:04:32 +03:00
### Testing locally
2016-04-03 16:54:01 +03:00
#### TL;DR
2016-03-21 21:04:32 +03:00
Tests can then be run with (see also the [Running unit tests ](#running-unit-tests ) section below):
./run_unit_tests.sh
2017-12-22 15:56:18 +03:00
Individual test files can be run with:
nosetests [path to file]
2016-03-21 21:04:32 +03:00
#### Running unit tests
2016-12-25 16:40:46 +03:00
We *highly* recommend setting up [Travis CI ](https://travis-ci.org/ ) on
your repo to automate this. It is free for open source projects. If for
2016-06-23 22:36:17 +03:00
some reason you cannot, you can use the steps below to run tests.
2015-08-28 19:44:04 +03:00
Here are loose guidelines on how to get your environment to run the unit tests.
2016-02-25 21:59:31 +03:00
We do understand that no one out there can run the full test suite since
Airflow is meant to connect to virtually any external system and that you most
likely have only a subset of these in your environment. You should run the
CoreTests and tests related to things you touched in your PR.
2015-08-28 19:44:04 +03:00
2015-11-10 19:54:56 +03:00
To set up a unit test environment, first take a look at `run_unit_tests.sh` and
2015-08-28 19:44:04 +03:00
understand that your ``AIRFLOW_CONFIG`` points to an alternate config file
while running the tests. You shouldn't have to alter this config file but
you may if need be.
2015-11-10 19:54:56 +03:00
From that point, you can actually export these same environment variables in
2015-08-28 19:44:04 +03:00
your shell, start an Airflow webserver ``airflow webserver -d`` and go and
configure your connection. Default connections that are used in the tests
should already have been created, you just need to point them to the systems
where you want your tests to run.
Once your unit test environment is setup, you should be able to simply run
2016-02-25 21:59:31 +03:00
``./run_unit_tests.sh`` at will.
2015-11-10 19:54:56 +03:00
2016-02-25 21:59:31 +03:00
For example, in order to just execute the "core" unit tests, run the following:
2015-11-10 19:54:56 +03:00
```
2015-12-08 14:05:49 +03:00
./run_unit_tests.sh tests.core:CoreTest -s --logging-level=DEBUG
2015-11-10 19:54:56 +03:00
```
2016-02-25 21:59:31 +03:00
or a single test method:
2015-11-10 19:54:56 +03:00
2016-02-25 21:59:31 +03:00
```
2015-12-08 14:05:49 +03:00
./run_unit_tests.sh tests.core:CoreTest.test_check_operators -s --logging-level=DEBUG
2015-11-10 19:54:56 +03:00
```
2016-02-25 21:59:31 +03:00
For more information on how to run a subset of the tests, take a look at the
nosetests docs.
2015-11-10 19:54:56 +03:00
2016-07-06 11:33:09 +03:00
See also the list of test classes and methods in `tests/core.py` .
2015-11-10 19:54:56 +03:00
2016-03-21 21:04:32 +03:00
### Changing the Metadata Database
2015-11-30 17:46:06 +03:00
When developing features the need may arise to persist information to the the
2016-02-25 21:59:31 +03:00
metadata database. Airflow has [Alembic ](https://bitbucket.org/zzzeek/alembic )
built-in to handle all schema changes. Alembic must be installed on your
development machine before continuing.
2015-11-30 17:46:06 +03:00
```
# starting at the root of the project
$ pwd
~/airflow
# change to the airflow directory
$ cd airflow
$ alembic revision -m "add new field to db"
Generating
~/airflow/airflow/migrations/versions/12341123_add_new_field_to_db.py
```