From 2a6b9db9efbe081528f719277d5d3529003525a4 Mon Sep 17 00:00:00 2001 From: Johannes Kasimir Date: Fri, 10 Nov 2023 10:49:54 +0100 Subject: [PATCH 1/3] update copier --- .copier-answers.yml | 2 +- .github/workflows/nightly_at_main.yml | 2 +- .github/workflows/nightly_at_release.yml | 2 +- .github/workflows/unpinned.yml | 43 ++++++++++++++++++++++++ .pre-commit-config.yaml | 15 ++++----- CODE_OF_CONDUCT.md | 2 +- docs/developer/getting-started.md | 6 ++-- pyproject.toml | 2 ++ requirements/make_base.py | 24 +++++++------ tox.ini | 9 ++++- 10 files changed, 81 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/unpinned.yml diff --git a/.copier-answers.yml b/.copier-answers.yml index 5689fe22..9018787d 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,5 +1,5 @@ # Changes here will be overwritten by Copier; NEVER EDIT MANUALLY -_commit: d9ab46a +_commit: 9cf97d4 _src_path: gh:scipp/copier_template description: Reflectometry data reduction for the European Spallation Source max_python: '3.12' diff --git a/.github/workflows/nightly_at_main.yml b/.github/workflows/nightly_at_main.yml index 67d31d87..f83c0c36 100644 --- a/.github/workflows/nightly_at_main.yml +++ b/.github/workflows/nightly_at_main.yml @@ -6,7 +6,7 @@ name: Nightly test at main branch on: workflow_dispatch: schedule: - - cron: '30 23 * * *' + - cron: '30 1 * * 1-5' jobs: setup: diff --git a/.github/workflows/nightly_at_release.yml b/.github/workflows/nightly_at_release.yml index b424c664..f9d811a0 100644 --- a/.github/workflows/nightly_at_release.yml +++ b/.github/workflows/nightly_at_release.yml @@ -6,7 +6,7 @@ name: Nightly tests at latest release on: workflow_dispatch: schedule: - - cron: '0 23 * * *' + - cron: '0 1 * * 1-5' jobs: setup: diff --git a/.github/workflows/unpinned.yml b/.github/workflows/unpinned.yml new file mode 100644 index 00000000..dbb546f4 --- /dev/null +++ b/.github/workflows/unpinned.yml @@ -0,0 +1,43 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (c) 2023 Scipp contributors (https://github.com/scipp) + +name: Unpinned tests at latest release + +on: + workflow_dispatch: + schedule: + - cron: '0 2 * * 1' + +jobs: + setup: + name: Setup variables + runs-on: 'ubuntu-20.04' + outputs: + min_python: ${{ steps.vars.outputs.min_python }} + release_tag: ${{ steps.release.outputs.release_tag }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # history required so we can determine latest release tag + - name: Get last release tag from git + id: release + run: echo "release_tag=$(git describe --tags --abbrev=0 --match '[0-9]*.[0-9]*.[0-9]*')" >> $GITHUB_OUTPUT + - name: Get Python version for other CI jobs + id: vars + run: echo "min_python=$(cat .github/workflows/python-version-ci)" >> $GITHUB_OUTPUT + + tests: + name: Tests + needs: setup + strategy: + matrix: + os: ['ubuntu-20.04'] + python: + - version: '${{needs.setup.outputs.min_python}}' + tox-env: 'unpinned' + uses: ./.github/workflows/test.yml + with: + os-variant: ${{ matrix.os }} + python-version: ${{ matrix.python.version }} + tox-env: ${{ matrix.python.tox-env }} + checkout_ref: ${{ needs.setup.outputs.release_tag }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a8b47569..6a86994b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.5.0 hooks: - id: check-added-large-files - id: check-json @@ -18,7 +18,7 @@ repos: - id: isort name: isort (python) - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.9.0 + rev: 23.11.0 hooks: - id: black - repo: https://github.com/kynan/nbstripout @@ -29,28 +29,27 @@ repos: args: [ "--drop-empty-cells", "--extra-keys 'metadata.language_info.version cell.metadata.jp-MarkdownHeadingCollapsed cell.metadata.pycharm'" ] - repo: https://github.com/pycqa/flake8 - rev: 4.0.1 + rev: 6.1.0 hooks: - id: flake8 types: ["python"] - additional_dependencies: ["flake8-bugbear==22.10.27"] + additional_dependencies: ["flake8-bugbear==23.9.16"] - repo: https://github.com/pycqa/bandit - rev: 1.7.4 + rev: 1.7.5 hooks: - id: bandit additional_dependencies: ["bandit[toml]"] args: ["-c", "pyproject.toml"] - repo: https://github.com/codespell-project/codespell - rev: v2.2.2 + rev: v2.2.6 hooks: - id: codespell additional_dependencies: - tomli - repo: https://github.com/pre-commit/pygrep-hooks - rev: v1.9.0 + rev: v1.10.0 hooks: - id: python-no-eval - exclude: "object_list.py" - id: python-no-log-warn - id: python-use-type-annotations - id: rst-backticks diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index ff33c0e1..1c3746e4 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -61,7 +61,7 @@ representative at an online or offline event. Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at -scipp@ess.eu. +scipp[at]ess.eu. All complaints will be reviewed and investigated promptly and fairly. All community leaders are obligated to respect the privacy and security of the diff --git a/docs/developer/getting-started.md b/docs/developer/getting-started.md index 88e1036e..abedc848 100644 --- a/docs/developer/getting-started.md +++ b/docs/developer/getting-started.md @@ -78,14 +78,14 @@ tox -e linkcheck Build the documentation using ```sh -python -m sphinx -v -b html -d build/.doctrees docs build/html +python -m sphinx -v -b html -d .tox/docs_doctrees docs html ``` Additionally, test the documentation using ```sh -python -m sphinx -v -b doctest -d build/.doctrees docs build/html -python -m sphinx -v -b linkcheck -d build/.doctrees docs build/html +python -m sphinx -v -b doctest -d .tox/docs_doctrees docs html +python -m sphinx -v -b linkcheck -d .tox/docs_doctrees docs html ``` ```` ````` diff --git a/pyproject.toml b/pyproject.toml index 73eefb72..8aab9479 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,6 +46,7 @@ dynamic = ["version"] [project.urls] "Bug Tracker" = "https://github.com/scipp/essreflectometry/issues" +"Documentation" = "https://scipp.github.io/essreflectometry" "Source" = "https://github.com/scipp/essreflectometry" [tool.setuptools_scm] @@ -70,6 +71,7 @@ skip-string-normalization = true [tool.isort] skip_gitignore = true profile = "black" +known_first_party = ["essreflectometry"] [tool.mypy] strict = true diff --git a/requirements/make_base.py b/requirements/make_base.py index 27a23c2f..3bc6ee51 100644 --- a/requirements/make_base.py +++ b/requirements/make_base.py @@ -1,5 +1,6 @@ import sys from argparse import ArgumentParser +from typing import List import tomli @@ -12,7 +13,14 @@ ) args = parser.parse_args() -header = "# Generated by 'tox -e deps', DO NOT EDIT MANUALLY!'\n" + +def write_dependencies(dependency_name: str, dependencies: List[str]) -> None: + header = "# Generated by 'tox -e deps', DO NOT EDIT MANUALLY!'\n" + with open(f"{dependency_name}.in", "w") as f: + f.write(header) + f.write("\n".join(dependencies)) + f.write("\n") + with open("../pyproject.toml", "rb") as toml_file: pyproject = tomli.load(toml_file) @@ -21,9 +29,7 @@ raise RuntimeError("No dependencies found in pyproject.toml") dependencies = [dep.strip().strip('"') for dep in dependencies] -with open("base.in", "w") as f: - f.write(header) - f.write("\n".join(dependencies)) +write_dependencies("base", dependencies) def as_nightly(repo: str) -> str: @@ -39,10 +45,8 @@ def as_nightly(repo: str) -> str: return f"{repo} @ git+https://github.com/{org}/{repo}@main" -nightly = args.nightly.split(",") if args.nightly else [] -dependencies = [dep for dep in dependencies if not dep.startswith(tuple(nightly))] -dependencies += [as_nightly(arg) for arg in nightly] +nightly = tuple(args.nightly.split(",") if args.nightly else []) +nightly_dependencies = [dep for dep in dependencies if not dep.startswith(nightly)] +nightly_dependencies += [as_nightly(arg) for arg in nightly] -with open("nightly.in", "w") as f: - f.write(header) - f.write("\n".join(dependencies)) +write_dependencies("nightly", nightly_dependencies) diff --git a/tox.ini b/tox.ini index 2d5cdb15..f2c27181 100644 --- a/tox.ini +++ b/tox.ini @@ -6,7 +6,7 @@ isolated_build = true deps = -r requirements/test.txt setenv = JUPYTER_PLATFORM_DIRS = 1 -commands = pytest +commands = pytest {posargs} [testenv:nightly] deps = @@ -14,6 +14,13 @@ deps = pytest commands = pytest +[testenv:unpinned] +description = Test with unpinned dependencies, as a user would install now. +deps = + essreflectometry + pytest +commands = pytest + [testenv:docs] description = invoke sphinx-build to build the HTML docs deps = -r requirements/docs.txt From 1b8ca422d660ff7271a5fc8d58de47121090160c Mon Sep 17 00:00:00 2001 From: Johannes Kasimir Date: Fri, 10 Nov 2023 10:53:47 +0100 Subject: [PATCH 2/3] fix: set warning stack level 2 --- src/essreflectometry/orso.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/essreflectometry/orso.py b/src/essreflectometry/orso.py index a0906769..c824ca09 100644 --- a/src/essreflectometry/orso.py +++ b/src/essreflectometry/orso.py @@ -11,4 +11,5 @@ def not_found_warning(): "For metadata to be logged in the data array, " "it is necessary to install the orsopy package.", UserWarning, + stacklevel=2, ) From 65a15fcba876e1dc10f45a85c04dee5fd9d4ccf8 Mon Sep 17 00:00:00 2001 From: Johannes Kasimir Date: Fri, 10 Nov 2023 10:57:29 +0100 Subject: [PATCH 3/3] style: flake8 line width --- src/essreflectometry/types.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/essreflectometry/types.py b/src/essreflectometry/types.py index 25c3c4a9..2c17c438 100644 --- a/src/essreflectometry/types.py +++ b/src/essreflectometry/types.py @@ -24,15 +24,16 @@ class ThetaData(sciline.Scope[Run, sc.DataArray], sc.DataArray): class QData(sciline.Scope[Run, sc.DataArray], sc.DataArray): - """Event data with wavelength, incidence angle and momentum transfer computed per event. + """Event data with wavelength, incidence angle, + and momentum transfer computed per event. Binned by momentum transfer according to the QBins provider, and by `detector_number` (pixel of the detector frame). """ class FootprintCorrectedData(sciline.Scope[Run, sc.DataArray], sc.DataArray): - """Event data with weight corrected for the footprint of the beam on the sample for the - incidence angle of the event.""" + """Event data with weight corrected for the footprint of the beam + on the sample for the incidence angle of the event.""" SpecularReflectionCoordTransformGraph = NewType(