From b8cea017f08c55a1f8008fef49414646158a35ce Mon Sep 17 00:00:00 2001 From: Jessica Gadling Date: Mon, 21 Oct 2024 14:23:25 -0400 Subject: [PATCH] Tests. --- .../scripts/tests/db_import/populate_db.py | 7 +++-- .../db_import/test_db_annotation_import.py | 8 ++--- .../tests/db_import/test_db_tomo_import.py | 30 +++++++++++-------- .../Tomograms/100/tomogram_metadata.json | 4 +-- 4 files changed, 29 insertions(+), 20 deletions(-) diff --git a/ingestion_tools/scripts/tests/db_import/populate_db.py b/ingestion_tools/scripts/tests/db_import/populate_db.py index cc26e7029..ee30a0009 100644 --- a/ingestion_tools/scripts/tests/db_import/populate_db.py +++ b/ingestion_tools/scripts/tests/db_import/populate_db.py @@ -192,6 +192,7 @@ def populate_stale_tomogram_voxel_spacing(run_id: int = RUN1_ID) -> None: TomogramAuthor.create(tomogram_id=stale_tomogram.id, name="John John", author_list_order=2) stale_annotation = Annotation.create( tomogram_voxel_spacing_id=stale_voxel_spacing.id, + deposition_id=DEPOSITION_ID2, s3_metadata_path="foo", https_metadata_path="foo", deposition_date="2025-04-01", @@ -342,14 +343,15 @@ def populate_annotations() -> None: Annotation.create( id=ANNOTATION_ID, tomogram_voxel_spacing_id=TOMOGRAM_VOXEL_ID1, + deposition_id=DEPOSITION_ID2, s3_metadata_path="s3://test-public-bucket/30001/RUN1/Tomograms/VoxelSpacing12.300/Annotations/100-foo-1.0.json", https_metadata_path="foo", deposition_date="2025-04-01", release_date="2025-06-01", last_modified_date="2025-06-01", - annotation_method="", + annotation_method="2D CNN predictions", ground_truth_status=False, - object_name="bar", + object_name="foo", object_count=0, object_id="invalid-id", annotation_software="bar", @@ -360,6 +362,7 @@ def populate_stale_annotations() -> None: Annotation.create( id=STALE_ANNOTATION_ID, tomogram_voxel_spacing_id=TOMOGRAM_VOXEL_ID1, + deposition_id=DEPOSITION_ID2, s3_metadata_path="foo", https_metadata_path="foo", deposition_date="2025-04-01", diff --git a/ingestion_tools/scripts/tests/db_import/test_db_annotation_import.py b/ingestion_tools/scripts/tests/db_import/test_db_annotation_import.py index bc60beb12..043928f53 100644 --- a/ingestion_tools/scripts/tests/db_import/test_db_annotation_import.py +++ b/ingestion_tools/scripts/tests/db_import/test_db_annotation_import.py @@ -19,7 +19,7 @@ @pytest.fixture def expected_annotations(http_prefix: str) -> list[dict[str, Any]]: - path = f"{DATASET_ID}/RUN1/Tomograms/VoxelSpacing12.300/Annotations/100-foo-1.0.json" + path = f"{DATASET_ID}/RUN1/Reconstructions/VoxelSpacing12.300/Annotations/100/foo-1.0.json" return [ { "id": ANNOTATION_ID, @@ -43,12 +43,12 @@ def expected_annotations(http_prefix: str) -> list[dict[str, Any]]: { "link": "https://fake-link.com/resources/100-foo-1.0_method.pdf", "link_type": "documentation", - "name": "Method Documentation", + "custom_name": "Method Documentation", }, { "link": "https://another-link.com/100-foo-1.0_code.zip", "link_type": "source_code", - "name": "Source Code", + "custom_name": "Source Code", }, ], }, @@ -57,7 +57,7 @@ def expected_annotations(http_prefix: str) -> list[dict[str, Any]]: @pytest.fixture def expected_annotation_files(http_prefix: str) -> list[dict[str, Any]]: - path = f"{DATASET_ID}/RUN1/Tomograms/VoxelSpacing12.300/Annotations/" + path = f"{DATASET_ID}/RUN1/Reconstructions/VoxelSpacing12.300/Annotations/" return [ { "id": ANNOTATION_FILE_ID, diff --git a/ingestion_tools/scripts/tests/db_import/test_db_tomo_import.py b/ingestion_tools/scripts/tests/db_import/test_db_tomo_import.py index d2ad3e626..e07a999a6 100644 --- a/ingestion_tools/scripts/tests/db_import/test_db_tomo_import.py +++ b/ingestion_tools/scripts/tests/db_import/test_db_tomo_import.py @@ -68,10 +68,10 @@ def expected_tomograms_by_run(http_prefix: str) -> dict[str, dict[float, list[di "processing_software": "tomo3D", "tomogram_version": "1", "is_canonical": True, - "s3_omezarr_dir": f"s3://test-public-bucket/{run1_vs_path}CanonicalTomogram/RUN1.zarr", - "https_omezarr_dir": f"{http_prefix}/{run1_vs_path}CanonicalTomogram/RUN1.zarr", - "s3_mrc_scale0": f"s3://test-public-bucket/{run1_vs_path}CanonicalTomogram/RUN1.mrc", - "https_mrc_scale0": f"{http_prefix}/{run1_vs_path}CanonicalTomogram/RUN1.mrc", + "s3_omezarr_dir": f"s3://test-public-bucket/{run1_vs_path}Tomograms/100/RUN1.zarr", + "https_omezarr_dir": f"{http_prefix}/{run1_vs_path}Tomograms/100/RUN1.zarr", + "s3_mrc_scale0": f"s3://test-public-bucket/{run1_vs_path}Tomograms/100/RUN1.mrc", + "https_mrc_scale0": f"{http_prefix}/{run1_vs_path}Tomograms/100/RUN1.mrc", "scale0_dimensions": "980,1016,500", "scale1_dimensions": "490,508,250", "scale2_dimensions": "245,254,125", @@ -85,11 +85,11 @@ def expected_tomograms_by_run(http_prefix: str) -> dict[str, dict[float, list[di [0, 0, 1, 0], [0, 0, 0, 1], ], - "key_photo_url": f"{http_prefix}/{run1_vs_path}KeyPhotos/key-photo-snapshot.png", - "key_photo_thumbnail_url": f"{http_prefix}/{run1_vs_path}KeyPhotos/key-photo-thumbnail.png", + "key_photo_url": f"{http_prefix}/{run1_vs_path}Images/key-photo-snapshot.png", + "key_photo_thumbnail_url": f"{http_prefix}/{run1_vs_path}Images/key-photo-thumbnail.png", "neuroglancer_config": '{"foo":"bar","baz":"test"}', "type": "CANONICAL", - "deposition_id": 301, + "deposition_id": 300, } run2_tomo = { "name": "RUN2", @@ -102,11 +102,17 @@ def expected_tomograms_by_run(http_prefix: str) -> dict[str, dict[float, list[di "reconstruction_software": "Unknown", "processing": "filtered", "tomogram_version": "1", + "affine_transformation_matrix": [ + [1, 0, 0, 0], + [0, 1, 0, 0], + [0, 0, 1, 0], + [0, 0, 0, 1], + ], "is_canonical": True, - "s3_omezarr_dir": f"s3://test-public-bucket/{run2_vs_path}CanonicalTomogram/RUN2.zarr", - "https_omezarr_dir": f"{http_prefix}/{run2_vs_path}CanonicalTomogram/RUN2.zarr", - "s3_mrc_scale0": f"s3://test-public-bucket/{run2_vs_path}CanonicalTomogram/RUN2.mrc", - "https_mrc_scale0": f"{http_prefix}/{run2_vs_path}CanonicalTomogram/RUN2.mrc", + "s3_omezarr_dir": f"s3://test-public-bucket/{run2_vs_path}Tomograms/100/RUN2.zarr", + "https_omezarr_dir": f"{http_prefix}/{run2_vs_path}Tomograms/100/RUN2.zarr", + "s3_mrc_scale0": f"s3://test-public-bucket/{run2_vs_path}Tomograms/100/RUN2.mrc", + "https_mrc_scale0": f"{http_prefix}/{run2_vs_path}Tomograms/100/RUN2.mrc", "scale0_dimensions": "800,800,400", "scale1_dimensions": "400,400,200", "scale2_dimensions": "200,200,100", @@ -114,7 +120,7 @@ def expected_tomograms_by_run(http_prefix: str) -> dict[str, dict[float, list[di "offset_x": 0, "offset_y": 0, "offset_z": 0, - "neuroglancer_config": "{}", + "neuroglancer_config": '{"foo":"bar","baz":"test"}', "type": "CANONICAL", "deposition_id": 300, } diff --git a/test_infra/test_files/30001/RUN2/Reconstructions/VoxelSpacing3.456/Tomograms/100/tomogram_metadata.json b/test_infra/test_files/30001/RUN2/Reconstructions/VoxelSpacing3.456/Tomograms/100/tomogram_metadata.json index f170640a8..c83c5bc0a 100644 --- a/test_infra/test_files/30001/RUN2/Reconstructions/VoxelSpacing3.456/Tomograms/100/tomogram_metadata.json +++ b/test_infra/test_files/30001/RUN2/Reconstructions/VoxelSpacing3.456/Tomograms/100/tomogram_metadata.json @@ -70,7 +70,7 @@ "last_modified_date": "2022-09-02", "release_date": "2022-06-01" }, - "alignment_metadata_path": "test-public-bucket/30001/RUN2/Alignments/100/alignment_metadata.json", - "neuroglancer_config_path": "test-public-bucket/30001/RUN2/Reconstructions/VoxelSpacing13.480/NeuroglancerPrecompute/100-neuroglancer_config.json", + "alignment_metadata_path": null, + "neuroglancer_config_path": null, "last_updated_at": 1728676818 }