Skip to content

Commit d0f3d09

Browse files
authored
Merge pull request #1247 from ComputationalCryoEM/develop
Develop v0.13.2~~> main
2 parents ab3dec1 + c8a9756 commit d0f3d09

File tree

97 files changed

+2826
-1696
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+2826
-1696
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.13.1
2+
current_version = 0.13.2
33
commit = True
44
tag = True
55

.github/workflows/workflow.yml

Lines changed: 148 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,69 @@ jobs:
2121
- name: Run Tox Check
2222
run: tox -e check
2323

24-
build:
24+
data-cache:
2525
needs: check
2626
runs-on: ubuntu-latest
27+
outputs:
28+
cache_hash: ${{ steps.compute-cache-hash.outputs.cache_hash }}
29+
steps:
30+
- uses: actions/checkout@v4
31+
- name: Setup Python
32+
uses: actions/setup-python@v5
33+
with:
34+
python-version: '3.9'
35+
- name: Install Dependencies
36+
run: |
37+
python -m pip install --upgrade pip
38+
pip install -e ".[dev]"
39+
- name: Restore Cache
40+
uses: actions/cache@v4
41+
with:
42+
key: cached-data-${{ hashFiles('**/registry.py', '**/*workflow.yml') }}
43+
restore-keys: |
44+
cached-data-
45+
path: .github_cache/ASPIRE-data
46+
enableCrossOsArchive: true
47+
- name: Create Cache Directory
48+
run: |
49+
# Create cache and config directories
50+
mkdir -p .github_cache/ASPIRE-data
51+
chmod -R 777 .github_cache/ASPIRE-data
52+
echo "cache:" > config.yaml
53+
echo " cache_dir: .github_cache/ASPIRE-data" >> config.yaml
54+
echo "Logging config.yaml for verification:"
55+
cat config.yaml
56+
- name: Download Cache Files
57+
run: |
58+
export ASPIREDIR=.
59+
python -c "
60+
from aspire.downloader import emdb_2660, simulated_channelspin
61+
emdb_2660()
62+
simulated_channelspin()
63+
"
64+
- name: Compute Cache Directory Hash
65+
id: compute-cache-hash
66+
run: |
67+
echo "Computing hash for .github_cache/ASPIRE-data..."
68+
# Compute a hash on the sorted file listing.
69+
cache_hash=$(ls -1 .github_cache/ASPIRE-data/** | md5sum)
70+
echo "Computed cache hash: $cache_hash"
71+
# Expose the computed hash to subsequent steps/jobs.
72+
echo "cache_hash=${cache_hash}" >> $GITHUB_OUTPUT
73+
- name: Verify Cache Directory Before Saving
74+
run: |
75+
ls -lhR .github_cache/ASPIRE-data
76+
[ -f config.yaml ]
77+
- name: Save Cache
78+
uses: actions/cache@v4
79+
with:
80+
key: cached-data-${{ hashFiles('**/registry.py', '**/*workflow.yml') }}
81+
path: .github_cache/ASPIRE-data
82+
enableCrossOsArchive: true
83+
84+
build:
85+
needs: [check, data-cache]
86+
runs-on: ubuntu-latest
2787
# Run on every code push, but only on review ready PRs
2888
if: ${{ github.event_name == 'push' || github.event.pull_request.draft == false }}
2989
strategy:
@@ -39,7 +99,6 @@ jobs:
3999
- python-version: '3.9'
40100
pyenv: pip,docs
41101

42-
43102
steps:
44103
- uses: actions/checkout@v4
45104
- name: Set up Python ${{ matrix.python-version }} ${{ matrix.pyenv }}
@@ -51,15 +110,44 @@ jobs:
51110
pip install tox tox-gh-actions
52111
# Optional packages
53112
pip install pyfftw # `test_fft` runs for pyfftw when installed
113+
- name: Restore Cache
114+
uses: actions/cache@v4
115+
with:
116+
key: cached-data-${{ hashFiles('**/registry.py', '**/*workflow.yml') }}
117+
restore-keys: |
118+
cached-data-
119+
path: .github_cache/ASPIRE-data
120+
enableCrossOsArchive: true
121+
- name: Set Cache Directory
122+
run: |
123+
echo "cache:" > config.yaml
124+
echo " cache_dir: .github_cache/ASPIRE-data" >> config.yaml
125+
- name: Verify Restored Cache Directory
126+
run: |
127+
ls -lhR .github_cache/ASPIRE-data
128+
[ -f config.yaml ]
54129
- name: Test with tox
55-
run: tox --skip-missing-interpreters false -e py${{ matrix.python-version }}-${{ matrix.pyenv }}
130+
run: |
131+
tox --override testenv.set_env=ASPIREDIR=${{ github.workspace }} \
132+
--skip-missing-interpreters false \
133+
-e py${{ matrix.python-version }}-${{ matrix.pyenv }}
134+
- name: Validate Cache Directory Hash
135+
run: |
136+
echo "Computing hash for .github_cache/ASPIRE-data..."
137+
new_hash=$(ls -1 .github_cache/ASPIRE-data/** | md5sum)
138+
echo "Hash from data-cache job: ${{ needs.data-cache.outputs.cache_hash }}"
139+
echo "Computed hash now: $new_hash"
140+
if [ "${{ needs.data-cache.outputs.cache_hash }}" != "$new_hash" ]; then
141+
echo "Error: Cache directory hash has changed!"
142+
exit 1
143+
fi
56144
- name: Upload Coverage to CodeCov
57145
uses: codecov/codecov-action@v4
58146
with:
59147
token: ${{ secrets.CODECOV_TOKEN }}
60148

61149
conda-build:
62-
needs: check
150+
needs: [check, data-cache]
63151
runs-on: ${{ matrix.os }}
64152
# Only run on review ready pull_requests
65153
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.draft == false }}
@@ -97,8 +185,21 @@ jobs:
97185
pip install -e ".[dev]"
98186
pip freeze
99187
python -c "import numpy; numpy.show_config()"
188+
- name: Restore Cache
189+
uses: actions/cache@v4
190+
with:
191+
key: cached-data-${{ hashFiles('**/registry.py', '**/*workflow.yml') }}
192+
restore-keys: |
193+
cached-data-
194+
path: .github_cache/ASPIRE-data
195+
enableCrossOsArchive: true
196+
- name: Set Cache Directory
197+
run: |
198+
echo "cache:" > config.yaml
199+
echo " cache_dir: .github_cache/ASPIRE-data" >> config.yaml
100200
- name: Execute Pytest Conda ${{ matrix.os }} Python ${{ matrix.python-version }}
101201
run: |
202+
export ASPIREDIR=.
102203
export OMP_NUM_THREADS=2
103204
# -n runs test in parallel using pytest-xdist
104205
pytest -n2 --durations=50 -s
@@ -149,15 +250,16 @@ jobs:
149250
echo "Stash the WORK_DIR to GitHub env so we can clean it up later."
150251
echo "WORK_DIR=${WORK_DIR}" >> $GITHUB_ENV
151252
echo -e "common:" >> ${WORK_DIR}/config.yaml
152-
echo -e " cache_dir: ${CI_CACHE_DIR}" >> ${WORK_DIR}/config.yaml
153253
echo -e " numeric: cupy" >> ${WORK_DIR}/config.yaml
154254
echo -e " fft: cupy\n" >> ${WORK_DIR}/config.yaml
255+
echo -e "cache:" >> ${WORK_DIR}/config.yaml
256+
echo -e " cache_dir: ${CI_CACHE_DIR}" >> ${WORK_DIR}/config.yaml
155257
echo "Log the config: ${WORK_DIR}/config.yaml"
156258
cat ${WORK_DIR}/config.yaml
157259
- name: Cache Data
158260
run: |
159261
ASPIREDIR=${{ env.WORK_DIR }} python -c \
160-
"import aspire; print(aspire.config['common']['cache_dir']); import aspire.downloader; aspire.downloader.emdb_2660()"
262+
"import aspire; print(aspire.config['cache']['cache_dir']); import aspire.downloader; aspire.downloader.emdb_2660()"
161263
- name: Run
162264
run: |
163265
ASPIREDIR=${{ env.WORK_DIR }} PYTHONWARNINGS=error python -m pytest --durations=50 --cov=aspire --cov-report=xml
@@ -168,30 +270,6 @@ jobs:
168270
- name: Cleanup
169271
run: rm -rf ${{ env.WORK_DIR }}
170272

171-
# Create cache and download data for Github Actions CI.
172-
data-cache:
173-
needs: check
174-
runs-on: ubuntu-latest
175-
steps:
176-
- uses: actions/checkout@v4
177-
- name: Setup Python
178-
uses: actions/setup-python@v5
179-
with:
180-
python-version: '3.9'
181-
- name: Install Dependencies
182-
run: |
183-
python -m pip install --upgrade pip
184-
pip install -e ".[dev]"
185-
- name: Create Cache
186-
uses: actions/cache@v4
187-
with:
188-
path: ~/.cache/ASPIRE-data
189-
key: ${{ runner.os }}-cached-data
190-
- name: Download EMDB 2660
191-
run: |
192-
python -c \
193-
"from aspire.downloader import emdb_2660; emdb_2660()"
194-
195273
# Build branch's docs and gallery.
196274
docs:
197275
needs: [check, data-cache]
@@ -209,10 +287,18 @@ jobs:
209287
- name: Restore Cache
210288
uses: actions/cache@v4
211289
with:
212-
path: ~/.cache/ASPIRE-data
213-
key: ${{ runner.os }}-cached-data
290+
key: cached-data-${{ hashFiles('**/registry.py', '**/*workflow.yml') }}
291+
restore-keys: |
292+
cached-data-
293+
path: .github_cache/ASPIRE-data
294+
enableCrossOsArchive: true
295+
- name: Set Cache Directory
296+
run: |
297+
echo "cache:" > config.yaml
298+
echo " cache_dir: .github_cache/ASPIRE-data" >> config.yaml
214299
- name: Build Sphinx docs
215300
run: |
301+
export ASPIREDIR=${{ github.workspace }}
216302
make distclean
217303
sphinx-apidoc -f -o ./source ../src -H Modules
218304
make html
@@ -223,9 +309,19 @@ jobs:
223309
name: sphinx-docs
224310
path: docs/build
225311
retention-days: 7
312+
- name: Validate Cache Directory Hash
313+
run: |
314+
echo "Computing hash for .github_cache/ASPIRE-data..."
315+
new_hash=$(ls -1 .github_cache/ASPIRE-data/** | md5sum)
316+
echo "Hash from data-cache job: ${{ needs.data-cache.outputs.cache_hash }}"
317+
echo "Computed hash now: $new_hash"
318+
if [ "${{ needs.data-cache.outputs.cache_hash }}" != "$new_hash" ]; then
319+
echo "Error: Cache directory hash has changed!"
320+
exit 1
321+
fi
226322
227323
osx_arm:
228-
needs: check
324+
needs: [check, data-cache]
229325
runs-on: macos-14
230326
# Run on every code push, but only on review ready PRs
231327
if: ${{ github.event_name == 'push' || github.event.pull_request.draft == false }}
@@ -239,5 +335,23 @@ jobs:
239335
python --version
240336
pip install -e ".[dev]" # install aspire
241337
pip freeze
338+
- name: Restore Cache
339+
uses: actions/cache@v4
340+
with:
341+
key: cached-data-${{ hashFiles('**/registry.py', '**/*workflow.yml') }}
342+
restore-keys: |
343+
cached-data-
344+
path: .github_cache/ASPIRE-data
345+
enableCrossOsArchive: true
346+
- name: Set Cache Directory
347+
run: |
348+
echo "cache:" > config.yaml
349+
echo " cache_dir: .github_cache/ASPIRE-data" >> config.yaml
350+
- name: Verify Restored Cache Directory
351+
run: |
352+
ls -lhR .github_cache/ASPIRE-data
353+
[ -f config.yaml ]
242354
- name: Test
243-
run: python -m pytest -n3 --durations=50
355+
run: |
356+
export ASPIREDIR=.
357+
python -m pytest -n3 --durations=50

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.5657281.svg)](https://doi.org/10.5281/zenodo.5657281)
66
[![Downloads](https://static.pepy.tech/badge/aspire/month)](https://pepy.tech/project/aspire)
77

8-
# ASPIRE - Algorithms for Single Particle Reconstruction - v0.13.1
8+
# ASPIRE - Algorithms for Single Particle Reconstruction - v0.13.2
99

1010
The ASPIRE-Python project supersedes [Matlab ASPIRE](https://github.com/PrincetonUniversity/aspire).
1111

@@ -20,7 +20,7 @@ For more information about the project, algorithms, and related publications ple
2020
Please cite using the following DOI. This DOI represents all versions, and will always resolve to the latest one.
2121

2222
```
23-
ComputationalCryoEM/ASPIRE-Python: v0.13.1 https://doi.org/10.5281/zenodo.5657281
23+
ComputationalCryoEM/ASPIRE-Python: v0.13.2 https://doi.org/10.5281/zenodo.5657281
2424
2525
```
2626

docs/source/class_source.rst

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ required component and assign them here for complete control.
4949

5050
""""""""""
5151

52-
While that allows for full customization, two helper classes are
53-
provided that supply defaults as a jumping off point. Both of these
52+
While that allows for full customization, helper classes are
53+
provided that supply defaults as a jumping off point. These
5454
helper sources only require an input ``Source`` to be instantiated.
5555
They can still be fully customized, but they are intended to start
5656
with sensible defaults, so users only need to instantiate the specific
@@ -61,18 +61,27 @@ components they wish to configure.
6161
classDiagram
6262
ClassAvgSource <|-- DebugClassAvgSource
6363
ClassAvgSource <|-- DefaultClassAvgSource
64+
ClassAvgSource <|-- LegacyClassAvgSource
6465
class DebugClassAvgSource{
6566
src: ImageSource
6667
classifier: RIRClass2D
6768
class_selector: TopClassSelector
6869
averager: BFRAverager2D
6970
+images()
7071
}
72+
class LegacyClassAvgSource{
73+
src: ImageSource
74+
classifier: RIRClass2D
75+
class_selector: GlobalVarianceClassSelector
76+
averager: BFRAverager2D
77+
+images()
78+
}
7179
class DefaultClassAvgSource{
72-
version="0.11.0"
80+
version="0.13.2"
7381
src: ImageSource
7482
classifier: RIRClass2D
7583
class_selector: NeighborVarianceWithRepulsionClassSelector
84+
quality_function: BandedSNRImageQualityFunction
7685
averager: BFSRAverager2D
7786
+images()
7887
}
@@ -86,7 +95,7 @@ mappings etc.
8695

8796
``DefaultClassAvgSource`` applies the most sensible defaults available
8897
in the current ASPIRE release. ``DefaultClassAvgSource`` takes a
89-
version string, such as ``0.11.0`` which will return a specific
98+
version string, such as ``0.13.2`` which will return a specific
9099
configuration. This version should allow users to perform a similar
91100
experiment across releases as ASPIRE implements improved methods.
92101
When a version is not provided, ``DefaultClassAvgSource`` defaults to
@@ -160,6 +169,7 @@ can reduce pipeline run times by an order of magnitude.
160169
ClassSelector <|-- TopClassSelector
161170
ClassSelector <|-- RandomClassSelector
162171
ClassSelector <|-- NeighborVarianceClassSelector
172+
ClassSelector <|-- GlobalVarianceClassSelector
163173
ClassSelector <|-- DistanceClassSelector
164174
ClassSelector o-- GreedyClassRepulsionMixin
165175

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
# built documents.
8787
#
8888
# The full version, including alpha/beta/rc tags.
89-
release = version = "0.13.1"
89+
release = version = "0.13.2"
9090

9191
# The language for content autogenerated by Sphinx. Refer to documentation
9292
# for a list of supported languages.

docs/source/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Aspire v0.13.1
1+
Aspire v0.13.2
22
==============
33

44
Algorithms for Single Particle Reconstruction

0 commit comments

Comments
 (0)