From 46ed16b904b4e8df3f05e6f362f5f7838c1bc5b2 Mon Sep 17 00:00:00 2001 From: Fabio Date: Mon, 25 Nov 2024 17:57:14 -0300 Subject: [PATCH 1/3] Add support for python 3.12 --- .github/workflows/deploy-pypi.yml | 2 +- .github/workflows/test-pr.yml | 2 +- setup.cfg | 2 +- setup.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy-pypi.yml b/.github/workflows/deploy-pypi.yml index 8138ae81..606ced04 100644 --- a/.github/workflows/deploy-pypi.yml +++ b/.github/workflows/deploy-pypi.yml @@ -12,7 +12,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] os: [ubuntu-latest, macOS-latest, windows-latest] steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/test-pr.yml b/.github/workflows/test-pr.yml index 7a4343a4..34e5cca5 100644 --- a/.github/workflows/test-pr.yml +++ b/.github/workflows/test-pr.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] os: [ubuntu-latest, macOS-latest, windows-latest] steps: - uses: actions/checkout@v2 diff --git a/setup.cfg b/setup.cfg index 11c68c15..27599a0b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -14,7 +14,7 @@ exclude = **/__init__.py, docs/source/conf.py ;file.py: error [requires] -python_version = ">=3.8,<3.12" +python_version = ">=3.8,<3.13" # See the docstring in versioneer.py for instructions. Note that you must # re-run 'versioneer.py setup' after changing this section, and commit the diff --git a/setup.py b/setup.py index 39fb9a0d..c5d7a4e2 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ URL_ISSUES = "https://github.com/scikit-learn-contrib/hiclass/issues" EMAIL = "fabio.malchermiranda@hpi.de, Niklas.Koehnecke@student.hpi.uni-potsdam.de" AUTHOR = "Fabio Malcher Miranda, Niklas Koehnecke" -REQUIRES_PYTHON = ">=3.8,<3.12" +REQUIRES_PYTHON = ">=3.8,<3.13" KEYWORDS = ["hierarchical classification"] DACS_SOFTWARE = "https://gitlab.com/dacs-hpi" # What packages are required for this module to be executed? From 83ee6e895181650ce99e41a29fc72e60281fa84e Mon Sep 17 00:00:00 2001 From: Fabio Date: Mon, 25 Nov 2024 18:12:30 -0300 Subject: [PATCH 2/3] Remove flake8 and pydocstyle from pytest command --- .github/workflows/deploy-pypi.yml | 4 +++- .github/workflows/test-pr.yml | 4 +++- hiclass/HierarchicalClassifier.py | 4 ++-- hiclass/LocalClassifierPerLevel.py | 4 ++-- setup.py | 8 +++----- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.github/workflows/deploy-pypi.yml b/.github/workflows/deploy-pypi.yml index 606ced04..f8acb080 100644 --- a/.github/workflows/deploy-pypi.yml +++ b/.github/workflows/deploy-pypi.yml @@ -26,7 +26,9 @@ jobs: python -m pip install -e ".[dev]" - name: Test with pytest run: | - pytest -v --flake8 --pydocstyle --cov=hiclass --cov-fail-under=90 --cov-report html + flake8 + pydocstyle + pytest -v --cov=hiclass --cov-fail-under=90 --cov-report html coverage xml - name: Upload Coverage to Codecov if: matrix.os == 'ubuntu-latest' diff --git a/.github/workflows/test-pr.yml b/.github/workflows/test-pr.yml index 34e5cca5..7cdb3c3b 100644 --- a/.github/workflows/test-pr.yml +++ b/.github/workflows/test-pr.yml @@ -27,7 +27,9 @@ jobs: python -m pip install -e ".[dev]" - name: Test with pytest run: | - pytest -v --flake8 --pydocstyle --cov=hiclass --cov-fail-under=90 --cov-report html + flake8 + pydocstyle hiclass tests + pytest -v --cov=hiclass --cov-fail-under=90 --cov-report html coverage xml - name: Upload Coverage to Codecov uses: codecov/codecov-action@v2 diff --git a/hiclass/HierarchicalClassifier.py b/hiclass/HierarchicalClassifier.py index 75ec94c6..e23915b1 100644 --- a/hiclass/HierarchicalClassifier.py +++ b/hiclass/HierarchicalClassifier.py @@ -443,7 +443,7 @@ def _fit_node_classifier( self, nodes, local_mode: bool = False, use_joblib: bool = False ): def logging_wrapper(func, idx, node, node_length): - self.logger_.info(f"fitting node {idx+1}/{node_length}: {str(node)}") + self.logger_.info(f"fitting node {idx + 1}/{node_length}: {str(node)}") return func(self, node) if self.n_jobs > 1: @@ -481,7 +481,7 @@ def _fit_node_calibrator( self, nodes, local_mode: bool = False, use_joblib: bool = False ): def logging_wrapper(func, idx, node, node_length): - self.logger_.info(f"calibrating node {idx+1}/{node_length}: {str(node)}") + self.logger_.info(f"calibrating node {idx + 1}/{node_length}: {str(node)}") return func(self, node) if self.n_jobs > 1: diff --git a/hiclass/LocalClassifierPerLevel.py b/hiclass/LocalClassifierPerLevel.py index 94680ab4..680e2146 100644 --- a/hiclass/LocalClassifierPerLevel.py +++ b/hiclass/LocalClassifierPerLevel.py @@ -350,7 +350,7 @@ def _fit_digraph(self, local_mode: bool = False, use_joblib: bool = False): self.logger_.info("Fitting local classifiers") def logging_wrapper(func, level, separator, max_level): - self.logger_.info(f"fitting level {level+1}/{max_level}") + self.logger_.info(f"fitting level {level + 1}/{max_level}") return func(self, level, separator) if self.n_jobs > 1: @@ -395,7 +395,7 @@ def _calibrate_digraph(self, local_mode: bool = False, use_joblib: bool = False) self.logger_.info("Fitting local calibrators") def logging_wrapper(func, level, separator, max_level): - self.logger_.info(f"calibrating level {level+1}/{max_level}") + self.logger_.info(f"calibrating level {level + 1}/{max_level}") return func(self, level, separator) if self.n_jobs > 1: diff --git a/setup.py b/setup.py index c5d7a4e2..1c362c1e 100644 --- a/setup.py +++ b/setup.py @@ -35,11 +35,9 @@ "ray": ["ray>=1.11.0"], "xai": ["shap==0.44.1", "xarray==2023.1.0"], "dev": [ - "flake8==4.0.1", - "pytest==7.1.2", - "pytest-flake8==1.1.1", - "pydocstyle==6.1.1", - "pytest-pydocstyle==2.3.0", + "flake8", + "pytest", + "pydocstyle", "pytest-cov==3.0.0", "pyfakefs==5.3.5", "black==24.2.0", From ad5972d2237a0b4889d2e63575ecb50eb7caf4c6 Mon Sep 17 00:00:00 2001 From: Fabio Date: Mon, 25 Nov 2024 18:19:28 -0300 Subject: [PATCH 3/3] Add flake8 and pydocstyle to precommit --- .github/workflows/deploy-pypi.yml | 2 +- .pre-commit-config.yaml | 9 +++++++++ CONTRIBUTING.md | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-pypi.yml b/.github/workflows/deploy-pypi.yml index f8acb080..47d58e29 100644 --- a/.github/workflows/deploy-pypi.yml +++ b/.github/workflows/deploy-pypi.yml @@ -27,7 +27,7 @@ jobs: - name: Test with pytest run: | flake8 - pydocstyle + pydocstyle hiclass tests pytest -v --cov=hiclass --cov-fail-under=90 --cov-report html coverage xml - name: Upload Coverage to Codecov diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d2b6eade..9314179a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,3 +9,12 @@ repos: rev: 24.2.0 hooks: - id: black + - repo: https://github.com/pycqa/flake8 + rev: 7.1.1 + hooks: + - id: flake8 + - repo: https://github.com/pycqa/pydocstyle + rev: 6.3.0 + hooks: + - id: pydocstyle + files: ^hiclass/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1348c85f..9189fd7a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,7 +19,7 @@ pip install -e ".[dev]" To run the tests simply execute: ``` -pytest -v --flake8 --pydocstyle --cov=hiclass --cov-fail-under=90 --cov-report html +pytest -v --cov=hiclass --cov-fail-under=90 --cov-report html ``` Lastly, you can set up the git hooks scripts to fix formatting errors locally during commits: