Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions tests/aignostics/application/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1111,8 +1111,8 @@ def test_cli_run_execute(runner: CliRunner, tmp_path: Path, record_property) ->
results_dir = tmp_path / SPOT_1_FILENAME.replace(".tiff", "")
assert results_dir.is_dir(), f"Expected directory {results_dir} not found"
files_in_dir = list(results_dir.glob("*"))
assert len(files_in_dir) == 9, (
f"Expected 9 files in {results_dir}, but found {len(files_in_dir)}: {[f.name for f in files_in_dir]}"
assert len(files_in_dir) == 12, (
f"Expected 12 files in {results_dir}, but found {len(files_in_dir)}: {[f.name for f in files_in_dir]}"
Comment on lines +1114 to +1115
)
print(f"Found files in {results_dir}:")
for filename, expected_size, tolerance_percent in SPOT_1_EXPECTED_RESULT_FILES:
Expand All @@ -1133,6 +1133,25 @@ def test_cli_run_execute(runner: CliRunner, tmp_path: Path, record_property) ->
f"({min_size} to {max_size} bytes, ±{tolerance_percent}% of {expected_size})"
)

# Validate parquet <-> GeoJSON row count parity for the 3 paired outputs
import pandas as pd

parquet_geojson_pairs = [
("tissue_qc_parquet_polygons.parquet", "tissue_qc_geojson_polygons.json"),
("tissue_segmentation_parquet_polygons.parquet", "tissue_segmentation_geojson_polygons.json"),
("cell_classification_parquet_polygons.parquet", "cell_classification_geojson_polygons.json"),
]
for parquet_filename, geojson_filename in parquet_geojson_pairs:
parquet_path = results_dir / parquet_filename
geojson_path = results_dir / geojson_filename
parquet_row_count = len(pd.read_parquet(parquet_path))
with geojson_path.open() as f:
geojson_feature_count = len(json.load(f)["features"])
assert parquet_row_count == geojson_feature_count, (
f"Row count mismatch between {parquet_filename} ({parquet_row_count} rows) "
f"and {geojson_filename} ({geojson_feature_count} features)"
)

# Validate the execute command exited successfully
assert result.exit_code == 0

