If you are interested in contributing to PyG, your contributions will likely fall into one of the following two categories:
- You want to implement a new feature:
- In general, we accept any features as long as they fit the scope of this package. If you are unsure about this or need help on the design/implementation of your feature, post about it in an issue.
- You want to fix a bug:
- Feel free to send a Pull Request (PR) any time you encounter a bug. Please provide a clear and concise description of what the bug was. If you are unsure about if this is a bug at all or how to fix, post about it in an issue.
Once you finish implementing a feature or bug-fix, please send a PR to https://github.com/pyg-team/pytorch_geometric.
Your PR will be merged after one or more rounds of reviews by the pyg-team.
If your PR isn't merged anytime soon (e.g., due to its large size, complexity or unavailability of reviewers), try moving your contribution to the torch_geometric.contrib
package.
torch_geometric.contrib
has less rigourous review requirements and might lead to your PR getting merged faster.
To develop PyG on your machine, here are some tips:
-
Ensure that you are running on one of the two latest PyTorch releases (e.g.,
1.12.0
):import torch print(torch.__version__)
-
Follow the installation instructions to install
pyg-lib
,torch-scatter
,torch-sparse
,torch-cluster
andtorch-spline-conv
(if you haven't already):pip install pyg-lib torch-scatter torch-sparse torch-cluster torch-spline-conv -f https://data.pyg.org/whl/torch-${TORCH}+${CUDA}.html
where
${TORCH}
should be replaced by your PyTorch version (e.g.,1.12.0
), and${CUDA}
should be replaced by your CUDA version (e.g.,cpu
orcu116
). -
Uninstall all existing PyG installations:
pip uninstall torch-geometric pip uninstall torch-geometric # run this command twice
-
Clone a copy of PyG from source:
git clone https://github.com/pyg-team/pytorch_geometric cd pytorch_geometric
-
If you already cloned PyG from source, update it:
git pull
-
Install PyG in editable mode:
pip install -e ".[dev,full]"
This mode will symlink the Python files from the current local source tree into the Python install. Hence, if you modify a Python file, you do not need to reinstall PyG again and again.
-
Ensure that you have a working PyG installation by running the entire test suite with
pytest
In case an error occurs, please first check if all sub-packages (
pyg-lib
,torch-scatter
,torch-sparse
,torch-cluster
andtorch-spline-conv
) are on its latest reported version. -
Install pre-commit hooks:
pre-commit install
The PyG testing suite is located under test/
.
Run the entire test suite with
pytest
or test individual files via, e.g., pytest test/utils/test_convert.py
.
PyG uses GitHub Actions in combination with CodeCov for continuous integration.
Everytime you send a Pull Request, your commit will be built and checked against the PyG guidelines:
-
Ensure that your code is formatted correctly by testing against the styleguide of
flake8
://github.com/PyCQA/pycodestyle):flake8 .
If you do not want to format your code manually, we recommend to use
yapf
. -
Ensure that the entire test suite passes and that code coverage roughly stays the same. Please feel encouraged to provide a test with your submitted code. To test, either run
pytest --cov
or
FULL_TEST=1 pytest --cov
(which runs a set of additional but time-consuming tests) dependening on your needs.
-
Add your feature/bugfix to the
CHANGELOG.md
. If multiple PRs move towards integrating a single feature, it is advised to group them together into one bullet point.
To build the documentation:
- Build and install PyG from source.
- Install Sphinx theme via
pip install git+https://github.com/pyg-team/pyg_sphinx_theme.git
- Generate the documentation via:
cd docs make html
The documentation is now available to view by opening docs/build/html/index.html
.