Skip to content

Commit cf35fde

Browse files
author
Hông-Lan Botterman
committed
check ruff
1 parent ab79496 commit cf35fde

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+4169
-2436
lines changed

.flake8

Lines changed: 0 additions & 9 deletions
This file was deleted.

.github/workflows/publish.yml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
name: Publish Package on PYPI
1+
name: Publish Package on PyPI
22

33
on:
44
release:
55
types: [published]
66

7-
87
jobs:
98
deploy:
10-
119
runs-on: ubuntu-latest
1210

1311
steps:
@@ -16,14 +14,19 @@ jobs:
1614
uses: actions/setup-python@v4
1715
with:
1816
python-version: '3.10'
17+
- name: Install Poetry
18+
run: |
19+
curl -sSL https://install.python-poetry.org | python3 -
20+
echo "$HOME/.local/bin" >> $GITHUB_PATH
1921
- name: Install dependencies
2022
run: |
21-
python -m pip install --upgrade pip
22-
pip install setuptools wheel twine
23+
poetry install
2324
- name: Build package
24-
run: python setup.py sdist bdist_wheel
25+
run: |
26+
poetry build
2527
- name: Publish package
26-
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
27-
with:
28-
user: __token__
29-
password: ${{ secrets.PYPI_API_TOKEN }}
28+
env:
29+
PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
30+
run: |
31+
poetry config pypi-token.pypi $PYPI_TOKEN
32+
poetry publish

.github/workflows/test.yml

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ name: Unit tests
33
on:
44
push:
55
branches:
6-
-dev
7-
-main
6+
- "**"
87
pull_request:
98
types: [opened, synchronize, reopened, ready_for_review]
109
workflow_dispatch:
@@ -22,24 +21,23 @@ jobs:
2221
shell: bash -l {0}
2322

2423
steps:
25-
- name: Git clone
24+
- name: Checkout
2625
uses: actions/checkout@v3
27-
- name: Set up venv for ci
28-
uses: conda-incubator/setup-miniconda@v2
26+
- name: Python
27+
uses: actions/setup-python@v4
2928
with:
30-
python-version: ${{matrix.python-version}}
31-
environment-file: environment.ci.yml
32-
- name: Lint with flake8
33-
run: |
34-
flake8
35-
- name: Test with pytest
36-
run: |
37-
make coverage
38-
- name: typing with mypy
39-
run: |
40-
mypy qolmat
41-
echo you should uncomment mypy qolmat and delete this line
42-
- name: Upload coverage reports to Codecov
29+
python-version: ${{ matrix.python-version }}
30+
- name: Poetry
31+
uses: snok/install-poetry@v1
32+
with:
33+
version: 1.8.3
34+
- name: Lock
35+
run: poetry lock --no-update
36+
- name: Install
37+
run: poetry install
38+
- name: Checkers
39+
run: make checkers
40+
- name: Codecov
4341
uses: codecov/codecov-action@v3
4442
env:
4543
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/test_quick.yml

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
shell: bash -l {0}
2020

2121
steps:
22-
- name: Git clone
22+
- name: Checkout
2323
uses: actions/checkout@v3
2424

2525
# See caching environments
@@ -29,40 +29,27 @@ jobs:
2929
with:
3030
miniforge-variant: Mambaforge
3131
miniforge-version: latest
32-
activate-environment: env_qolmat_ci
3332
use-mamba: true
33+
python-version: ${{ matrix.python-version }}
3434

3535
- name: Get Date
3636
id: get-date
3737
run: echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT
3838

39-
- name: Cache Conda env
39+
- name: Cache Poetry dependencies
4040
uses: actions/cache@v2
4141
with:
42-
path: ${{ env.CONDA }}/envs
43-
key:
44-
conda-${{ runner.os }}--${{ runner.arch }}--${{
45-
steps.get-date.outputs.today }}-${{
46-
hashFiles('environment.ci.yml') }}-${{ env.CACHE_NUMBER
47-
}}
48-
env:
49-
# Increase this value to reset cache if environment.ci.yml has not changed
50-
CACHE_NUMBER: 0
51-
id: cache
52-
53-
- name: Update environment
54-
run: mamba env update -n env_qolmat_ci -f environment.ci.yml
55-
if: steps.cache.outputs.cache-hit != 'true'
56-
57-
- name: Lint with flake8
58-
run: |
59-
flake8
60-
- name: Test with pytest
61-
run: |
62-
make coverage
63-
- name: Test docstrings
64-
run: make doctest
65-
- name: typing with mypy
66-
run: |
67-
mypy qolmat
68-
echo you should uncomment mypy qolmat and delete this line
42+
path: |
43+
~/.cache/pypoetry/cache
44+
~/.cache/pypoetry/artifacts
45+
key: poetry-${{ runner.os }}-cache-${{ steps.get-date.outputs.today }}-${{ hashFiles('poetry.lock') }}
46+
restore-keys: |
47+
poetry-${{ runner.os }}-cache-
48+
49+
- name: Install Poetry
50+
run :
51+
mamba install -c conda-forge poetry -y
52+
poetry install
53+
54+
- name: Checkers
55+
run: make check-coverage check-types