Expand Down
27 changes: 24 additions & 3 deletions tests/aignostics/application/gui_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ async def test_gui_download_dataset_via_application_to_run_cancel_to_find_back(
@pytest.mark.flaky(retries=1, delay=5)
@pytest.mark.timeout(timeout=60 * 10)
@pytest.mark.sequential # Helps on Linux with image analysis step otherwise timing out
async def test_gui_run_download( # noqa: PLR0915
async def test_gui_run_download( # noqa: PLR0914, PLR0915
user: User, runner: CliRunner, tmp_path: Path, silent_logging: None, record_property
) -> None:
"""Test that the user can download a run result via the GUI."""
Expand Down Expand Up @@ -440,8 +440,8 @@ async def test_gui_run_download( # noqa: PLR0915

# Check for files in the results directory
files_in_results_dir = list(results_dir.glob("*"))
assert len(files_in_results_dir) == 9, (
f"Expected 9 files in {results_dir}, but found {len(files_in_results_dir)}: "
assert len(files_in_results_dir) == 12, (
f"Expected 12 files in {results_dir}, but found {len(files_in_results_dir)}: "
Comment on lines +443 to +444
f"{[f.name for f in files_in_results_dir]}"
)

Expand All @@ -464,6 +464,27 @@ async def test_gui_run_download( # noqa: PLR0915
f"({min_size} to {max_size} bytes, ±{tolerance_percent}% of {expected_size})"
)

# Validate parquet <-> GeoJSON row count parity for the 3 paired outputs
import json

import pandas as pd

parquet_geojson_pairs = [
("tissue_qc_parquet_polygons.parquet", "tissue_qc_geojson_polygons.json"),
("tissue_segmentation_parquet_polygons.parquet", "tissue_segmentation_geojson_polygons.json"),
("cell_classification_parquet_polygons.parquet", "cell_classification_geojson_polygons.json"),
]
for parquet_filename, geojson_filename in parquet_geojson_pairs:
parquet_path = results_dir / parquet_filename
geojson_path = results_dir / geojson_filename
parquet_row_count = len(pd.read_parquet(parquet_path))
with geojson_path.open() as f:
geojson_feature_count = len(json.load(f)["features"])
assert parquet_row_count == geojson_feature_count, (
f"Row count mismatch between {parquet_filename} ({parquet_row_count} rows) "
f"and {geojson_filename} ({geojson_feature_count} features)"
)


@pytest.mark.integration
@pytest.mark.sequential
Expand Down
48 changes: 30 additions & 18 deletions tests/constants_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,18 @@
# SPOT_0: uv run pytest tests/aignostics/application/gui_test.py::test_gui_run_download -s --no-cov
# SPOT_1: uv run pytest tests/aignostics/application/cli_test.py::test_cli_run_execute -s --no-cov
SPOT_0_EXPECTED_RESULT_FILES = [
("tissue_qc_segmentation_map_image.tiff", 1642856, 10),
("tissue_qc_geojson_polygons.json", 259955, 10),
("tissue_segmentation_geojson_polygons.json", 887003, 10),
("readout_generation_slide_readouts.csv", 303217, 10),
("readout_generation_cell_readouts.csv", 1658344, 10),
("cell_classification_geojson_polygons.json", 11218951, 10),
("tissue_segmentation_segmentation_map_image.tiff", 2945078, 10),
("tissue_segmentation_csv_class_information.csv", 452, 10),
("tissue_qc_csv_class_information.csv", 285, 10),
("tissue_qc_segmentation_map_image.tiff", 470150, 10),
("tissue_qc_geojson_polygons.json", 171251, 10),
("tissue_segmentation_geojson_polygons.json", 185516, 10),
("readout_generation_slide_readouts.csv", 300205, 10),
("readout_generation_cell_readouts.csv", 2417117, 10),
("cell_classification_geojson_polygons.json", 16673412, 10),
("tissue_segmentation_segmentation_map_image.tiff", 527264, 10),
("tissue_segmentation_csv_class_information.csv", 443, 10),
("tissue_qc_csv_class_information.csv", 286, 10),
("tissue_qc_parquet_polygons.parquet", 34346, 10),
("tissue_segmentation_parquet_polygons.parquet", 39185, 10),
("cell_classification_parquet_polygons.parquet", 5476364, 10),
Comment on lines 85 to +97
]
SPOT_0_EXPECTED_CELLS_CLASSIFIED = (39798, 10)

Expand All @@ -105,6 +108,9 @@
("tissue_segmentation_segmentation_map_image.tiff", 1783952, 10),
("tissue_segmentation_csv_class_information.csv", 446, 10),
("tissue_qc_csv_class_information.csv", 290, 10),
("tissue_qc_parquet_polygons.parquet", 29049, 10),
("tissue_segmentation_parquet_polygons.parquet", 56682, 10),
("cell_classification_parquet_polygons.parquet", 838533, 10),
]

case "staging":
Expand All @@ -124,15 +130,18 @@

# See production block above for instructions on how to update these sizes.
SPOT_0_EXPECTED_RESULT_FILES = [
("tissue_qc_segmentation_map_image.tiff", 1642856, 10),
("tissue_qc_geojson_polygons.json", 259955, 10),
("tissue_segmentation_geojson_polygons.json", 887003, 10),
("readout_generation_slide_readouts.csv", 303217, 10),
("readout_generation_cell_readouts.csv", 1658344, 10),
("cell_classification_geojson_polygons.json", 11218951, 10),
("tissue_segmentation_segmentation_map_image.tiff", 2945078, 10),
("tissue_segmentation_csv_class_information.csv", 452, 10),
("tissue_qc_csv_class_information.csv", 285, 10),
("tissue_qc_segmentation_map_image.tiff", 470150, 10),
("tissue_qc_geojson_polygons.json", 171251, 10),
("tissue_segmentation_geojson_polygons.json", 185516, 10),
("readout_generation_slide_readouts.csv", 300205, 10),
("readout_generation_cell_readouts.csv", 2417117, 10),
("cell_classification_geojson_polygons.json", 16673412, 10),
("tissue_segmentation_segmentation_map_image.tiff", 527264, 10),
("tissue_segmentation_csv_class_information.csv", 443, 10),
("tissue_qc_csv_class_information.csv", 286, 10),
("tissue_qc_parquet_polygons.parquet", 34346, 10),
("tissue_segmentation_parquet_polygons.parquet", 39185, 10),
("cell_classification_parquet_polygons.parquet", 5476364, 10),
]
SPOT_0_EXPECTED_CELLS_CLASSIFIED = (39798, 10)

Expand All @@ -146,6 +155,9 @@
("tissue_segmentation_segmentation_map_image.tiff", 1783952, 10),
("tissue_segmentation_csv_class_information.csv", 446, 10),
("tissue_qc_csv_class_information.csv", 290, 10),
("tissue_qc_parquet_polygons.parquet", 29049, 10),
("tissue_segmentation_parquet_polygons.parquet", 56682, 10),
("cell_classification_parquet_polygons.parquet", 838533, 10),
]

case _:
Expand Down