-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from flatironinstitute/tests
incorporate pytest in github workflows
- Loading branch information
Showing
9 changed files
with
112 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# GHA workflow for running tests. | ||
# | ||
# Largely taken from | ||
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | ||
# Please check the link for more detailed instructions | ||
|
||
name: Run tests | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.8", "3.9", "3.10", "3.11"] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Cache dependencies and test data | ||
id: cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cache/pip | ||
tests/data | ||
data | ||
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml', '**/tests/scripts/fetch_test_data.sh') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip- | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install . | ||
pip install pytest omegaconf | ||
- name: Get test data from OSF | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: | | ||
sh tests/scripts/fetch_test_data.sh | ||
- name: Test with pytest | ||
run: | | ||
pytest tests/test_map_to_map.py | ||
pytest tests/test_distribution_to_distribution.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,7 +58,8 @@ dev = [ | |
"pytest", | ||
"mypy", | ||
"pre-commit", | ||
"ruff" | ||
"ruff", | ||
"omegaconf" | ||
] | ||
|
||
[project.urls] | ||
|
12 changes: 12 additions & 0 deletions
12
tests/config_files/test_config_distribution_to_distribution.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
input_fname: tests/results/test_map_to_map_distance_matrix_submission_0.pkl | ||
metrics: | ||
- l2 | ||
gt_metadata_fname: tests/data/test_metadata_10.csv | ||
n_replicates: 3 | ||
n_pool_microstate: 2 | ||
replicate_fraction: 0.9 | ||
cvxpy_solver: ECOS | ||
optimal_q_kl: | ||
n_iter: 100000 | ||
break_atol: 0.0001 | ||
output_fname: results/test_distribution_to_distribution_submission_0.pkl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
data: | ||
n_pix: 224 | ||
psize: 2.146 | ||
submission: | ||
fname: tests/data/dataset_2_submissions/test_submission_0_n8.pt | ||
volume_key: volumes | ||
metadata_key: populations | ||
label_key: id | ||
ground_truth: | ||
volumes: tests/data/test_maps_gt_flat_10.pt | ||
metadata: tests/data/test_metadata_10.csv | ||
mask: | ||
do: true | ||
volume: data/mask_dilated_wide_224x224.mrc | ||
analysis: | ||
metrics: | ||
- l2 | ||
chunk_size_submission: 80 | ||
chunk_size_gt: 190 | ||
normalize: | ||
do: true | ||
method: median_zscore | ||
output: tests/results/test_map_to_map_distance_matrix_submission_0.pkl |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
index,volumes,populations_count,pc1,populations | ||
3238,13396.mrc,1,-231.62100638454024,2.9636654614427123e-05 | ||
3789,30099.mrc,2,243.32448171011487,5.927330922885425e-05 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
mkdir -p data/dataset_2_submissions tests/data/dataset_2_submissions tests/results | ||
wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/dataset_2_submissions/test_submission_0_n8.pt?download=true -O tests/data/dataset_2_submissions/test_submission_0_n8.pt | ||
wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/Ground_truth/test_maps_gt_flat_10.pt?download=true -O tests/data/test_maps_gt_flat_10.pt | ||
wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/Ground_truth/test_metadata_10.csv?download=true -O tests/data/test_metadata_10.csv | ||
wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/Ground_truth/mask_dilated_wide_224x224.mrc?download=true -O data/mask_dilated_wide_224x224.mrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from omegaconf import OmegaConf | ||
from cryo_challenge._commands import run_distribution2distribution_pipeline | ||
|
||
|
||
def test_run_distribution2distribution_pipeline(): | ||
args = OmegaConf.create({'config': 'tests/config_files/test_config_distribution_to_distribution.yaml'}) | ||
run_distribution2distribution_pipeline.main(args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from omegaconf import OmegaConf | ||
from cryo_challenge._commands import run_map2map_pipeline | ||
|
||
|
||
def test_run_map2map_pipeline(): | ||
args = OmegaConf.create({'config': 'tests/config_files/test_config_map_to_map.yaml'}) | ||
run_map2map_pipeline.main(args) |