Skip to content

Commit

Permalink
Update CI test and build infrastructure (#118)
Browse files Browse the repository at this point in the history
* 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 dbdc1d6.

* metadata: fix unbound local

* Preparing for v2.0.0 release

* ci: cosmetic changes, readme update
  • Loading branch information
lgarrison authored Nov 16, 2023
1 parent 12a974a commit fc98b8d
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 54 deletions.
36 changes: 0 additions & 36 deletions .github/workflows/python-publish.yml

This file was deleted.

81 changes: 68 additions & 13 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 20 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
~~~~~~~~~~~~
Expand Down
4 changes: 2 additions & 2 deletions abacusnbody/metadata/abacussummit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand All @@ -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
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
[build-system]
requires = [
"setuptools>=61",
"wheel",
"setuptools_scm>=6.2",
"pip>=21.2",
]
build-backend = "setuptools.build_meta"

Expand Down

0 comments on commit fc98b8d

Please sign in to comment.