.pre-commit-config.yaml

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,8 @@ repos:
88
exclude: (docs/)
99
- id: trailing-whitespace
1010
exclude: (docs/)
11-
- repo: https://github.com/psf/black
12-
rev: 22.8.0
11+
- repo: https://github.com/astral-sh/ruff-pre-commit
12+
rev: v0.3.3
1313
hooks:
14-
- id: black
15-
args:
16-
- "-l 99"
17-
# Flake8
18-
- repo: https://github.com/PyCQA/flake8
19-
rev: 4.0.1
20-
hooks:
21-
- id: flake8
22-
- repo: https://github.com/pre-commit/mirrors-mypy
23-
rev: v1.1.1
24-
hooks:
25-
- id: mypy
26-
args: [--ignore-missing-imports]
27-
additional_dependencies: [types-requests]
14+
- id: ruff
15+
- id: ruff-format

Makefile

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,34 @@
1-
coverage:
2-
pytest --cov-branch --cov=qolmat --cov-report=xml tests
31

4-
doctest:
5-
pytest --doctest-modules --pyargs qolmat
2+
check-coverage:
3+
poetry run pytest --cov-branch --cov=qolmat/ --cov-report=xml tests/
64

7-
doc:
8-
make html -C docs
5+
check-poetry:
6+
poetry check --lock
7+
8+
check-quality:
9+
poetry run ruff check qolmat/ tests/
10+
11+
check-security:
12+
poetry run bandit --recursive --configfile=pyproject.toml qolmat/
13+
14+
check-tests:
15+
poetry run pytest tests/
16+
17+
check-types:
18+
poetry run mypy qolmat/ tests/
19+
20+
checkers: check-coverage check-types
921

1022
clean:
1123
rm -rf .mypy_cache .pytest_cache .coverage*
1224
rm -rf **__pycache__
1325
make clean -C docs
26+
27+
coverage:
28+
poetry run pytest --cov-branch --cov=qolmat --cov-report=xml tests
29+
30+
doc:
31+
make html -C docs
32+
33+
doctest:
34+
poetry run pytest --doctest-modules --pyargs qolmat

environment.ci.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

examples/tutorials/plot_tuto_benchmark_TS.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""
2-
=========================
1+
"""=========================
32
Benchmark for time series
43
=========================
54
@@ -14,18 +13,18 @@
1413
# First import some libraries
1514

1615
import numpy as np
17-
import pandas as pd
1816

1917
np.random.seed(1234)
20-
from matplotlib import pyplot as plt
2118
import matplotlib.ticker as plticker
19+
from matplotlib import pyplot as plt
2220

2321
tab10 = plt.get_cmap("tab10")
2422

23+
from sklearn.linear_model import LinearRegression
24+
2525
from qolmat.benchmark import comparator, missing_patterns
2626
from qolmat.imputations import imputers
2727
from qolmat.utils import data, plot
28-
from sklearn.linear_model import LinearRegression
2928

3029
# %%
3130
# 1. Data

examples/tutorials/plot_tuto_categorical.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""
2-
==============================
1+
"""==============================
32
Benchmark for categorical data
43
==============================
54
@@ -8,14 +7,13 @@
87
It comprehends passengers features as well as if they survived the accident.
98
"""
109

11-
from qolmat.imputations import preprocessing, imputers
10+
from sklearn.pipeline import Pipeline
11+
12+
from qolmat.benchmark import comparator, missing_patterns
13+
from qolmat.imputations import imputers, preprocessing
1214
from qolmat.imputations.imputers import ImputerRegressor
13-
from qolmat.benchmark import missing_patterns
14-
from qolmat.benchmark import comparator
1515
from qolmat.utils import data
1616

17-
from sklearn.pipeline import Pipeline
18-
1917
# %%
2018
# 1. Titanic dataset
2119
# ---------------------------------------------------------------

examples/tutorials/plot_tuto_diffusion_models.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
"""
2-
===============================================
1+
"""===============================================
32
Tutorial for imputers based on diffusion models
43
===============================================
54
65
In this tutorial, we show how to use :class:`~qolmat.imputations.diffusions.ddpms.TabDDPM`
76
and :class:`~qolmat.imputations.diffusions.ddpms.TsDDPM` classes.
87
"""
98

10-
import pandas as pd
11-
import numpy as np
129
import matplotlib.pyplot as plt
10+
import numpy as np
11+
import pandas as pd
1312

14-
from qolmat.utils import data
1513
from qolmat.benchmark import comparator, missing_patterns
16-
17-
from qolmat.imputations.imputers_pytorch import ImputerDiffusion
1814
from qolmat.imputations.diffusions.ddpms import TabDDPM, TsDDPM
15+
from qolmat.imputations.imputers_pytorch import ImputerDiffusion
16+
from qolmat.utils import data
1917

2018
# %%
2119
# 1. Time-series data

0 commit comments

Comments
 (0)