From a342a7bfc00af9faab4891a30beff9a98f0727b4 Mon Sep 17 00:00:00 2001 From: Mridul Seth Date: Mon, 22 Apr 2024 15:45:10 +0200 Subject: [PATCH] run copier update manually to bring the bots over --- .copier-answers.yml | 2 +- .github/workflows/ci.yml | 16 ++--- .github/workflows/copier.yml | 25 +++++++ .github/workflows/docs.yml | 12 ++-- .github/workflows/nightly_at_main.yml | 3 - .github/workflows/nightly_at_release.yml | 3 - .github/workflows/release.yml | 21 +++--- .github/workflows/test.yml | 9 +-- .github/workflows/unpinned.yml | 3 - .gitignore | 1 + conda/meta.yaml | 10 +++ docs/_templates/doc_version.html | 2 +- docs/_typehints.py | 83 ------------------------ docs/conf.py | 33 +++++++--- docs/developer/index.md | 2 +- pyproject.toml | 2 +- requirements/base.in | 3 +- requirements/make_base.py | 5 +- 18 files changed, 91 insertions(+), 144 deletions(-) create mode 100644 .github/workflows/copier.yml delete mode 100644 docs/_typehints.py diff --git a/.copier-answers.yml b/.copier-answers.yml index 338d52c..f0729eb 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,5 +1,5 @@ # Changes here will be overwritten by Copier; NEVER EDIT MANUALLY -_commit: 0b94d03 +_commit: d91bf92 _src_path: gh:scipp/copier_template description: Validate and check NeXus files max_python: '3.12' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 20c647d..44266a2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,3 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright (c) 2023 Scipp contributors (https://github.com/scipp) - name: CI on: @@ -24,15 +21,16 @@ jobs: run: | echo "min_python=$(cat .github/workflows/python-version-ci)" >> $GITHUB_OUTPUT echo "min_tox_env=py$(cat .github/workflows/python-version-ci | sed 's/\.//g')" >> $GITHUB_OUTPUT - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version-file: '.github/workflows/python-version-ci' - - run: python -m pip install --upgrade pip - - run: python -m pip install -r requirements/ci.txt - - run: tox -e static - - uses: stefanzweifel/git-auto-commit-action@v5 + - uses: pre-commit/action@v3.0.1 + with: + extra_args: --all-files + - uses: pre-commit-ci/lite-action@v1.0.2 + if: always() with: - commit_message: Apply automatic formatting + msg: Apply automatic formatting tests: name: Tests diff --git a/.github/workflows/copier.yml b/.github/workflows/copier.yml new file mode 100644 index 0000000..b1fe6ce --- /dev/null +++ b/.github/workflows/copier.yml @@ -0,0 +1,25 @@ +name: Copier template sync + +on: + workflow_dispatch: + schedule: + - cron: '0 1 * * 1' + +jobs: + update: + name: Sync with copier template + runs-on: 'ubuntu-latest' + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.X' + - run: pip install copier + - run: copier update --skip-answered --vcs-ref=HEAD --conflict=rej + - name: Create Pull Request + uses: peter-evans/create-pull-request@v6 + with: + title: '[CRON] Sync with copier template' + body: | + This PR updates the project to the latest version of scipp's [copier-template](https://github.com/scipp/copier_template). + Remember to check for any conflicts and resolve them. diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 5e189fb..ab1be29 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -1,6 +1,3 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright (c) 2023 Scipp contributors (https://github.com/scipp) - name: Docs on: @@ -47,11 +44,12 @@ jobs: runs-on: 'ubuntu-22.04' steps: - run: sudo apt install --yes graphviz pandoc - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: ${{ inputs.branch == '' && github.ref_name || inputs.branch }} + repository: ${{ github.event.pull_request.head.repo.full_name }} fetch-depth: 0 # history required so cmake can determine version - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version-file: '.github/workflows/python-version-ci' - run: python -m pip install --upgrade pip @@ -62,12 +60,12 @@ jobs: if: ${{ inputs.version == '' }} - run: tox -e linkcheck if: ${{ inputs.linkcheck }} - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: docs_html path: html/ - - uses: JamesIves/github-pages-deploy-action@v4.4.3 + - uses: JamesIves/github-pages-deploy-action@v4.5.0 if: ${{ inputs.publish }} with: branch: gh-pages diff --git a/.github/workflows/nightly_at_main.yml b/.github/workflows/nightly_at_main.yml index 1073068..08fdddd 100644 --- a/.github/workflows/nightly_at_main.yml +++ b/.github/workflows/nightly_at_main.yml @@ -1,6 +1,3 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright (c) 2023 Scipp contributors (https://github.com/scipp) - name: Nightly test at main branch on: diff --git a/.github/workflows/nightly_at_release.yml b/.github/workflows/nightly_at_release.yml index 7f1653b..373c454 100644 --- a/.github/workflows/nightly_at_release.yml +++ b/.github/workflows/nightly_at_release.yml @@ -1,6 +1,3 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright (c) 2023 Scipp contributors (https://github.com/scipp) - name: Nightly tests at latest release on: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e492978..d1317a7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,6 +1,3 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright (c) 2023 Scipp contributors (https://github.com/scipp) - name: Release on: @@ -18,7 +15,7 @@ jobs: runs-on: 'ubuntu-22.04' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: true fetch-depth: 0 # history required so setuptools_scm can determine version @@ -31,7 +28,7 @@ jobs: boa - run: conda mambabuild --channel conda-forge --channel scipp --no-anaconda-upload --override-channels --output-folder conda/package conda - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: conda-package-noarch path: conda/package/noarch/*.tar.bz2 @@ -41,11 +38,11 @@ jobs: runs-on: 'ubuntu-22.04' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 # history required so setuptools_scm can determine version - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version-file: '.github/workflows/python-version-ci' @@ -56,7 +53,7 @@ jobs: run: python -m build - name: Upload wheels - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: dist path: dist @@ -70,8 +67,8 @@ jobs: id-token: write if: github.event_name == 'release' && github.event.action == 'published' steps: - - uses: actions/download-artifact@v3 - - uses: pypa/gh-action-pypi-publish@v1.8.10 + - uses: actions/download-artifact@v4 + - uses: pypa/gh-action-pypi-publish@v1.8.14 upload_conda: name: Deploy Conda @@ -80,7 +77,7 @@ jobs: if: github.event_name == 'release' && github.event.action == 'published' steps: - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 - uses: mamba-org/setup-micromamba@v1 with: environment-name: upload-env @@ -104,7 +101,7 @@ jobs: permissions: contents: write # This is needed so that the action can upload the asset steps: - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 - name: Zip documentation run: | mv docs_html documentation-${{ github.ref_name }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3cfb75d..5f56a06 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,3 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright (c) 2023 Scipp contributors (https://github.com/scipp) - name: Test on: @@ -48,16 +45,16 @@ jobs: runs-on: ${{ inputs.os-variant }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: ${{ inputs.checkout_ref }} - - uses: actions/setup-python@v3 + - uses: actions/setup-python@v5 with: python-version: ${{ inputs.python-version }} - run: python -m pip install --upgrade pip - run: python -m pip install -r ${{ inputs.pip-recipe }} - run: tox -e ${{ inputs.tox-env }} - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 if: ${{ inputs.coverage-report }} with: name: CoverageReport diff --git a/.github/workflows/unpinned.yml b/.github/workflows/unpinned.yml index 853c1ec..46a84c1 100644 --- a/.github/workflows/unpinned.yml +++ b/.github/workflows/unpinned.yml @@ -1,6 +1,3 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright (c) 2023 Scipp contributors (https://github.com/scipp) - name: Unpinned tests at latest release on: diff --git a/.gitignore b/.gitignore index e8b1ec7..0f0541b 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,4 @@ docs/generated/ *.raw *.cif *.rcif +*.ort diff --git a/conda/meta.yaml b/conda/meta.yaml index 12c476a..2d8247a 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -6,6 +6,11 @@ package: source: path: .. + +{% set pyproject = load_file_data('pyproject.toml') %} +{% set dependencies = pyproject.get('project', {}).get('dependencies', {}) %} + + requirements: build: - setuptools @@ -14,6 +19,11 @@ requirements: - h5py - python>=3.10 + {% for package in dependencies %} + - {% if package == "graphviz" %}python-graphviz{% else %}{{ package }}{% endif %} + {% endfor %} + + test: imports: - chexus diff --git a/docs/_templates/doc_version.html b/docs/_templates/doc_version.html index a348e28..48f9aac 100644 --- a/docs/_templates/doc_version.html +++ b/docs/_templates/doc_version.html @@ -1,2 +1,2 @@ -Current {{ project }} version: {{ version }} (older versions). +Current {{ project }} version: {{ version }} (older versions). diff --git a/docs/_typehints.py b/docs/_typehints.py deleted file mode 100644 index f9ef235..0000000 --- a/docs/_typehints.py +++ /dev/null @@ -1,83 +0,0 @@ -from typing import Any, NewType, Optional - -import sphinx - -_typehint_aliases = { - 'scipp._scipp.core.DataArray': 'scipp.DataArray', - 'scipp._scipp.core.Dataset': 'scipp.Dataset', - 'scipp._scipp.core.DType': 'scipp.DType', - 'scipp._scipp.core.Unit': 'scipp.Unit', - 'scipp._scipp.core.Variable': 'scipp.Variable', - 'scipp.core.data_group.DataGroup': 'scipp.DataGroup', -} - - -def typehints_formatter_for(package: str) -> callable: - def typehints_formatter(annotation, config: sphinx.config.Config) -> Optional[str]: - """Format typehints with improved NewType handling.""" - _ = config - if _is_new_type(annotation): - return _format_new_type(annotation, package) - if _is_type_alias_type(annotation): - return _format_type_alias_type(annotation, package) - return None - - return typehints_formatter - - -def _is_new_type(annotation: Any) -> bool: - # TODO Switch to isinstance(key, NewType) once our minimum is Python 3.10 - # Note that we cannot pass mypy in Python<3.10 since NewType is not a type. - return hasattr(annotation, '__supertype__') - - -def _format_new_type(annotation: NewType, package: str) -> str: - return ( - f'{_internal_link(annotation, "class", package)}' - f' ({_link(annotation.__supertype__, "class")})' - ) - - -def _is_type_alias_type(annotation) -> bool: - try: - from typing import TypeAliasType - - return isinstance(annotation, TypeAliasType) - except ImportError: - return False # pre python 3.12 - - -def _format_type_alias_type(annotation: Any, package: str) -> str: - alias = _internal_link(annotation, "class", package, annotation.__type_params__) - value = _link(annotation.__value__, "class", _get_type_args(annotation.__value__)) - return f'{alias} ({value})' - - -def _get_type_args(ty: type) -> tuple[type, ...]: - if (args := getattr(ty, '__args__', None)) is not None: - return args # e.g. list[int] - return ty.__type_params__ - - -def _internal_link( - annotation: Any, - kind: str, - package: str, - type_params: Optional[tuple[type, ...]] = None, -) -> str: - target = f'{annotation.__module__}.{annotation.__name__}' - label = f'{annotation.__module__.removeprefix(package+".")}.{annotation.__name__}' - if type_params: - label += f'[{", ".join(ty.__name__ for ty in type_params)}]' - return f':{kind}:`{label} <{target}>`' - - -def _link(ty: type, kind: str, type_params: Optional[tuple[type, ...]] = None) -> str: - if ty.__module__ == 'builtins': - target = ty.__name__ - else: - target = f'{ty.__module__}.{ty.__name__}' - label = _typehint_aliases.get(target, target) - if type_params: - label += f'[{", ".join(ty.__name__ for ty in type_params)}]' - return f':{kind}:`{label} <{target}>`' diff --git a/docs/conf.py b/docs/conf.py index 9e32ee3..cf0708a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -3,13 +3,10 @@ import doctest import os import sys - -import chexus +from importlib.metadata import version as get_version sys.path.insert(0, os.path.abspath('.')) -from _typehints import typehints_formatter_for # noqa: E402 - # General information about the project. project = u'Chexus' copyright = u'2024 Scipp contributors' @@ -25,6 +22,7 @@ 'sphinx.ext.intersphinx', 'sphinx.ext.mathjax', 'sphinx.ext.napoleon', + 'sphinx.ext.viewcode', 'sphinx_autodoc_typehints', 'sphinx_copybutton', 'sphinx_design', @@ -32,6 +30,14 @@ 'myst_parser', ] +try: + import sciline.sphinxext.domain_types # noqa: F401 + + extensions.append('sciline.sphinxext.domain_types') +except ModuleNotFoundError: + pass + + myst_enable_extensions = [ "amsmath", "colon_fence", @@ -75,7 +81,18 @@ } typehints_defaults = 'comma' typehints_use_rtype = False -typehints_formatter = typehints_formatter_for('chexus') + + +sciline_domain_types_prefix = 'chexus' +sciline_domain_types_aliases = { + 'scipp._scipp.core.DataArray': 'scipp.DataArray', + 'scipp._scipp.core.Dataset': 'scipp.Dataset', + 'scipp._scipp.core.DType': 'scipp.DType', + 'scipp._scipp.core.Unit': 'scipp.Unit', + 'scipp._scipp.core.Variable': 'scipp.Variable', + 'scipp.core.data_group.DataGroup': 'scipp.DataGroup', +} + # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] @@ -94,10 +111,8 @@ # built documents. # -# The short X.Y version. -version = chexus.__version__ -# The full version, including alpha/beta/rc tags. -release = chexus.__version__ +release = get_version("chexus") +version = ".".join(release.split('.')[:3]) # CalVer warning_is_error = True diff --git a/docs/developer/index.md b/docs/developer/index.md index 23b5544..9dc534a 100644 --- a/docs/developer/index.md +++ b/docs/developer/index.md @@ -1,4 +1,4 @@ -# Developer documentation +# Development ```{include} ../../CONTRIBUTING.md ``` diff --git a/pyproject.toml b/pyproject.toml index feb32c9..5bbe774 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,6 +50,7 @@ minversion = "7.0" addopts = """ --strict-config --strict-markers +--import-mode=importlib -ra -v """ @@ -78,5 +79,4 @@ enable_error_code = [ "redundant-expr", "truthy-bool", ] -show_error_codes = true warn_unreachable = true diff --git a/requirements/base.in b/requirements/base.in index d2be1a3..eb85e69 100644 --- a/requirements/base.in +++ b/requirements/base.in @@ -1,4 +1,5 @@ - +# Anything above "--- END OF CUSTOM SECTION ---" +# will not be touched by ``make_base.py`` # --- END OF CUSTOM SECTION --- # The following was generated by 'tox -e deps', DO NOT EDIT MANUALLY! h5py diff --git a/requirements/make_base.py b/requirements/make_base.py index b26a1c2..1e1f48e 100644 --- a/requirements/make_base.py +++ b/requirements/make_base.py @@ -1,6 +1,3 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright (c) 2023 Scipp contributors (https://github.com/scipp) - import sys from argparse import ArgumentParser from pathlib import Path @@ -43,7 +40,7 @@ def write_dependencies(dependency_name: str, dependencies: List[str]) -> None: with open("../pyproject.toml", "rb") as toml_file: pyproject = tomli.load(toml_file) dependencies = pyproject["project"].get("dependencies") - if not dependencies: + if dependencies is None: raise RuntimeError("No dependencies found in pyproject.toml") dependencies = [dep.strip().strip('"') for dep in dependencies]