From 757ce33b4e6f5c275e31b67d32ddb57c7b44b721 Mon Sep 17 00:00:00 2001 From: Garrett Wright Date: Wed, 13 Mar 2024 11:08:45 -0400 Subject: [PATCH 01/17] change default fft to scipy --- src/aspire/config_default.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/aspire/config_default.yaml b/src/aspire/config_default.yaml index 3d135a64f6..2a7725b1a2 100644 --- a/src/aspire/config_default.yaml +++ b/src/aspire/config_default.yaml @@ -3,7 +3,7 @@ common: # numeric module to use - one of numpy/cupy numeric: numpy # fft backend to use - one of pyfftw/scipy/cupy/mkl - fft: pyfftw + fft: scipy # Set cache directory for ASPIRE example data. # By default the cache location will be set by pooch.os_cache(), From cb87c35a9ffb4cf53c6b2f61c26869ffd9b4ce2e Mon Sep 17 00:00:00 2001 From: Garrett Wright Date: Wed, 13 Mar 2024 11:09:11 -0400 Subject: [PATCH 02/17] remove pyfftw from depends --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 0e28ebad97..478e1fe0dc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,7 +44,6 @@ dependencies = [ "pooch>=1.7.0", "pillow", "psutil", - "pyfftw", "pymanopt", "pyshtools<=4.10.4", # 4.11.7 might have a packaging bug "PyWavelets", From 14f7e8795bd8350a408b87c067e37a872d1587f8 Mon Sep 17 00:00:00 2001 From: Garrett Wright Date: Wed, 13 Mar 2024 11:17:02 -0400 Subject: [PATCH 03/17] remove pyfftw from environment yamls --- environment-accelerate.yml | 4 ---- environment-default.yml | 4 ---- environment-intel.yml | 4 ---- environment-openblas.yml | 4 ---- 4 files changed, 16 deletions(-) diff --git a/environment-accelerate.yml b/environment-accelerate.yml index 1d01c51d75..1a0a6c9e5a 100644 --- a/environment-accelerate.yml +++ b/environment-accelerate.yml @@ -5,10 +5,6 @@ channels: - defaults dependencies: - - fftw - # There is a potential pyFFTW bug, pin to 0.12 - # https://github.com/pyFFTW/pyFFTW/issues/294 - - pyfftw=0.12 - pip - python=3.8 - numpy=1.23.5 diff --git a/environment-default.yml b/environment-default.yml index f092f4c3ca..f5ff7ae893 100644 --- a/environment-default.yml +++ b/environment-default.yml @@ -5,10 +5,6 @@ channels: - defaults dependencies: - - fftw - # There is a potential pyFFTW bug, pin to 0.12 - # https://github.com/pyFFTW/pyFFTW/issues/294 - - pyfftw=0.12 - pip - python=3.8 - numpy=1.23.5 diff --git a/environment-intel.yml b/environment-intel.yml index fa3beba787..83250caeaf 100644 --- a/environment-intel.yml +++ b/environment-intel.yml @@ -5,10 +5,6 @@ channels: - defaults dependencies: - - fftw - # There is a potential pyFFTW bug, pin to 0.12 - # https://github.com/pyFFTW/pyFFTW/issues/294 - - pyfftw=0.12 - pip - python=3.8 - numpy=1.23.5 diff --git a/environment-openblas.yml b/environment-openblas.yml index bc4d61b46d..ee2f665e6e 100644 --- a/environment-openblas.yml +++ b/environment-openblas.yml @@ -5,10 +5,6 @@ channels: - defaults dependencies: - - fftw - # There is a potential pyFFTW bug, pin to 0.12 - # https://github.com/pyFFTW/pyFFTW/issues/294 - - pyfftw=0.12 - pip - python=3.8 - numpy=1.23.5 From 9a2023c4d7bfe424e8f6338c33209b41fef93b47 Mon Sep 17 00:00:00 2001 From: Garrett Wright Date: Wed, 13 Mar 2024 11:17:22 -0400 Subject: [PATCH 04/17] Emit message to install pyfftw to use as a backend --- src/aspire/numeric/pyfftw_fft.py | 6 +++++- tests/test_fft.py | 12 +++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/aspire/numeric/pyfftw_fft.py b/src/aspire/numeric/pyfftw_fft.py index c1b183108a..9cfdd45210 100644 --- a/src/aspire/numeric/pyfftw_fft.py +++ b/src/aspire/numeric/pyfftw_fft.py @@ -1,7 +1,11 @@ import os from threading import Lock -import pyfftw +try: + import pyfftw +except ModuleNotFoundError: + raise ModuleNotFoundError("Install `pyfftw` to use as a backend.") + import pyfftw.interfaces.scipy_fftpack as scipy_fft from aspire.numeric.base_fft import FFT diff --git a/tests/test_fft.py b/tests/test_fft.py index 45f22b1fd1..5a88929402 100644 --- a/tests/test_fft.py +++ b/tests/test_fft.py @@ -1,3 +1,4 @@ +import logging from unittest import TestCase import numpy as np @@ -5,8 +6,17 @@ from aspire import config from aspire.numeric import fft_object, numeric_object +logger = logging.getLogger(__name__) # Create test option combinations between numerical modules and FFT libs -test_backends = [("numpy", "scipy"), ("numpy", "pyfftw")] +test_backends = [("numpy", "scipy")] + +try: + import pyfftw # noqa: F401 + + test_backends.append(("numpy", "pyfftw")) +except ModuleNotFoundError: + logger.info("`pyfftw` module is not installed, skipping `pyfftw` FFT backend.") + # Create Cupy fft backend if Cupy module is enabled and lib exits. if config["common"]["numeric"].as_str() == "cupy": From 6439b93ef4284891962e6868d4eb74199d880b2f Mon Sep 17 00:00:00 2001 From: Garrett Wright Date: Wed, 5 Jun 2024 16:15:13 -0400 Subject: [PATCH 05/17] attempt adding osx m1 runner --- .github/workflows/workflow.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 64dfa54961..81494105ac 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -4,7 +4,7 @@ on: pull_request: types: [opened, synchronize, reopened, ready_for_review] push: - + jobs: check: @@ -215,3 +215,19 @@ jobs: name: sphinx-docs path: docs/build retention-days: 7 + + osx_arm: + needs: check + runs-on: macos-latest-xlarge + # Run on every code push, but only on review ready PRs + if: ${{ github.event_name == 'push' || github.event.pull_request.draft == false }} + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.8' + - name: Install dependencies + run: pip install tox tox-gh-actions + - name: Test + run: python -m pytest --durations=50 From ee6c57007f37a5819263a03b96a20339880bef8f Mon Sep 17 00:00:00 2001 From: Garrett Wright Date: Thu, 6 Jun 2024 08:53:28 -0400 Subject: [PATCH 06/17] mac osx latest to 14 --- .github/workflows/workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 81494105ac..92e68dfd28 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -218,7 +218,7 @@ jobs: osx_arm: needs: check - runs-on: macos-latest-xlarge + runs-on: macos-14 # Run on every code push, but only on review ready PRs if: ${{ github.event_name == 'push' || github.event.pull_request.draft == false }} steps: From 722ef87d20ae7090785d488ec3a0ed324f72361c Mon Sep 17 00:00:00 2001 From: Garrett Wright Date: Thu, 6 Jun 2024 08:58:21 -0400 Subject: [PATCH 07/17] install deps --- .github/workflows/workflow.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 92e68dfd28..57bf288dd2 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -228,6 +228,8 @@ jobs: with: python-version: '3.8' - name: Install dependencies - run: pip install tox tox-gh-actions + run: | + pip install tox tox-gh-actions + pip install -e ".[dev]" - name: Test run: python -m pytest --durations=50 From 47f9a4c1ad04a9a6623c42ed8565460c554b407d Mon Sep 17 00:00:00 2001 From: Garrett Wright Date: Thu, 6 Jun 2024 15:51:25 -0400 Subject: [PATCH 08/17] attempt pre-installing pyshtools via conda --- .github/workflows/workflow.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 57bf288dd2..d6dc83bf19 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -223,13 +223,18 @@ jobs: if: ${{ github.event_name == 'push' || github.event.pull_request.draft == false }} steps: - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 + - name: Set up Conda + uses: conda-incubator/setup-miniconda@v2.3.0 with: + miniconda-version: "latest" + auto-update-conda: true python-version: '3.8' - - name: Install dependencies + - name: Complete Install and Log Environment ${{ matrix.os }} Python ${{ matrix.python-version }} run: | - pip install tox tox-gh-actions - pip install -e ".[dev]" + conda info + conda list + conda install pyshtools # debug depends issues + pip install -e ".[dev]" # install aspire + pip freeze - name: Test run: python -m pytest --durations=50 From f1cc12f8eb650aa84dd4d19ec124a5c505b394d9 Mon Sep 17 00:00:00 2001 From: Garrett Wright Date: Thu, 6 Jun 2024 15:59:31 -0400 Subject: [PATCH 09/17] attempt pre-installing pyshtools via conda env --- .github/workflows/workflow.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index d6dc83bf19..bf3f86a308 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -229,6 +229,9 @@ jobs: miniconda-version: "latest" auto-update-conda: true python-version: '3.8' + activate-environment: aspire + environment-file: environment-accelerate.yml + auto-activate-base: false - name: Complete Install and Log Environment ${{ matrix.os }} Python ${{ matrix.python-version }} run: | conda info From 57bc7bb623675c6a119a851af395287aba6df201 Mon Sep 17 00:00:00 2001 From: Garrett Wright Date: Fri, 7 Jun 2024 09:58:33 -0400 Subject: [PATCH 10/17] use base env and shell --- .github/workflows/workflow.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index bf3f86a308..3003839e4e 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -22,7 +22,7 @@ jobs: run: tox -e check build: - needs: check + needs: osx_arm runs-on: ubuntu-latest # Run on every code push, but only on review ready PRs if: ${{ github.event_name == 'push' || github.event.pull_request.draft == false }} @@ -55,7 +55,7 @@ jobs: uses: codecov/codecov-action@v4 conda-build: - needs: check + needs: osx_arm runs-on: ${{ matrix.os }} # Only run on review ready pull_requests if: ${{ github.event_name == 'pull_request' && github.event.pull_request.draft == false }} @@ -121,7 +121,7 @@ jobs: shell: bash ampere_gpu: - needs: check + needs: osx_arm runs-on: self-hosted # Run on every code push, but only on review ready PRs if: ${{ github.event_name == 'push' || github.event.pull_request.draft == false }} @@ -217,6 +217,9 @@ jobs: retention-days: 7 osx_arm: + defaults: + run: + shell: bash -l {0} needs: check runs-on: macos-14 # Run on every code push, but only on review ready PRs @@ -228,10 +231,9 @@ jobs: with: miniconda-version: "latest" auto-update-conda: true + channels: conda-forge, defaults python-version: '3.8' - activate-environment: aspire - environment-file: environment-accelerate.yml - auto-activate-base: false + auto-activate-base: true - name: Complete Install and Log Environment ${{ matrix.os }} Python ${{ matrix.python-version }} run: | conda info From 94bcfbc0371cbfd9af5dcf92724ed9bebb0b658c Mon Sep 17 00:00:00 2001 From: Garrett Wright Date: Fri, 7 Jun 2024 10:55:46 -0400 Subject: [PATCH 11/17] try updated accel env --- .github/workflows/workflow.yml | 5 +++-- environment-accelerate.yml | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 3003839e4e..a96d6b05bd 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -231,9 +231,10 @@ jobs: with: miniconda-version: "latest" auto-update-conda: true - channels: conda-forge, defaults python-version: '3.8' - auto-activate-base: true + activate-environment: aspire + environment-file: environment-accelerate.yml + auto-activate-base: false - name: Complete Install and Log Environment ${{ matrix.os }} Python ${{ matrix.python-version }} run: | conda info diff --git a/environment-accelerate.yml b/environment-accelerate.yml index 1a0a6c9e5a..38dd49813d 100644 --- a/environment-accelerate.yml +++ b/environment-accelerate.yml @@ -7,8 +7,9 @@ channels: dependencies: - pip - python=3.8 - - numpy=1.23.5 - - scipy=1.9.3 + - pyshtools + - numpy=1.24.1 + - scipy=1.10.1 - scikit-learn - scikit-image - libblas=*=*accelerate From 2c77825b0dc5ab3732553a820de9e1bbeb8e8de2 Mon Sep 17 00:00:00 2001 From: Garrett Wright Date: Fri, 7 Jun 2024 12:06:50 -0400 Subject: [PATCH 12/17] restore job deps, and try parallel for osx_arm --- .github/workflows/workflow.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index a96d6b05bd..ffe85d5343 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -22,7 +22,7 @@ jobs: run: tox -e check build: - needs: osx_arm + needs: check runs-on: ubuntu-latest # Run on every code push, but only on review ready PRs if: ${{ github.event_name == 'push' || github.event.pull_request.draft == false }} @@ -55,7 +55,7 @@ jobs: uses: codecov/codecov-action@v4 conda-build: - needs: osx_arm + needs: check runs-on: ${{ matrix.os }} # Only run on review ready pull_requests if: ${{ github.event_name == 'pull_request' && github.event.pull_request.draft == false }} @@ -121,7 +121,7 @@ jobs: shell: bash ampere_gpu: - needs: osx_arm + needs: check runs-on: self-hosted # Run on every code push, but only on review ready PRs if: ${{ github.event_name == 'push' || github.event.pull_request.draft == false }} @@ -243,4 +243,4 @@ jobs: pip install -e ".[dev]" # install aspire pip freeze - name: Test - run: python -m pytest --durations=50 + run: python -m pytest -n2 --durations=50 From 57e4bbc3eb0e023e1af29391883b7c8c65a141e8 Mon Sep 17 00:00:00 2001 From: Garrett Wright Date: Fri, 7 Jun 2024 13:47:12 -0400 Subject: [PATCH 13/17] try -n3 --- .github/workflows/workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index ffe85d5343..6e77dad75e 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -243,4 +243,4 @@ jobs: pip install -e ".[dev]" # install aspire pip freeze - name: Test - run: python -m pytest -n2 --durations=50 + run: python -m pytest -n3 --durations=50 From 132c378ab0b12b7ac1c1905c0eaec1866c587c80 Mon Sep 17 00:00:00 2001 From: Garrett Wright Date: Mon, 10 Jun 2024 11:13:43 -0400 Subject: [PATCH 14/17] continue testing pyfftw backend --- .github/workflows/workflow.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 6e77dad75e..06b8dd71af 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -18,6 +18,8 @@ jobs: - name: Install dependencies run: | pip install tox tox-gh-actions + # Optional packages + pip install pyfftw # `test_fft` runs for pyfftw when installed - name: Run Tox Check run: tox -e check From a25fe7d82ffa962743ae079f42fcd7dbc8b3d7a1 Mon Sep 17 00:00:00 2001 From: Marc Date: Fri, 14 Jun 2024 09:37:44 -0700 Subject: [PATCH 15/17] adjust tolerance for m1 --- tests/test_synthetic_volume.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_synthetic_volume.py b/tests/test_synthetic_volume.py index 8860b3532d..ddcdcbcab5 100644 --- a/tests/test_synthetic_volume.py +++ b/tests/test_synthetic_volume.py @@ -136,4 +136,4 @@ def test_volume_symmetry(vol_fixture): corr = np.dot(rot_vol[0].flatten(), vol[0].flatten()) / np.dot( vol[0].flatten(), vol[0].flatten() ) - assert abs(corr - 1) < 1e-5 + assert abs(corr - 1) < 1.1e-5 From 48aeab2d2b3d7dde438935c0143a112ef4f1e41c Mon Sep 17 00:00:00 2001 From: Garrett Wright Date: Mon, 17 Jun 2024 13:33:17 -0400 Subject: [PATCH 16/17] put pyfftw install into correct job --- .github/workflows/workflow.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 06b8dd71af..f2d5472e52 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -18,8 +18,6 @@ jobs: - name: Install dependencies run: | pip install tox tox-gh-actions - # Optional packages - pip install pyfftw # `test_fft` runs for pyfftw when installed - name: Run Tox Check run: tox -e check @@ -51,6 +49,8 @@ jobs: - name: Install dependencies run: | pip install tox tox-gh-actions + # Optional packages + pip install pyfftw # `test_fft` runs for pyfftw when installed - name: Test with tox run: tox --skip-missing-interpreters false -e py${{ matrix.python-version }}-${{ matrix.pyenv }} - name: Upload Coverage to CodeCov From 0db87ba60e5ee88b45ed4209ecd1423967c1814d Mon Sep 17 00:00:00 2001 From: Garrett Wright Date: Mon, 17 Jun 2024 13:47:30 -0400 Subject: [PATCH 17/17] Force numpy<2 Numpy Was previously bound <2 by pyfftw deps. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 478e1fe0dc..f48de5f41b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,7 @@ dependencies = [ "joblib", "matplotlib >= 3.2.0", "mrcfile", - "numpy>=1.21.5", + "numpy>=1.21.5, <2.0.0", "packaging", "pooch>=1.7.0", "pillow",