From fc98b8db0d66626084ca86effbfb03a378335747 Mon Sep 17 00:00:00 2001 From: Lehman Garrison Date: Wed, 15 Nov 2023 19:58:20 -0500 Subject: [PATCH] Update CI test and build infrastructure (#118) * github: modernize build and publish workflow * update sdist dependencies * cibuildwheel isn't for python-only packages * Try again with pattern match syntax * try fetch-tags for setuptools-scm * try fetch-depth 0 * try to add wheel test * try to fix wheel install * refactor ci/tests: require tests to pass before upload * Try adding publish-only steps * split fetch and install * fix env syntax * can't use env at job level :( * env string "false" is true... * mock up publishing * no pipe_asdf C test client from wheels * Revert "mock up publishing" This reverts commit dbdc1d6f7996243b880b4a09d45847f7e6d844dd. * metadata: fix unbound local * Preparing for v2.0.0 release * ci: cosmetic changes, readme update --- .github/workflows/python-publish.yml | 36 ------------- .github/workflows/tests.yml | 81 +++++++++++++++++++++++----- CHANGES.rst | 21 +++++++- abacusnbody/metadata/abacussummit.py | 4 +- pyproject.toml | 2 - 5 files changed, 90 insertions(+), 54 deletions(-) delete mode 100644 .github/workflows/python-publish.yml diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml deleted file mode 100644 index 862034cc..00000000 --- a/.github/workflows/python-publish.yml +++ /dev/null @@ -1,36 +0,0 @@ -# This workflow will upload a Python Package using Twine when a release is created -# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries - -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -name: Upload Python Package - -on: - release: - types: [published] - -jobs: - deploy: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install build - - name: Build package - run: python -m build - - name: Publish package - uses: pypa/gh-action-pypi-publish@b7f401de30cb6434a1e19f805ff006643653240e - with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1f99d1cf..14dfeb35 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -5,50 +5,105 @@ on: schedule: # Run weekly, Friday at 7:15 EST. - cron: '15 12 * * 5' + release: + types: [published] jobs: + build: + if: ${{ github.event_name == 'release' && github.event.action == 'published' }} + name: Build Wheels + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install dependencies + run: | + python -m pip install -U pip + python -m pip install build + + - name: Build + run: python -m build + + - uses: actions/upload-artifact@v3 + with: + path: | + ./dist/*.whl + ./dist/*.tar.gz + tests: + name: Tests + # always run, but wait for build if publishing + if: ${{ !cancelled() }} + needs: [build] runs-on: ubuntu-latest + env: + PUBLISH: ${{ github.event_name == 'release' && github.event.action == 'published' }} strategy: matrix: python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} + - name: Install dependencies run: | python -m pip install -U pip pip install numpy pip install 'setuptools' 'wheel' 'numpy>=1.19.0' 'Cython>=0.29.21,<3' # for classy pip install --no-build-isolation classy + + - name: Install package from source + if: ${{ env.PUBLISH != 'true' }} + run: | pip install -U .[test] make -C pipe_asdf + + - name: Fetch wheel + if: ${{ env.PUBLISH == 'true' }} + uses: actions/download-artifact@v3 + with: + name: artifact + path: dist + + - name: Install package from wheel + if: ${{ env.PUBLISH == 'true' }} + run: | + pip install $(ls dist/*.whl)[test] + - name: Test Python with pytest run: | # TODO: set up environment in tox export NUMBA_THREADING_LAYER=forksafe pytest -v + - name: Test pipe_asdf + # no C test client from wheels + if: ${{ env.PUBLISH != 'true' }} run: | ./tests/test_pipe_asdf.sh - lint: + upload: + name: PyPI Upload + if: ${{ github.event_name == 'release' && github.event.action == 'published' }} + needs: [build, tests] + environment: pypi + permissions: + id-token: write runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v4 + - uses: actions/download-artifact@v3 with: - python-version: "3.10" - - name: Install dependencies - run: | - python -m pip install -U pip - pip install pre-commit - - name: Lint with pre-commit - run: | - pre-commit run --all-files + name: artifact + path: dist + + - uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/CHANGES.rst b/CHANGES.rst index 4b3cd804..35443ac7 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,9 +1,25 @@ Changelog ========= -1.4.0 (2023-??-??) +2.0.0 (2023-11-15) ------------------ +abacusutils 2.0 introduces a power spectrum module based on fast, parallelized TSC +and FFT, including grid interlacing and window compensation, that can output bandpowers, +Legendre multipoles, (k,mu) wedges, and more. + +The set of default installed dependencies has also been reduced to avoid trouble with +source-only distributions. Use `pip install abacusutils[all]` if you need functionality +provided by a non-default dependency. + +Furthermore, there's a new Zel'dovich Control Variates (ZCV) module, and the HOD module +has many additions, performance improvements, and bug fixes. + +This is a relatively large release, so the version number has been bumped to 2.0.0. + +Supported Python versions are 3.8-3.11. Python 3.7 continues to work, although we'll +drop support if/when this is no longer the case. + New Features ~~~~~~~~~~~~ - HOD now supports a new ELG conformity model @@ -13,12 +29,15 @@ New Features Fixes ~~~~~ - Bump Numba requirement to fixed version and enable parallelism in env calc [#60] +- Many small bug fixes Enhancements ~~~~~~~~~~~~ - Add power spectrum to `metadata` module [#69] - Upgrade docs and CI [#71] - Power spectrum optimization and parallelization [#102] +- Compute Xi(rp,pi) from P(k) [#115] +- Update CI test and build infrastructure [#118] Installation ~~~~~~~~~~~~ diff --git a/abacusnbody/metadata/abacussummit.py b/abacusnbody/metadata/abacussummit.py index 2e507d67..773d4d75 100644 --- a/abacusnbody/metadata/abacussummit.py +++ b/abacusnbody/metadata/abacussummit.py @@ -45,7 +45,7 @@ def get_meta(simname, redshift=None): if 'CLASS_power_spectrum' in af_tree[sim]: metadata[sim]['CLASS_power_spectrum'] = af_tree[sim]['CLASS_power_spectrum'] if simname not in metadata: - raise ValueError(f'Simulation "{simname}" is not in metadata file "{metadata_fn}"') + raise ValueError(f'Simulation "{simname}" is not in metadata files "{metadata_fns}"') res = dict(metadata[simname]['param']) @@ -58,7 +58,7 @@ def get_meta(simname, redshift=None): if not redshift.startswith('z'): redshift = 'z' + redshift if redshift not in metadata[simname]['state']: - raise ValueError(f'Redshift {redshift} metadata not present for "{simname}" in metadata file "{metadata_fn}') + raise ValueError(f'Redshift {redshift} metadata not present for "{simname}" in metadata files "{metadata_fns}') res.update(metadata[simname]['state'][redshift]) return res diff --git a/pyproject.toml b/pyproject.toml index 21e5bdcd..6bea5da3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,7 @@ [build-system] requires = [ "setuptools>=61", - "wheel", "setuptools_scm>=6.2", - "pip>=21.2", ] build-backend = "setuptools.build_meta"