Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Contribution guidelines #209

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[flake8]
exclude = .git, .venv*
max-line-length = 120
max-complexity = 10
max-complexity = 12
ignore = E203, W503
8 changes: 2 additions & 6 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,10 @@ jobs:
if: steps.cache-deps.outputs.cache-hit != 'true'

- name: Check code formatting with black
run: poetry run black --check .
run: poetry run black . --check

- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
poetry run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
run: poetry run flake8 . --count --show-source

- name: Test with pytest
run: poetry run pytest
5 changes: 4 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

project = "Spherinator"
copyright = f"{datetime.now().year}, HITS gGmbH"
author = "Kai Polsterer <[email protected]>, Bernd Doser <[email protected]>, Andreas Fehlner <[email protected]>, Sebastian T. Gomez <[email protected]>"
author = """Kai Polsterer <[email protected]>,
Bernd Doser <[email protected]>,
Andreas Fehlner <[email protected]>,
Sebastian T. Gomez <[email protected]>"""

extensions = [
"myst_parser",
Expand Down
59 changes: 59 additions & 0 deletions docs/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Contributing to Spherinator & HiPSter

We welcome contributions to the Spherinator & HiPSter project. This document outlines the guidelines for contributing to the project. Don't worry about the length of this document. There are various ways to contribute to the project at different levels. Just get started, and we will help you through the process. Finally, all the guidelines and checks are in place to ensure the quality of the project.

## Code of Conduct

The project follows the [Contributor Covenant Code of Conduct](https://www.contributor-covenant.org/version/2/1/code_of_conduct/). Please read the code of conduct before contributing to the project.

## Use best practices for a clean codebase

The Python code must adhere to the [PEP8 Python coding style guide](https://peps.python.org/pep-0008/) for formatting and syntax. The [Google Python Style Guide](https://google.github.io/styleguide/pyguide.html) provides additional guidelines for writing clean and readable code. The Spherinator is using the design principles of the [PyTorch Lightning](https://lightning.ai/docs/pytorch/stable/) library.

## Python dependencies

The project uses [Poetry](https://python-poetry.org/) for dependency management. The dependencies are listed in the `pyproject.toml` file. To add new dependencies, use Poetry's `poetry add` command. It is recommended to keep the number of dependencies to a minimum.

## Documentation

Write docstrings for all public modules, functions, classes, and methods. Follow docstring conventions as outlined by [PEP 257](https://peps.python.org/pep-0257/).
The user documentation is located in the `docs` directory and will be generated with [Sphinx](https://www.sphinx-doc.org/en/master/index.html) and hosted on [Read The Docs](https://spherinator.readthedocs.io/en/latest/index.html).

## Testing

The code is tested using [pytest](https://docs.pytest.org). All tests are located in the `tests` directory. Please write tests for all new code and ensure all tests pass before creating a pull request. The CI workflow will run the tests and fail if any test fails.

## Continuous Integration

GitHub Actions is used for continuous integration. The CI workflow is defined in [.github/workflows/python-package.yml](.github/workflows/python-package.yml). The CI workflow runs the tests and checks the code style and the code formatting on every push to the repository.

## Code Formatting

The Python code must be formatted with [black](https://black.readthedocs.io/en/stable/).
This can be done manually by running `black .` in the project directory or by installing the vscode extension `ms-python.black-formatter`. The format on save option is enabled for `vscode` in the `.vscode/settings.json` file.
The CI workflow will check the code formatting and fail if the code is not formatted correctly.

## Static code analysis

The code will be analyzed using [flake8](https://flake8.pycqa.org/en/latest/).
The linting rules are defined in the `.flake8` file. The linter can be run manually by running `flake8` in the project directory.
The CI workflow will check the code for any issues reported by flake8 and fail if any issues are found.

## Pull requests

The project uses the [GitHub flow](https://guides.github.com/introduction/flow/) to manage pull requests.

1. Create a fork of the repository. Although you can create a branch in the main repository, creating a fork for better isolation is recommended.
2. Create a branch in your fork. Let the branch name describe the changes you are making.
3. Make the changes in the branch.
4. Check if all the checks are passing. If not, fix the issues and push the changes to the branch.
5. Create a pull request from your branch to the `main` repository and describe your changes.
6. The pull request will be reviewed by the maintainers. The review process may involve multiple iterations of changes and reviews.
7. Please keep the branch up to date with the `main` repository by rebasing it on the main branch if necessary.
8. Once the pull request is approved, it will be merged into the `main` repository, and the feature branch will be deleted.

## Issues

If you find a bug or have a feature request, please create an issue in the [GitHub issue tracker](https://github.com/HITS-AIN/Spherinator/issues).

Thank you for contributing to the Spherinator & HiPSter project!
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ The documentation is under construction and not yet complete. For more informati
installation.md
training.md
hipster.md
contributing.md
```
2 changes: 0 additions & 2 deletions tests/test_dynamo_export.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import sys

import pytest
import torch
import torch.nn as nn
Expand Down
2 changes: 0 additions & 2 deletions tests/test_onnx_export.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import sys

import pytest
import torch
import torch.nn as nn
Expand Down
Loading