-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into #268-fix-readme-missing-kwarg
- Loading branch information
Showing
17 changed files
with
385 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,35 @@ | ||
name: codecov | ||
on: [push, pull_request] | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
|
||
jobs: | ||
run: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Fetch | ||
uses: actions/checkout@master | ||
- name: Test | ||
run: | | ||
pip install -r requirements_test.txt | ||
pytest tests -v --cov-report term --cov-report html:htmlcov --cov-report xml --cov=quantus | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup python 3.10 | ||
uses: actions/setup-python@v4 | ||
with: | ||
cache: 'pip' | ||
python-version: "3.10" | ||
|
||
- name: Install tox-gh | ||
run: pip install tox-gh | ||
|
||
- name: Setup test environment | ||
run: tox run -e coverage --notest | ||
|
||
- name: Measure coverage. | ||
run: tox run -e coverage | ||
|
||
- name: Upload | ||
uses: codecov/codecov-action@v3 | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
files: ./coverage.xml, coverage.xml | ||
|
||
files: ./coverage.xml, coverage.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Lint | ||
|
||
on: | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
name: Lint | ||
steps: | ||
- name: Check out source repository | ||
uses: actions/checkout@v3 | ||
- name: Set up Python environment | ||
uses: actions/setup-python@v4 | ||
with: | ||
cache: 'pip' | ||
python-version: "3.10" | ||
- name: Install tox-gh | ||
run: pip install tox-gh | ||
- name: Run flake8 | ||
run: tox run -e lint | ||
- name: Run mypy | ||
run: tox run -e type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,37 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | ||
|
||
name: Python package | ||
|
||
on: | ||
#push: | ||
#branches: [ main ] | ||
# Run tests every night, to catch potentially breaking changes in dependencies. | ||
schedule: | ||
- cron: '0 0 * * *' | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: [ main ] | ||
workflow_dispatch: | ||
|
||
|
||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
name: Python Package | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] | ||
|
||
python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11" ] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install flake8 pytest mypy==0.982 | ||
if [ -f requirements_test.txt ]; then pip install -r requirements_test.txt; fi | ||
- name: Lint | ||
run: | | ||
# stop the build if there are Python syntax errors or undefined names | ||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | ||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | ||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | ||
# run mypy | ||
mypy quantus | ||
- name: Test with pytest | ||
run: | | ||
pytest -s -v | ||
- uses: actions/checkout@v3 | ||
- name: Setup python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
cache: 'pip' | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install tox-gh | ||
run: pip install tox-gh | ||
- name: Setup test environment | ||
run: tox run --notest | ||
- name: Test with PyTest | ||
run: tox run | ||
- name: Test building package | ||
run: tox run -e build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,8 +48,10 @@ Make sure to install the latest version of Quantus from the main branch. | |
```bash | ||
git clone https://github.com/understandable-machine-intelligence-lab/Quantus.git | ||
cd quantus | ||
pip install -r requirements_test.txt | ||
pip install -e . | ||
# Tox will provision dev environment with editable installation for you. | ||
python3 -m pip install tox | ||
python3 -m tox devenv | ||
source venv/bin/activate | ||
``` | ||
|
||
### Branching | ||
|
@@ -63,20 +65,29 @@ We use [flake8](https://pypi.org/project/flake8/) for quick style checks and [bl | |
|
||
### Unit Tests | ||
|
||
Tests are written using [pytest](https://github.com/pytest-dev/pytest) and executed together with [codecov](https://github.com/codecov/codecov-action) for coverage reports. | ||
To perform the tests, execute the following (make sure pytest is installed): | ||
```bash | ||
pytest | ||
Tests are written using [pytest](https://github.com/pytest-dev/pytest) and executed together | ||
with [codecov](https://github.com/codecov/codecov-action) for coverage reports. | ||
We use [tox](https://tox.wiki/en/latest/) for test automation. For complete list of CLI commands, please refer | ||
to [tox - CLI interface](https://tox.wiki/en/latest/cli_interface.html). | ||
To perform the tests for all supported python versions execute the following CLI command: | ||
|
||
```shell | ||
python3 -m tox run | ||
``` | ||
... alternatively, to get additionaly coverage details, run: | ||
|
||
... alternatively, to get additionally coverage details, run: | ||
|
||
```bash | ||
pytest --cov=. --cov-report term-missing | ||
python3 -m tox run -e coverage | ||
``` | ||
|
||
It is possible to limit the scope of testing to specific sections of the codebase, for example, only test the Faithfulness metrics: | ||
It is possible to limit the scope of testing to specific sections of the codebase, for example, only test the | ||
Faithfulness metrics using python3.10: | ||
|
||
```bash | ||
pytest -m faithfulness -s | ||
python3 -m tox run -e py310 -- -m faithfulness -s | ||
``` | ||
|
||
For a complete overview of the possible testing scopes, please refer to `pytest.ini`. | ||
|
||
### Documentation | ||
|
@@ -90,18 +101,31 @@ Before creating a PR, double-check that the following tasks are completed: | |
|
||
- Make sure that the latest version of the code from the `main` branch is merged into your working branch. | ||
- Run `black` to format source code: | ||
|
||
```bash | ||
black quantus/INSERT_YOUR_FILE_NAME.py | ||
``` | ||
|
||
- Run `flake8` for quick style checks, e.g.: | ||
|
||
```bash | ||
flake8 quantus/INSERT_YOUR_FILE_NAME.py | ||
``` | ||
- Create `pytests` for new functionality (if needed) and add under `tests/` folder | ||
- If the `pytests` include a new category of `@pytest.mark` then add that category with description to `pytest.ini` | ||
- Make sure all unit tests are passed and the coverage level is maintained (we aim at ~100% code coverage for Quantus): | ||
|
||
- Create a unit test for new functionality and add under `tests/` folder, add `@pytest.mark` with fitting category. | ||
- If newly added test cases include a new category of `@pytest.mark` then add that category with description | ||
to `pytest.ini` | ||
- Make sure all unit tests pass for all supported python version by running: | ||
|
||
```shell | ||
python3 -m tox run | ||
``` | ||
|
||
- Generally, every change should be covered with respective test-case, we aim at ~100% code coverage in Quantus, you can | ||
verify it by running: | ||
|
||
```bash | ||
pytest tests -v --cov-report term --cov-report html:htmlcov --cov-report xml --cov=quantus | ||
python3 -m tox run -e coverage | ||
``` | ||
|
||
### Pull Requests | ||
|
@@ -174,4 +198,4 @@ Please note that by contributing to the project you agree that it will be licens | |
## Questions | ||
|
||
If you have any developer-related questions, please [open an issue](https://github.com/understandable-machine-intelligence-lab/Quantus/issues/new/choose) | ||
or write us at [[email protected]](mailto:[email protected]). | ||
or write us at [[email protected]](mailto:[email protected]). |
Oops, something went wrong.