Skip to content

Commit

Permalink
ci: improve tests_local workflow (#103)
Browse files Browse the repository at this point in the history
* ci: improve tests_local workflow

* ci: switch license checking framework

* ci: Switch from pydocstyle to ruff to check docstrings

* ci: change name of coverage report artifact
  • Loading branch information
leahaeusel authored Jan 23, 2025
1 parent 45f6f37 commit 088d977
Show file tree
Hide file tree
Showing 27 changed files with 158 additions and 110 deletions.
47 changes: 40 additions & 7 deletions .github/workflows/tests_local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
name: tests_local

on:
schedule:
- cron: '0 1 * * *'
pull_request:
push:
branches:
Expand Down Expand Up @@ -37,19 +39,50 @@ jobs:
uses: ./.github/actions/create_python_environment
- name: Get Python package manager
run: echo "PYTHON_PACKAGE_MANAGER=${{steps.environment.outputs.ppm}}" >> $GITHUB_ENV
- name: Codechecks
- name: Code checks
run: |
$PYTHON_PACKAGE_MANAGER activate queens
isort --check-only queens tests > track_isort.txt 2>&1
black --check queens tests > track_black.txt 2>&1
pylint --rcfile=.pylintrc_ci queens tests | tee track_pylint.txt 2>&1
pylint queens tests --rcfile=.pylintrc --output-format=json:pylint_warnings.json --fail-under 0
python .gitlab/pipeline_utils/code_quality_creator.py pylint_warnings.json
pydocstyle --match-dir='^(?!.*test).*$' queens > track_pydocstyle.txt 2>&1
echo "::group::Run isort..."
isort --check-only queens tests
echo "::endgroup::"
echo "::group::Run black..."
black --check queens tests
echo "::endgroup::"
echo "::group::Run pylint..."
pylint --rcfile=.pylintrc_ci queens tests
echo "::endgroup::"
echo "::group::Run ruff..."
ruff check
echo "::endgroup::"
# echo "::group::Create code quality report..."
# pylint queens tests --rcfile=.pylintrc --output-format=json:pylint_warnings.json --fail-under 0
# python .gitlab/pipeline_utils/code_quality_creator.py pylint_warnings.json
# echo "::endgroup::"
echo "::group::Check compatibility with licenses of dependencies..."
liccheck -r requirements.txt
echo "::endgroup::"
echo "::group::Create an rc file for the license header check..."
python .gitlab/pipeline_utils/create_licenserc.py --template_file ".gitlab/pipeline_utils/.licenserc_template.yaml" --text_file "license_header.tmpl" --output_file ".licenserc.yaml" --placeholder "license_header"
echo "::endgroup::"
- name: Check License headers
uses: apache/skywalking-eyes/[email protected]
- name: Run pytest
run: |
$PYTHON_PACKAGE_MANAGER activate queens
pytest -v -m "unit_tests or integration_tests or integration_tests_fourc" --cov --cov-report=term --cov-report=html:html_coverage_report --cov-report=xml:xml_coverage_report.xml $TEST_TIMING_OPTION --color=yes -o junit_logging=all --junitxml=test_junit.xml
- name: Upload coverage report
uses: actions/upload-pages-artifact@v3
with:
name: html-coverage-report
path: html_coverage_report/
retention-days: 7
- name: Publish junit pytest report
uses: mikepenz/action-junit-report@v5
if: success() || failure() # always run even if the previous step fails
Expand Down
5 changes: 3 additions & 2 deletions .gitlab/pipeline_utils/update_changelog.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# SPDX-License-Identifier: LGPL-3.0-or-later
# Copyright (c) 2024, QUEENS contributors.
# Copyright (c) 2025, QUEENS contributors.
#
# This file is part of QUEENS.
#
Expand All @@ -17,7 +17,7 @@
import sys
from pathlib import Path

import gitlab
import gitlab # pylint: disable=import-error

CHANGE_KEY = "change:"

Expand All @@ -28,6 +28,7 @@ def create_section(name, link, date, message, header_symbol, newline=True):
Args:
name (str): Name of the tag
link (str): Link of the tag
date (obj): Date of the tag
message (str): Tag message
header_symbol (str): Symbol of the section
newline (bool): Add newline after the section name
Expand Down
13 changes: 7 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
default_stages: [pre-commit, pre-merge-commit, pre-push, manual]
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.2 # Ruff version
hooks:
# Run the linter.
# Needs to placed before black, isort, and other formatters
- id: ruff
args: [ --fix ]
- repo: local
hooks:
- id: trailing-whitespace
Expand All @@ -24,12 +31,6 @@ repos:
language: python
types: ["python"]
pass_filenames: true
- id: pydocstyle
name: pydocstyle
entry: pydocstyle
language: python
types: ["python"]
additional_dependencies: ["toml"]
- id: docformatter
name: docformatter
entry: docformatter
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ will lead to failing CI pipelines and will therefore not be merged.
The code checks are conducted with [Pylint](https://pylint.org/),
[isort](https://github.com/PyCQA/isort), and [Black](https://github.com/psf/black).
Compliance with [Google style docstrings](https://github.com/google/styleguide/blob/gh-pages/pyguide.md#38-comments-and-docstrings)
is checked with [pydocstyle](https://github.com/PyCQA/pydocstyle).
is checked with [ruff](https://github.com/astral-sh/ruff).
Complete and meaningful docstrings are required as they are used to generate the
[documentation](#reading-and-writing-documentation).

Expand Down
2 changes: 1 addition & 1 deletion dev-requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ pydata-sphinx-theme
pandoc
pip-tools
commitizen>=3.12.0
pydocstyle>=6.3.0
docformatter>=1.5.1
yamllint>=1.19.0
ruff
8 changes: 3 additions & 5 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,6 @@ prompt-toolkit==3.0.36
# via questionary
pydata-sphinx-theme==0.16.0
# via -r dev-requirements.in
pydocstyle==6.3.0
# via -r dev-requirements.in
pygments==2.18.0
# via
# -c requirements.txt
Expand Down Expand Up @@ -214,6 +212,8 @@ ruamel-yaml==0.18.6
# via pre-commit-hooks
ruamel-yaml-clib==0.2.12
# via ruamel-yaml
ruff==0.9.2
# via -r dev-requirements.in
semantic-version==2.10.0
# via liccheck
six==1.16.0
Expand All @@ -222,9 +222,7 @@ six==1.16.0
# bleach
# python-dateutil
snowballstemmer==2.2.0
# via
# pydocstyle
# sphinx
# via sphinx
soupsieve==2.6
# via beautifulsoup4
sphinx==8.1.3
Expand Down
48 changes: 0 additions & 48 deletions lic_strategy.ini

This file was deleted.

62 changes: 59 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ force_grid_wrap = 0
multi_line_output = 3
include_trailing_comma = true

[tool.pydocstyle]
[tool.ruff.lint]
select = ["D"] # pydocstyle rules
ignore = ["D104"] # Missing docstring in public package

[tool.ruff.lint.pydocstyle]
convention = "google"
match-dir = '(?!tests).*'
match = '(?!__init__).*\.py'

[tool.pytest.ini_options]
addopts = '-m "not benchmark and not lnm_cluster and not imcs_cluster" --doctest-modules --doctest-continue-on-failure --doctest-ignore-import-errors'
Expand Down Expand Up @@ -92,3 +94,57 @@ show_missing = false

[tool.coverage.html]
directory = "html_coverage_report"

[tool.liccheck]
authorized_licenses = [
"apache",
"apache 2.0",
"Apache-2.0",
"apache software license",
"apache license, version 2.0",
"apache license version 2.0",
"apache license 2.0",
"apache software",
"bsd",
"new bsd",
"bsd license",
"new bsd license",
"3-clause bsd",
"BSD 3-Clause",
"BSD-3-Clause",
"simplified bsd",
"CMU License (MIT-CMU)",
"gnu lgpl",
"GNU Library or Lesser General Public License (LGPL)",
"lgpl",
"historical permission notice and disclaimer (hpnd)",
"isc",
"isc license",
"isc license (iscl)",
"mit",
"mit license",
"mozilla public license 2.0",
"mozilla public license 2.0 (mpl 2.0)",
"python software foundation",
"python software foundation license",
"University of Illinois/NCSA Open Source",
"zlib/libpng",
]
unauthorized_licenses = [
"gpl v3",
"gpl v2",
"gpl",
"GNU general public license (gpl)",
"IBM Public License",
"RPL",
"Reciprocal Public License",
"Sleepycat License",
]
[tool.liccheck.authorized_packages]
# filelock has public domain license without restrictions
# see https://github.com/tox-dev/py-filelock
filelock = ">=3"
# cons is under LGPL-3
cons = ">=0.4.5"
# namex is under Apache 2.0 see https://github.com/fchollet/namex?tab=License-1-ov-file
namex = "==0.0.8"
5 changes: 3 additions & 2 deletions queens/data_processor/data_processor_ensight.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# SPDX-License-Identifier: LGPL-3.0-or-later
# Copyright (c) 2024, QUEENS contributors.
# Copyright (c) 2025, QUEENS contributors.
#
# This file is part of QUEENS.
#
Expand Down Expand Up @@ -445,6 +445,7 @@ def _vtk_from_ensight(self, raw_data, target_time):
"""Load a vtk-object from the ensight file.
Args:
raw_data (obj): Raw data from file
target_time (float): Time the field should be evaluated on
Returns:
Expand Down Expand Up @@ -488,7 +489,7 @@ def read_geometry_coordinates(external_geometry):
This method uses the QUEENS external geometry module.
Args:
external_geometry_obj (queens.fourc_dat_geometry)
external_geometry (queens.fourc_dat_geometry): QUEENS external geometry object
Returns:
dict: set with 4C topology
Expand Down
3 changes: 2 additions & 1 deletion queens/data_processor/data_processor_ensight_interface.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# SPDX-License-Identifier: LGPL-3.0-or-later
# Copyright (c) 2024, QUEENS contributors.
# Copyright (c) 2025, QUEENS contributors.
#
# This file is part of QUEENS.
#
Expand Down Expand Up @@ -442,6 +442,7 @@ def deformed_grid(self, raw_data, time):
such that the final result is the deformed grid at the specified time.
Args:
raw_data (obj): Raw data from file
time (float): Time value for data processing
Returns:
Expand Down
4 changes: 2 additions & 2 deletions queens/external_geometry/fourc_dat_geometry.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# SPDX-License-Identifier: LGPL-3.0-or-later
# Copyright (c) 2024, QUEENS contributors.
# Copyright (c) 2025, QUEENS contributors.
#
# This file is part of QUEENS.
#
Expand Down Expand Up @@ -1153,7 +1153,7 @@ def _get_my_topology(self, geo_set_name_type):
I.e.e its node mappings, based on the type of the geometric set.
Args:
geo_set_name_type:
geo_set_name_type (str): Name of the geometric set type.
Returns:
my_topology (lst): List with desired geometric topology
Expand Down
4 changes: 3 additions & 1 deletion queens/interfaces/bmfmc_interface.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# SPDX-License-Identifier: LGPL-3.0-or-later
# Copyright (c) 2024, QUEENS contributors.
# Copyright (c) 2025, QUEENS contributors.
#
# This file is part of QUEENS.
#
Expand Down Expand Up @@ -61,6 +61,8 @@ def evaluate(self, samples, support="y", full_cov=False, gradient_bool=False):
*support=f* the Gaussian process predicts w.r.t. the latent function
*f*. For the choice of *support=y* we predict w.r.t. the
simulation/experimental output *y*
full_cov (bool): Boolean that specifies whether the entire posterior covariance matrix
should be returned or only the posterior variance
gradient_bool (bool): Flag to determine whether the gradient of the function at
the evaluation point is expected (*True*) or not (*False*)
Expand Down
5 changes: 3 additions & 2 deletions queens/iterators/bmfia_iterator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# SPDX-License-Identifier: LGPL-3.0-or-later
# Copyright (c) 2024, QUEENS contributors.
# Copyright (c) 2025, QUEENS contributors.
#
# This file is part of QUEENS.
#
Expand Down Expand Up @@ -397,6 +397,7 @@ def _get_coord_features(self, _, y_lf_mat, coords_mat):
and colum-wise variable dimensions.
y_lf_mat (np.array): Low-fidelity output matrix with row-wise model realizations.
Columns are different dimensions of the output.
coords_mat (np.array): Coordinates matrix.
Returns:
z_mat (np.array): Extended low-fidelity matrix containing
Expand Down Expand Up @@ -454,7 +455,7 @@ def _get_no_features(self, _x_mat, y_lf_mat, __):
def _get_time_features(self, _, y_lf_mat, __):
"""Get the low-fidelity feature matrix with time features.
Args:
Args:
y_lf_mat (np.array): Low-fidelity output matrix with row-wise model realizations.
Columns are different dimensions of the output.
Expand Down
Loading

0 comments on commit 088d977

Please sign in to comment.