From f1197c872a6ece451ae8e1fdd80c162ac59864dc Mon Sep 17 00:00:00 2001 From: Geoffrey Woollard Date: Thu, 20 Jun 2024 15:01:09 -0400 Subject: [PATCH 01/26] tests --- .github/workflows/testing.yml | 32 ++++++++++++++++++++++++++++++++ tests/test_map_to_map.py | 5 +++++ 2 files changed, 37 insertions(+) create mode 100644 .github/workflows/testing.yml create mode 100644 tests/test_map_to_map.py diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml new file mode 100644 index 0000000..4b829dc --- /dev/null +++ b/.github/workflows/testing.yml @@ -0,0 +1,32 @@ +# 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.7", "3.8", "3.9", "3.10"] + + steps: + - uses: actions/checkout@v3 + - 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 --upgrade pip + pip install . + pip install pytest + - name: Test with pytest + run: | + pytest tests/ diff --git a/tests/test_map_to_map.py b/tests/test_map_to_map.py new file mode 100644 index 0000000..968ab07 --- /dev/null +++ b/tests/test_map_to_map.py @@ -0,0 +1,5 @@ +def test_pass(): + assert True + +def test_fail(): + assert False \ No newline at end of file From 991177479ecefe9c1bf6310686db92eff3022df8 Mon Sep 17 00:00:00 2001 From: Geoffrey Woollard Date: Thu, 20 Jun 2024 15:03:46 -0400 Subject: [PATCH 02/26] python version --- .github/workflows/testing.yml | 2 +- tests/test_map_to_map.py | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 4b829dc..1e7f242 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.7", "3.8", "3.9", "3.10"] + python-version: ["3.8", "3.9", "3.10", "3.11"] steps: - uses: actions/checkout@v3 diff --git a/tests/test_map_to_map.py b/tests/test_map_to_map.py index 968ab07..d275259 100644 --- a/tests/test_map_to_map.py +++ b/tests/test_map_to_map.py @@ -1,5 +1,3 @@ def test_pass(): assert True -def test_fail(): - assert False \ No newline at end of file From 23e7323460903cda0d43ea8c180dcdd8ba4bdea5 Mon Sep 17 00:00:00 2001 From: Geoffrey Woollard Date: Thu, 20 Jun 2024 15:10:16 -0400 Subject: [PATCH 03/26] should fail --- tests/test_map_to_map.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_map_to_map.py b/tests/test_map_to_map.py index d275259..968ab07 100644 --- a/tests/test_map_to_map.py +++ b/tests/test_map_to_map.py @@ -1,3 +1,5 @@ def test_pass(): assert True +def test_fail(): + assert False \ No newline at end of file From 3c599ca2dab0f0b5bcd138b60c357d38a73e223f Mon Sep 17 00:00:00 2001 From: Geoffrey Woollard Date: Thu, 20 Jun 2024 15:59:27 -0400 Subject: [PATCH 04/26] unit test. should pass in about 1 min --- ...est_config_map_to_map_distance_matrix.yaml | 26 +++++++++++++++++++ ....py => test_map_to_map_distance_matrix.py} | 0 2 files changed, 26 insertions(+) create mode 100644 config_files/test_config_map_to_map_distance_matrix.yaml rename tests/{test_map_to_map.py => test_map_to_map_distance_matrix.py} (100%) diff --git a/config_files/test_config_map_to_map_distance_matrix.yaml b/config_files/test_config_map_to_map_distance_matrix.yaml new file mode 100644 index 0000000..0398065 --- /dev/null +++ b/config_files/test_config_map_to_map_distance_matrix.yaml @@ -0,0 +1,26 @@ +data: + n_pix: 224 + psize: 2.146 + submission: + fname: data/submission_0.pt + volume_key: volumes + metadata_key: populations + label_key: id + ground_truth: + volumes: data/test_maps_gt_flat.pt + metadata: data/test_metadata.csv + mask: + do: true + volume: data/mask_dilated_wide_224x224.mrc +analysis: + metrics: + - l2 + # - corr + # - bioem + # - fsc + chunk_size_submission: 80 + chunk_size_gt: 190 + normalize: + do: true + method: median_zscore +output: results/test_map_to_map_distance_matrix_submission_0.pkl \ No newline at end of file diff --git a/tests/test_map_to_map.py b/tests/test_map_to_map_distance_matrix.py similarity index 100% rename from tests/test_map_to_map.py rename to tests/test_map_to_map_distance_matrix.py From 7952aaa0ba827735e7737a27d0d34ed739941ece Mon Sep 17 00:00:00 2001 From: Geoffrey Woollard Date: Thu, 20 Jun 2024 16:18:30 -0400 Subject: [PATCH 05/26] test data --- tests/data/test_metadata_2.csv | 3 +++ .../{test_map_to_map_distance_matrix.py => test_map_to_map.py} | 0 2 files changed, 3 insertions(+) create mode 100644 tests/data/test_metadata_2.csv rename tests/{test_map_to_map_distance_matrix.py => test_map_to_map.py} (100%) diff --git a/tests/data/test_metadata_2.csv b/tests/data/test_metadata_2.csv new file mode 100644 index 0000000..b564400 --- /dev/null +++ b/tests/data/test_metadata_2.csv @@ -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 diff --git a/tests/test_map_to_map_distance_matrix.py b/tests/test_map_to_map.py similarity index 100% rename from tests/test_map_to_map_distance_matrix.py rename to tests/test_map_to_map.py From 13caee8029ad02f5ce6a586f9badbffe45e4c254 Mon Sep 17 00:00:00 2001 From: Geoffrey Woollard Date: Thu, 20 Jun 2024 16:39:28 -0400 Subject: [PATCH 06/26] unit test --- tests/test_map_to_map.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/test_map_to_map.py b/tests/test_map_to_map.py index 968ab07..7744af5 100644 --- a/tests/test_map_to_map.py +++ b/tests/test_map_to_map.py @@ -1,5 +1,7 @@ -def test_pass(): - assert True +from omegaconf import OmegaConf +from cryo_challenge._commands import run_map2map_pipeline -def test_fail(): - assert False \ No newline at end of file +args = OmegaConf.create({'config': 'config_files/test_config_map_to_map_distance_matrix.yaml'}) + +def test_run_map2map_pipeline(args): + run_map2map_pipeline.main(args) \ No newline at end of file From 0c56ee319167aa3ed375b33cbda2c2edbf4386a4 Mon Sep 17 00:00:00 2001 From: Geoffrey Woollard Date: Thu, 20 Jun 2024 16:40:00 -0400 Subject: [PATCH 07/26] path to test config --- tests/test_distribution_to_distribution.py | 7 +++++++ tests/test_map_to_map.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 tests/test_distribution_to_distribution.py diff --git a/tests/test_distribution_to_distribution.py b/tests/test_distribution_to_distribution.py new file mode 100644 index 0000000..9dcb1f0 --- /dev/null +++ b/tests/test_distribution_to_distribution.py @@ -0,0 +1,7 @@ +from omegaconf import OmegaConf +from cryo_challenge._commands import run_distribution2distribution_pipeline + +args = OmegaConf.create({'config': 'tests/config_files/test_config_map_to_map_distance_matrix.yaml'}) + +def test_run_distribution2distribution_pipeline(args): + run_distribution2distribution_pipeline.main(args) \ No newline at end of file diff --git a/tests/test_map_to_map.py b/tests/test_map_to_map.py index 7744af5..d470e21 100644 --- a/tests/test_map_to_map.py +++ b/tests/test_map_to_map.py @@ -1,7 +1,7 @@ from omegaconf import OmegaConf from cryo_challenge._commands import run_map2map_pipeline -args = OmegaConf.create({'config': 'config_files/test_config_map_to_map_distance_matrix.yaml'}) +args = OmegaConf.create({'config': 'tests/config_files/test_config_map_to_map_distance_matrix.yaml'}) def test_run_map2map_pipeline(args): run_map2map_pipeline.main(args) \ No newline at end of file From 4e12a3fe12abe569ae3615df2c0f6026692807df Mon Sep 17 00:00:00 2001 From: Geoffrey Woollard Date: Thu, 20 Jun 2024 17:30:05 -0400 Subject: [PATCH 08/26] wget from osf, test. full data --- .github/workflows/testing.yml | 6 +++++ ...t_config_distribution_to_distribution.yaml | 12 ++++++++++ .../config_files/test_config_map_to_map.yaml | 23 +++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 tests/config_files/test_config_distribution_to_distribution.yaml create mode 100644 tests/config_files/test_config_map_to_map.yaml diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 1e7f242..65db3c0 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -27,6 +27,12 @@ jobs: python -m pip install --upgrade pip pip install . pip install pytest + - name: Get test data + run: | + wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/dataset_2_submissions/submission_0.pt?download=true -O data/dataset_2_submissions/submission_0.pt + wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/Ground_truth/gt_maps_flat_float16.pt?download=true -O data/gt_maps_flat_float16.pt + wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/Ground_truth/metadata.csv?download=true -O data/metadata.csv + wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/Ground_truth/metadata.csv?download=true -O data/mask_dilated_wide_224x224.mrc - name: Test with pytest run: | pytest tests/ diff --git a/tests/config_files/test_config_distribution_to_distribution.yaml b/tests/config_files/test_config_distribution_to_distribution.yaml new file mode 100644 index 0000000..48f2546 --- /dev/null +++ b/tests/config_files/test_config_distribution_to_distribution.yaml @@ -0,0 +1,12 @@ +input_fname: results/test_map_to_map_distance_matrix_submission_0.pkl +metrics: + - l2 +gt_metadata_fname: data/metadata.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 \ No newline at end of file diff --git a/tests/config_files/test_config_map_to_map.yaml b/tests/config_files/test_config_map_to_map.yaml new file mode 100644 index 0000000..47e5bd1 --- /dev/null +++ b/tests/config_files/test_config_map_to_map.yaml @@ -0,0 +1,23 @@ +data: + n_pix: 224 + psize: 2.146 + submission: + fname: tests/data/dataset_2_submissions/submission_0.pt + volume_key: volumes + metadata_key: populations + label_key: id + ground_truth: + volumes: data/gt_maps_flat_float16.pt + metadata: data/metadata.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/test_map_to_map_distance_matrix_submission_0.pkl \ No newline at end of file From a94d8f27589aa1b782966f209f35dc9d42a4cdcd Mon Sep 17 00:00:00 2001 From: Geoffrey Woollard Date: Thu, 20 Jun 2024 17:33:19 -0400 Subject: [PATCH 09/26] testing data --- .github/workflows/testing.yml | 4 ++-- tests/config_files/test_config_map_to_map.yaml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 65db3c0..352ac5f 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -30,8 +30,8 @@ jobs: - name: Get test data run: | wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/dataset_2_submissions/submission_0.pt?download=true -O data/dataset_2_submissions/submission_0.pt - wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/Ground_truth/gt_maps_flat_float16.pt?download=true -O data/gt_maps_flat_float16.pt - wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/Ground_truth/metadata.csv?download=true -O data/metadata.csv + wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/Ground_truth/gt_maps_flat_float16.pt?download=true -O tests/data/gt_maps_flat_10.pt + wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/Ground_truth/metadata.csv?download=true -O tests/data/metadat_10a.csv wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/Ground_truth/metadata.csv?download=true -O data/mask_dilated_wide_224x224.mrc - name: Test with pytest run: | diff --git a/tests/config_files/test_config_map_to_map.yaml b/tests/config_files/test_config_map_to_map.yaml index 47e5bd1..7a093dc 100644 --- a/tests/config_files/test_config_map_to_map.yaml +++ b/tests/config_files/test_config_map_to_map.yaml @@ -2,13 +2,13 @@ data: n_pix: 224 psize: 2.146 submission: - fname: tests/data/dataset_2_submissions/submission_0.pt + fname: data/dataset_2_submissions/submission_0.pt volume_key: volumes metadata_key: populations label_key: id ground_truth: - volumes: data/gt_maps_flat_float16.pt - metadata: data/metadata.csv + volumes: tests/data/gt_maps_flat_10.pt + metadata: tests/data/metadata_10.csv mask: do: true volume: data/mask_dilated_wide_224x224.mrc From b5be9add00d7fd2ab646241f3f214437cd11d291 Mon Sep 17 00:00:00 2001 From: Geoffrey Woollard Date: Thu, 20 Jun 2024 17:37:48 -0400 Subject: [PATCH 10/26] empty file for directory --- data/dataset_2_submissions/emptyfile.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 data/dataset_2_submissions/emptyfile.txt diff --git a/data/dataset_2_submissions/emptyfile.txt b/data/dataset_2_submissions/emptyfile.txt new file mode 100644 index 0000000..e69de29 From 0525c74c432091e4f5e5a542437e108fa3fda735 Mon Sep 17 00:00:00 2001 From: Geoffrey Woollard Date: Thu, 20 Jun 2024 17:38:08 -0400 Subject: [PATCH 11/26] name of test --- .github/workflows/testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 352ac5f..b348ec5 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -27,7 +27,7 @@ jobs: python -m pip install --upgrade pip pip install . pip install pytest - - name: Get test data + - name: Get test data from OSF run: | wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/dataset_2_submissions/submission_0.pt?download=true -O data/dataset_2_submissions/submission_0.pt wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/Ground_truth/gt_maps_flat_float16.pt?download=true -O tests/data/gt_maps_flat_10.pt From ee5bc6453ae7a7b9bc85d622c6d1d9318bf37418 Mon Sep 17 00:00:00 2001 From: Geoffrey Woollard Date: Thu, 20 Jun 2024 17:40:40 -0400 Subject: [PATCH 12/26] remove file. can mkdir in github workflow runner --- data/dataset_2_submissions/emptyfile.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 data/dataset_2_submissions/emptyfile.txt diff --git a/data/dataset_2_submissions/emptyfile.txt b/data/dataset_2_submissions/emptyfile.txt deleted file mode 100644 index e69de29..0000000 From 59a283b110b069b97d7b7668d98beb53f18d0f69 Mon Sep 17 00:00:00 2001 From: Geoffrey Woollard Date: Thu, 20 Jun 2024 17:48:42 -0400 Subject: [PATCH 13/26] paths to osf files and pip caching --- .github/workflows/testing.yml | 14 +++++++--- ...est_config_map_to_map_distance_matrix.yaml | 26 ------------------- 2 files changed, 11 insertions(+), 29 deletions(-) delete mode 100644 config_files/test_config_map_to_map_distance_matrix.yaml diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index b348ec5..e7e472d 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -22,6 +22,13 @@ jobs: uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} + - name: Cache pip wheels + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }} + restore-keys: | + ${{ runner.os }}-pip- - name: Install dependencies run: | python -m pip install --upgrade pip @@ -29,10 +36,11 @@ jobs: pip install pytest - name: Get test data from OSF run: | + mkdir data/dataset_2_submissions wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/dataset_2_submissions/submission_0.pt?download=true -O data/dataset_2_submissions/submission_0.pt - wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/Ground_truth/gt_maps_flat_float16.pt?download=true -O tests/data/gt_maps_flat_10.pt - wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/Ground_truth/metadata.csv?download=true -O tests/data/metadat_10a.csv - wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/Ground_truth/metadata.csv?download=true -O data/mask_dilated_wide_224x224.mrc + wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/Ground_truth/gt_maps_flat_10.pt?download=true -O tests/data/gt_maps_flat_10.pt + wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/Ground_truth/metadata_10.csv?download=true -O tests/data/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 - name: Test with pytest run: | pytest tests/ diff --git a/config_files/test_config_map_to_map_distance_matrix.yaml b/config_files/test_config_map_to_map_distance_matrix.yaml deleted file mode 100644 index 0398065..0000000 --- a/config_files/test_config_map_to_map_distance_matrix.yaml +++ /dev/null @@ -1,26 +0,0 @@ -data: - n_pix: 224 - psize: 2.146 - submission: - fname: data/submission_0.pt - volume_key: volumes - metadata_key: populations - label_key: id - ground_truth: - volumes: data/test_maps_gt_flat.pt - metadata: data/test_metadata.csv - mask: - do: true - volume: data/mask_dilated_wide_224x224.mrc -analysis: - metrics: - - l2 - # - corr - # - bioem - # - fsc - chunk_size_submission: 80 - chunk_size_gt: 190 - normalize: - do: true - method: median_zscore -output: results/test_map_to_map_distance_matrix_submission_0.pkl \ No newline at end of file From 78d7d3b25552008fe584c45a6ffa6fdcf02ca163 Mon Sep 17 00:00:00 2001 From: Geoffrey Woollard Date: Thu, 20 Jun 2024 17:56:09 -0400 Subject: [PATCH 14/26] =?UTF-8?q?mkdir:=20cannot=20create=20directory=20?= =?UTF-8?q?=E2=80=98data/dataset=5F2=5Fsubmissions=E2=80=99:=20No=20such?= =?UTF-8?q?=20file=20or=20directory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index e7e472d..773cb66 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -36,7 +36,7 @@ jobs: pip install pytest - name: Get test data from OSF run: | - mkdir data/dataset_2_submissions + mkdir -p data/dataset_2_submissions tests/data/ wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/dataset_2_submissions/submission_0.pt?download=true -O data/dataset_2_submissions/submission_0.pt wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/Ground_truth/gt_maps_flat_10.pt?download=true -O tests/data/gt_maps_flat_10.pt wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/Ground_truth/metadata_10.csv?download=true -O tests/data/metadata_10.csv From d6535451d4fa20f59e2aa690f4180f7561d10bfe Mon Sep 17 00:00:00 2001 From: Geoffrey Woollard Date: Thu, 20 Jun 2024 18:12:53 -0400 Subject: [PATCH 15/26] local pytest passing. osf paths updated. --- .github/workflows/testing.yml | 6 +++--- .../test_config_distribution_to_distribution.yaml | 4 ++-- tests/config_files/test_config_map_to_map.yaml | 6 +++--- tests/test_distribution_to_distribution.py | 4 ++-- tests/test_map_to_map.py | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 773cb66..d476ee8 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -36,10 +36,10 @@ jobs: pip install pytest - name: Get test data from OSF run: | - mkdir -p data/dataset_2_submissions tests/data/ + mkdir -p data/dataset_2_submissions tests/data/ tests/results wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/dataset_2_submissions/submission_0.pt?download=true -O data/dataset_2_submissions/submission_0.pt - wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/Ground_truth/gt_maps_flat_10.pt?download=true -O tests/data/gt_maps_flat_10.pt - wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/Ground_truth/metadata_10.csv?download=true -O tests/data/metadata_10.csv + wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/Ground_truth/test_maps_gt_flat_10.pt?download=true -O tests/data/gt_maps_flat_10.pt + wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/Ground_truth/test_metadata_10.csv?download=true -O tests/data/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 - name: Test with pytest run: | diff --git a/tests/config_files/test_config_distribution_to_distribution.yaml b/tests/config_files/test_config_distribution_to_distribution.yaml index 48f2546..9359e58 100644 --- a/tests/config_files/test_config_distribution_to_distribution.yaml +++ b/tests/config_files/test_config_distribution_to_distribution.yaml @@ -1,7 +1,7 @@ -input_fname: results/test_map_to_map_distance_matrix_submission_0.pkl +input_fname: tests/results/test_map_to_map_distance_matrix_submission_0.pkl metrics: - l2 -gt_metadata_fname: data/metadata.csv +gt_metadata_fname: tests/data/test_metadata_10.csv n_replicates: 3 n_pool_microstate: 2 replicate_fraction: 0.9 diff --git a/tests/config_files/test_config_map_to_map.yaml b/tests/config_files/test_config_map_to_map.yaml index 7a093dc..2e7af67 100644 --- a/tests/config_files/test_config_map_to_map.yaml +++ b/tests/config_files/test_config_map_to_map.yaml @@ -7,8 +7,8 @@ data: metadata_key: populations label_key: id ground_truth: - volumes: tests/data/gt_maps_flat_10.pt - metadata: tests/data/metadata_10.csv + 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 @@ -20,4 +20,4 @@ analysis: normalize: do: true method: median_zscore -output: tests/test_map_to_map_distance_matrix_submission_0.pkl \ No newline at end of file +output: tests/results/test_map_to_map_distance_matrix_submission_0.pkl \ No newline at end of file diff --git a/tests/test_distribution_to_distribution.py b/tests/test_distribution_to_distribution.py index 9dcb1f0..d9c340b 100644 --- a/tests/test_distribution_to_distribution.py +++ b/tests/test_distribution_to_distribution.py @@ -1,7 +1,7 @@ from omegaconf import OmegaConf from cryo_challenge._commands import run_distribution2distribution_pipeline -args = OmegaConf.create({'config': 'tests/config_files/test_config_map_to_map_distance_matrix.yaml'}) -def test_run_distribution2distribution_pipeline(args): +def test_run_distribution2distribution_pipeline(): + args = OmegaConf.create({'config': 'tests/config_files/test_config_distribution_to_distribution.yaml'}) run_distribution2distribution_pipeline.main(args) \ No newline at end of file diff --git a/tests/test_map_to_map.py b/tests/test_map_to_map.py index d470e21..c782a8c 100644 --- a/tests/test_map_to_map.py +++ b/tests/test_map_to_map.py @@ -1,7 +1,7 @@ from omegaconf import OmegaConf from cryo_challenge._commands import run_map2map_pipeline -args = OmegaConf.create({'config': 'tests/config_files/test_config_map_to_map_distance_matrix.yaml'}) -def test_run_map2map_pipeline(args): +def test_run_map2map_pipeline(): + args = OmegaConf.create({'config': 'tests/config_files/test_config_map_to_map.yaml'}) run_map2map_pipeline.main(args) \ No newline at end of file From 76689e9a62463c999d62967a0718c1d4b94dfd7c Mon Sep 17 00:00:00 2001 From: Geoffrey Woollard Date: Thu, 20 Jun 2024 18:24:06 -0400 Subject: [PATCH 16/26] omegaconf dependency --- .github/workflows/testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index d476ee8..2c20784 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -33,7 +33,7 @@ jobs: run: | python -m pip install --upgrade pip pip install . - pip install pytest + pip install pytest omegaconf - name: Get test data from OSF run: | mkdir -p data/dataset_2_submissions tests/data/ tests/results From 48ab7750b05121d6dd94e68cb108e8300a4f5d36 Mon Sep 17 00:00:00 2001 From: Geoffrey Woollard Date: Thu, 20 Jun 2024 20:29:37 -0400 Subject: [PATCH 17/26] test submission with 8 volumes --- .github/workflows/testing.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 2c20784..9102a97 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -36,8 +36,8 @@ jobs: pip install pytest omegaconf - name: Get test data from OSF run: | - mkdir -p data/dataset_2_submissions tests/data/ tests/results - wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/dataset_2_submissions/submission_0.pt?download=true -O data/dataset_2_submissions/submission_0.pt + 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/gt_maps_flat_10.pt wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/Ground_truth/test_metadata_10.csv?download=true -O tests/data/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 From 5b2e576277dbd55cc2c90c908f4355bb01931192 Mon Sep 17 00:00:00 2001 From: Geoffrey Woollard Date: Thu, 20 Jun 2024 20:30:22 -0400 Subject: [PATCH 18/26] path --- tests/config_files/test_config_map_to_map.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/config_files/test_config_map_to_map.yaml b/tests/config_files/test_config_map_to_map.yaml index 2e7af67..eed5fb0 100644 --- a/tests/config_files/test_config_map_to_map.yaml +++ b/tests/config_files/test_config_map_to_map.yaml @@ -2,7 +2,7 @@ data: n_pix: 224 psize: 2.146 submission: - fname: data/dataset_2_submissions/submission_0.pt + fname: tests/data/dataset_2_submissions/test_submission_0_n8.pt volume_key: volumes metadata_key: populations label_key: id From a8a8a95e2bdb1cb2801a5e6b4d95516f4162a633 Mon Sep 17 00:00:00 2001 From: Geoffrey Woollard Date: Thu, 20 Jun 2024 20:35:23 -0400 Subject: [PATCH 19/26] paths --- .github/workflows/testing.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 9102a97..c1da099 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -38,8 +38,8 @@ jobs: run: | 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/gt_maps_flat_10.pt - wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/Ground_truth/test_metadata_10.csv?download=true -O tests/data/metadata_10.csv + 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 - name: Test with pytest run: | From d80124593166b8213d367c2cafe5c85f1e631138 Mon Sep 17 00:00:00 2001 From: Geoffrey Woollard Date: Thu, 20 Jun 2024 20:55:35 -0400 Subject: [PATCH 20/26] order of tests --- .github/workflows/testing.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index c1da099..2b67b37 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -43,4 +43,5 @@ jobs: 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 - name: Test with pytest run: | - pytest tests/ + pytest tests/test_map_to_map.py + pytest tests/test_distribution_to_distribution.py From 8d905e6e94a2e03b8caf5195c6185ae9554f9c16 Mon Sep 17 00:00:00 2001 From: Geoffrey Woollard Date: Thu, 20 Jun 2024 21:03:44 -0400 Subject: [PATCH 21/26] script for getting osf data --- tests/scripts/fetch_test_data.sh | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 tests/scripts/fetch_test_data.sh diff --git a/tests/scripts/fetch_test_data.sh b/tests/scripts/fetch_test_data.sh new file mode 100644 index 0000000..740d895 --- /dev/null +++ b/tests/scripts/fetch_test_data.sh @@ -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 \ No newline at end of file From 9afc6e642ef45f4aa84bb97d6bdedde221ab8706 Mon Sep 17 00:00:00 2001 From: Geoffrey Woollard Date: Thu, 20 Jun 2024 21:11:05 -0400 Subject: [PATCH 22/26] script to download --- .github/workflows/testing.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 2b67b37..327e80f 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -36,11 +36,7 @@ jobs: pip install pytest omegaconf - name: Get test data from OSF run: | - 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 + sh tests/scripts/fetch_test_data.sh - name: Test with pytest run: | pytest tests/test_map_to_map.py From 969c46b831df4c605e56d87aa89401bd13533338 Mon Sep 17 00:00:00 2001 From: Geoffrey Woollard Date: Thu, 20 Jun 2024 21:58:50 -0400 Subject: [PATCH 23/26] cache data --- .github/workflows/testing.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 327e80f..c0cd322 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -25,8 +25,10 @@ jobs: - name: Cache pip wheels uses: actions/cache@v3 with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }} + path: | + ~/.cache/pip + tests/data + key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml', '**/tests/scripts/fetch_test_data.sh') }} restore-keys: | ${{ runner.os }}-pip- - name: Install dependencies From 52e53ad43480dab7269b7304cbfee5632c09c1d4 Mon Sep 17 00:00:00 2001 From: Geoffrey Woollard Date: Thu, 20 Jun 2024 21:59:45 -0400 Subject: [PATCH 24/26] cache data --- .github/workflows/testing.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index c0cd322..228e04a 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -28,6 +28,7 @@ jobs: path: | ~/.cache/pip tests/data + data key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml', '**/tests/scripts/fetch_test_data.sh') }} restore-keys: | ${{ runner.os }}-pip- From 4aed02c944c21064731f7fffe078f2be20bde271 Mon Sep 17 00:00:00 2001 From: Geoffrey Woollard Date: Thu, 20 Jun 2024 22:05:12 -0400 Subject: [PATCH 25/26] cache data --- .github/workflows/testing.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 228e04a..277ad1a 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -1,6 +1,6 @@ -# GHA workflow for running tests. +# GHA workflow for running tests. # -# Largely taken from +# 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 @@ -18,11 +18,14 @@ jobs: 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 pip wheels + + - name: Cache dependencies and test data + id: cache uses: actions/cache@v3 with: path: | @@ -32,15 +35,19 @@ jobs: 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 + pytest tests/test_distribution_to_distribution.py From e9e0532d998b785e5db2ece11c29a83d0fafb7b1 Mon Sep 17 00:00:00 2001 From: DavidHerreros Date: Mon, 24 Jun 2024 10:06:29 +0200 Subject: [PATCH 26/26] Adding omegaconf to "dev" dependencies to allow running the tests locally --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index cf03973..85e73d5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,7 +58,8 @@ dev = [ "pytest", "mypy", "pre-commit", - "ruff" + "ruff", + "omegaconf" ] [project.urls]