From f757f1a3741db2a7d95a3304146e6ef990e07280 Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Wed, 25 Oct 2023 00:39:36 -0500 Subject: [PATCH] chore(backport): Update GitHub Actions and pre-commit hooks (#2359) * Backport: - PR https://github.com/scikit-hep/pyhf/pull/2332 - PR https://github.com/scikit-hep/pyhf/pull/2333 - PR https://github.com/scikit-hep/pyhf/pull/2334 - PR https://github.com/scikit-hep/pyhf/pull/2335 - PR https://github.com/scikit-hep/pyhf/pull/2337 - PR https://github.com/scikit-hep/pyhf/pull/2343 --- .github/workflows/docker.yml | 14 +++++++------- .github/workflows/publish-package.yml | 11 ++++++++++- .pre-commit-config.yaml | 15 ++++++--------- docs/faq.rst | 2 +- docs/governance/ROADMAP.rst | 2 +- src/pyhf/contrib/viz/brazil.py | 2 +- src/pyhf/tensor/jax_backend.py | 4 ++-- src/pyhf/tensor/numpy_backend.py | 4 ++-- src/pyhf/tensor/pytorch_backend.py | 4 ++-- src/pyhf/tensor/tensorflow_backend.py | 4 ++-- 10 files changed, 34 insertions(+), 28 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 245f11ec71..bd9b5527f4 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -54,21 +54,21 @@ jobs: echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Login to DockerHub if: github.event_name != 'pull_request' - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Login to GitHub Container Registry if: github.event_name != 'pull_request' - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} @@ -76,7 +76,7 @@ jobs: - name: Test build id: docker_build_test - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 with: context: . file: docker/Dockerfile @@ -114,7 +114,7 @@ jobs: # every PR will trigger a push event on main, so check the push event is actually coming from main if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'scikit-hep/pyhf' id: docker_build_latest - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 with: context: . file: docker/Dockerfile @@ -131,7 +131,7 @@ jobs: - name: Build and publish to registry with release tag if: github.event_name == 'release' && github.event.action == 'published' && github.repository == 'scikit-hep/pyhf' id: docker_build_release - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 with: context: . file: docker/Dockerfile diff --git a/.github/workflows/publish-package.yml b/.github/workflows/publish-package.yml index eb956eb506..187391b1a3 100644 --- a/.github/workflows/publish-package.yml +++ b/.github/workflows/publish-package.yml @@ -11,6 +11,9 @@ on: - release/v* release: types: [published] + # Run weekly at 1:23 UTC + schedule: + - cron: '23 1 * * 0' workflow_dispatch: inputs: publish: @@ -44,7 +47,13 @@ jobs: python -m pip install build twine python -m pip list - - name: Build a wheel and a sdist + - name: Build a sdist and wheel + if: github.event_name != 'schedule' + run: | + python -m build . + + - name: Build a sdist and wheel and check for warnings + if: github.event_name == 'schedule' run: | PYTHONWARNINGS=error,default::DeprecationWarning python -m build . diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 581b2b5c2e..1087037b32 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,14 +26,14 @@ repos: # exclude generated files exclude: ^validation/|\.dtd$|\.xml$ -- repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.0.287" - hooks: +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: "v0.0.292" + hooks: - id: ruff args: ["--fix", "--show-fixes"] - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.7.0 + rev: 23.9.1 hooks: - id: black-jupyter @@ -46,9 +46,6 @@ repos: - repo: https://github.com/pre-commit/mirrors-mypy rev: v1.5.1 # check the oldest and newest supported Pythons - # Though use Python 3.8 as the oldest Python to run mypy - # to avoid positional-only errors from NumPy in Python 3.11 - # runtime. hooks: - &mypy id: mypy @@ -65,11 +62,11 @@ repos: rev: 1.7.0 hooks: - id: nbqa-ruff - additional_dependencies: [ruff==0.0.287] + additional_dependencies: [ruff==0.0.292] args: ["--extend-ignore=F821,F401,F841,F811"] - repo: https://github.com/codespell-project/codespell - rev: v2.2.5 + rev: v2.2.6 hooks: - id: codespell files: ^.*\.(py|md|rst)$ diff --git a/docs/faq.rst b/docs/faq.rst index d821139463..48339ebb8e 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -141,7 +141,7 @@ How did ``pyhf`` get started? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In 2017 Lukas Heinrich was discussing with colleauge Holger Schulz how it would be convenient -to share and produce statistical results from LHC experiements if they were able to be +to share and produce statistical results from LHC experiments if they were able to be created with tools that didn't require the large ``C++`` dependencies and tooling expertise as :math:`\HiFa{}`. Around the same time that Lukas began thinking on these ideas, Matthew Feickert was working on diff --git a/docs/governance/ROADMAP.rst b/docs/governance/ROADMAP.rst index 65992ac5db..d3bca0d2f5 100644 --- a/docs/governance/ROADMAP.rst +++ b/docs/governance/ROADMAP.rst @@ -7,7 +7,7 @@ This is the pyhf 2019 into 2020 Roadmap (Issue Overview and Goals ------------------ -We will follow loosely Seibert’s `Heirarchy of +We will follow loosely Seibert’s `Hierarchy of Needs `__ |Seibert Hierarchy of Needs SciPy 2019| (`Stan diff --git a/src/pyhf/contrib/viz/brazil.py b/src/pyhf/contrib/viz/brazil.py index 4e25a63c1b..a8955f20eb 100644 --- a/src/pyhf/contrib/viz/brazil.py +++ b/src/pyhf/contrib/viz/brazil.py @@ -112,7 +112,7 @@ def plot_brazil_band(test_pois, cls_obs, cls_exp, test_size, ax, **kwargs): ax (:obj:`matplotlib.axes.Axes`): The matplotlib axis object to plot on. Returns: - :obj:`tuple`: The :obj:`matplotlib.aritst` objects drawn. + :obj:`tuple`: The :obj:`matplotlib.artist` objects drawn. """ line_color = kwargs.pop("color", "black") (cls_obs_line,) = ax.plot( diff --git a/src/pyhf/tensor/jax_backend.py b/src/pyhf/tensor/jax_backend.py index d49bb094a2..f7eef3aff2 100644 --- a/src/pyhf/tensor/jax_backend.py +++ b/src/pyhf/tensor/jax_backend.py @@ -96,8 +96,8 @@ def clip(self, tensor_in, min_value, max_value): Args: tensor_in (:obj:`tensor`): The input tensor object - min_value (:obj:`scalar` or :obj:`tensor` or :obj:`None`): The minimum value to be cliped to - max_value (:obj:`scalar` or :obj:`tensor` or :obj:`None`): The maximum value to be cliped to + min_value (:obj:`scalar` or :obj:`tensor` or :obj:`None`): The minimum value to be clipped to + max_value (:obj:`scalar` or :obj:`tensor` or :obj:`None`): The maximum value to be clipped to Returns: JAX ndarray: A clipped `tensor` diff --git a/src/pyhf/tensor/numpy_backend.py b/src/pyhf/tensor/numpy_backend.py index 2a11291346..69e45c507c 100644 --- a/src/pyhf/tensor/numpy_backend.py +++ b/src/pyhf/tensor/numpy_backend.py @@ -98,8 +98,8 @@ def clip( Args: tensor_in (:obj:`tensor`): The input tensor object - min_value (:obj:`scalar` or :obj:`tensor` or :obj:`None`): The minimum value to be cliped to - max_value (:obj:`scalar` or :obj:`tensor` or :obj:`None`): The maximum value to be cliped to + min_value (:obj:`scalar` or :obj:`tensor` or :obj:`None`): The minimum value to be clipped to + max_value (:obj:`scalar` or :obj:`tensor` or :obj:`None`): The maximum value to be clipped to Returns: NumPy ndarray: A clipped `tensor` diff --git a/src/pyhf/tensor/pytorch_backend.py b/src/pyhf/tensor/pytorch_backend.py index bfb59f4b13..b7cb96dcf8 100644 --- a/src/pyhf/tensor/pytorch_backend.py +++ b/src/pyhf/tensor/pytorch_backend.py @@ -49,8 +49,8 @@ def clip(self, tensor_in, min_value, max_value): Args: tensor_in (:obj:`tensor`): The input tensor object - min_value (:obj:`scalar` or :obj:`tensor` or :obj:`None`): The minimum value to be cliped to - max_value (:obj:`scalar` or :obj:`tensor` or :obj:`None`): The maximum value to be cliped to + min_value (:obj:`scalar` or :obj:`tensor` or :obj:`None`): The minimum value to be clipped to + max_value (:obj:`scalar` or :obj:`tensor` or :obj:`None`): The maximum value to be clipped to Returns: PyTorch tensor: A clipped `tensor` diff --git a/src/pyhf/tensor/tensorflow_backend.py b/src/pyhf/tensor/tensorflow_backend.py index a0fb84ad8d..7a7a997a5d 100644 --- a/src/pyhf/tensor/tensorflow_backend.py +++ b/src/pyhf/tensor/tensorflow_backend.py @@ -46,8 +46,8 @@ def clip(self, tensor_in, min_value, max_value): Args: tensor_in (:obj:`tensor`): The input tensor object - min_value (:obj:`scalar` or :obj:`tensor` or :obj:`None`): The minimum value to be cliped to - max_value (:obj:`scalar` or :obj:`tensor` or :obj:`None`): The maximum value to be cliped to + min_value (:obj:`scalar` or :obj:`tensor` or :obj:`None`): The minimum value to be clipped to + max_value (:obj:`scalar` or :obj:`tensor` or :obj:`None`): The maximum value to be clipped to Returns: TensorFlow Tensor: A clipped `tensor`