Skip to content

Commit 61d970c

Browse files
ari-nzclaude
andcommitted
chore(tests): stop checking he-tme output file sizes
Sizes drift on every he-tme release. The e2e tests now compare the set of output file names only; SPOT_0 and SPOT_1 share one HETA_EXPECTED_RESULT_FILES. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent a0ffe2b commit 61d970c

4 files changed

Lines changed: 34 additions & 128 deletions

File tree

‎tests/aignostics/application/cli_test.py‎

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@
3737
from tests.constants_test import (
3838
HETA_APPLICATION_ID,
3939
HETA_APPLICATION_VERSION,
40+
HETA_EXPECTED_RESULT_FILES,
4041
PIPELINE_GPU_TYPE,
4142
SPOT_0_CRC32C,
4243
SPOT_0_FILENAME,
4344
SPOT_0_GS_URL,
4445
SPOT_0_HEIGHT,
4546
SPOT_0_RESOLUTION_MPP,
4647
SPOT_0_WIDTH,
47-
SPOT_1_EXPECTED_RESULT_FILES,
4848
SPOT_1_FILENAME,
4949
SPOT_1_FILESIZE,
5050
SPOT_1_GS_URL,
@@ -1381,32 +1381,11 @@ def test_cli_run_execute(runner: CliRunner, tmp_path: Path, record_property) ->
13811381
# Validate results generated and downloaded
13821382
results_dir = tmp_path / SPOT_1_FILENAME.replace(".tiff", "")
13831383
assert results_dir.is_dir(), f"Expected directory {results_dir} not found"
1384-
files_in_dir = list(results_dir.glob("*"))
1385-
expected_count = len(SPOT_1_EXPECTED_RESULT_FILES)
1386-
assert len(files_in_dir) == expected_count, (
1387-
f"Expected {expected_count} files in {results_dir}, but found {len(files_in_dir)}: "
1388-
f"{[f.name for f in files_in_dir]}"
1384+
files_in_dir = {f.name for f in results_dir.glob("*")}
1385+
assert files_in_dir == HETA_EXPECTED_RESULT_FILES, (
1386+
f"Unexpected files in {results_dir}: missing {sorted(HETA_EXPECTED_RESULT_FILES - files_in_dir)}, "
1387+
f"extra {sorted(files_in_dir - HETA_EXPECTED_RESULT_FILES)}"
13891388
)
1390-
print(f"Found files in {results_dir}:")
1391-
for filename, expected_size, tolerance_percent in SPOT_1_EXPECTED_RESULT_FILES:
1392-
file_path = results_dir / filename
1393-
if file_path.exists():
1394-
actual_size = file_path.stat().st_size
1395-
print(f" {filename}: {actual_size} bytes (expected: {expected_size} ±{tolerance_percent}%)")
1396-
else:
1397-
print(f" {filename}: NOT FOUND")
1398-
for filename, expected_size, tolerance_percent in SPOT_1_EXPECTED_RESULT_FILES:
1399-
file_path = results_dir / filename
1400-
assert file_path.exists(), f"Expected file {filename} not found"
1401-
if expected_size is None: # shortcut: sizes unset after he-tme bump, re-baseline
1402-
continue
1403-
actual_size = file_path.stat().st_size
1404-
min_size = expected_size * (100 - tolerance_percent) // 100
1405-
max_size = expected_size * (100 + tolerance_percent) // 100
1406-
assert min_size <= actual_size <= max_size, (
1407-
f"File size for {filename} ({actual_size} bytes) is outside allowed range "
1408-
f"({min_size} to {max_size} bytes, ±{tolerance_percent}% of {expected_size})"
1409-
)
14101389

14111390
# Validate parquet <-> GeoJSON parity: area for segmentation, count for cell classification.
14121391
assert_parquet_geojson_parity(results_dir)

‎tests/aignostics/application/gui_test.py‎

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
from tests.constants_test import (
2626
HETA_APPLICATION_ID,
2727
HETA_APPLICATION_VERSION,
28+
HETA_EXPECTED_RESULT_FILES,
2829
PIPELINE_GPU_TYPE,
29-
SPOT_0_EXPECTED_RESULT_FILES,
3030
SPOT_0_FILENAME,
3131
SPOT_0_FILESIZE,
3232
SPOT_0_GS_URL,
@@ -326,7 +326,7 @@ async def test_gui_download_dataset_via_application_to_run_cancel_to_find_back(
326326
@pytest.mark.flaky(retries=1, delay=5)
327327
@pytest.mark.timeout(timeout=60 * 10)
328328
@pytest.mark.sequential # Helps on Linux with image analysis step otherwise timing out
329-
async def test_gui_run_download( # noqa: PLR0915
329+
async def test_gui_run_download(
330330
user: User, runner: CliRunner, tmp_path: Path, silent_logging: None, record_property
331331
) -> None:
332332
"""Test that the user can download a run result via the GUI."""
@@ -411,34 +411,12 @@ async def test_gui_run_download( # noqa: PLR0915
411411
)
412412

413413
# Check for files in the results directory
414-
files_in_results_dir = list(results_dir.glob("*"))
415-
expected_count = len(SPOT_0_EXPECTED_RESULT_FILES)
416-
assert len(files_in_results_dir) == expected_count, (
417-
f"Expected {expected_count} files in {results_dir}, but found {len(files_in_results_dir)}: "
418-
f"{[f.name for f in files_in_results_dir]}"
414+
files_in_results_dir = {f.name for f in results_dir.glob("*")}
415+
assert files_in_results_dir == HETA_EXPECTED_RESULT_FILES, (
416+
f"Unexpected files in {results_dir}: missing {sorted(HETA_EXPECTED_RESULT_FILES - files_in_results_dir)}, "
417+
f"extra {sorted(files_in_results_dir - HETA_EXPECTED_RESULT_FILES)}"
419418
)
420419

421-
print(f"Found files in {results_dir}:")
422-
for filename, expected_size, tolerance_percent in SPOT_0_EXPECTED_RESULT_FILES:
423-
file_path = results_dir / filename
424-
if file_path.exists():
425-
actual_size = file_path.stat().st_size
426-
print(f" {filename}: {actual_size} bytes (expected: {expected_size} ±{tolerance_percent}%)")
427-
else:
428-
print(f" {filename}: NOT FOUND")
429-
for filename, expected_size, tolerance_percent in SPOT_0_EXPECTED_RESULT_FILES:
430-
file_path = results_dir / filename
431-
assert file_path.exists(), f"Expected file {filename} not found"
432-
if expected_size is None: # shortcut: sizes unset after he-tme bump, re-baseline
433-
continue
434-
actual_size = file_path.stat().st_size
435-
min_size = expected_size * (100 - tolerance_percent) // 100
436-
max_size = expected_size * (100 + tolerance_percent) // 100
437-
assert min_size <= actual_size <= max_size, (
438-
f"File size for {filename} ({actual_size} bytes) is outside allowed range "
439-
f"({min_size} to {max_size} bytes, ±{tolerance_percent}% of {expected_size})"
440-
)
441-
442420
# Validate parquet <-> GeoJSON parity: area for segmentation, count for cell classification.
443421
assert_parquet_geojson_parity(results_dir)
444422

‎tests/aignostics/qupath/gui_test.py‎

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from tests.constants_test import (
2323
HETA_APPLICATION_ID,
2424
HETA_APPLICATION_VERSION,
25-
SPOT_0_EXPECTED_RESULT_FILES,
25+
HETA_EXPECTED_RESULT_FILES,
2626
SPOT_0_FILENAME,
2727
SPOT_0_FILESIZE,
2828
SPOT_0_GS_URL,
@@ -142,7 +142,7 @@ async def test_gui_qupath_install_and_launch( # noqa: PLR0913, PLR0917
142142
)
143143
@pytest.mark.timeout(timeout=60 * 15)
144144
@pytest.mark.sequential
145-
async def test_gui_run_qupath_install_to_inspect( # noqa: C901, PLR0912, PLR0913, PLR0915, PLR0917
145+
async def test_gui_run_qupath_install_to_inspect( # noqa: PLR0913, PLR0915, PLR0917
146146
user: User,
147147
runner: CliRunner,
148148
tmp_path: Path,
@@ -255,34 +255,12 @@ async def test_gui_run_qupath_install_to_inspect( # noqa: C901, PLR0912, PLR091
255255
)
256256

257257
# Check for files in the results directory
258-
files_in_results_dir = list(results_dir.glob("*"))
259-
expected_count = len(SPOT_0_EXPECTED_RESULT_FILES)
260-
assert len(files_in_results_dir) == expected_count, (
261-
f"Expected {expected_count} files in {results_dir}, but found {len(files_in_results_dir)}: "
262-
f"{[f.name for f in files_in_results_dir]}"
258+
files_in_results_dir = {f.name for f in results_dir.glob("*")}
259+
assert files_in_results_dir == HETA_EXPECTED_RESULT_FILES, (
260+
f"Unexpected files in {results_dir}: missing {sorted(HETA_EXPECTED_RESULT_FILES - files_in_results_dir)}, "
261+
f"extra {sorted(files_in_results_dir - HETA_EXPECTED_RESULT_FILES)}"
263262
)
264263

265-
print(f"Found files in {results_dir}:")
266-
for filename, expected_size, tolerance_percent in SPOT_0_EXPECTED_RESULT_FILES:
267-
file_path = results_dir / filename
268-
if file_path.exists():
269-
actual_size = file_path.stat().st_size
270-
print(f" {filename}: {actual_size} bytes (expected: {expected_size} ±{tolerance_percent}%)")
271-
else:
272-
print(f" {filename}: NOT FOUND")
273-
for filename, expected_size, tolerance_percent in SPOT_0_EXPECTED_RESULT_FILES:
274-
file_path = results_dir / filename
275-
assert file_path.exists(), f"Expected file {filename} not found"
276-
if expected_size is None: # shortcut: sizes unset after he-tme bump, re-baseline
277-
continue
278-
actual_size = file_path.stat().st_size
279-
min_size = expected_size * (100 - tolerance_percent) // 100
280-
max_size = expected_size * (100 + tolerance_percent) // 100
281-
assert min_size <= actual_size <= max_size, (
282-
f"File size for {filename} ({actual_size} bytes) is outside allowed range "
283-
f"({min_size} to {max_size} bytes, ±{tolerance_percent}% of {expected_size})"
284-
)
285-
286264
# Check QuPath is running
287265
notification = await assert_notified(user, "QuPath opened successfully", 30)
288266
pid_match = re.search(r"process id '(\d+)'", notification)

‎tests/constants_test.py‎

Lines changed: 17 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -62,52 +62,27 @@
6262
SPOT_4_WIDTH = 3728
6363
SPOT_4_HEIGHT = 3640
6464

65-
# To update file sizes: the tests print every file's actual size before asserting. Run with
66-
# -s to see them, then paste the printed byte values as the second element of each tuple.
67-
# Both are e2e tests and skip silently without their marker:
65+
# Output files of one he-tme item. The e2e tests check names only, not sizes:
6866
# SPOT_0: uv run pytest tests/aignostics/application/gui_test.py::test_gui_run_download \
6967
# -m "e2e and long_running" -s --no-cov
7068
# SPOT_1: uv run pytest tests/aignostics/application/cli_test.py::test_cli_run_execute \
7169
# -m "e2e and very_long_running" -s --no-cov
72-
#
73-
# These defaults reflect the production he-tme run. If staging produces different output (e.g.
74-
# after deploying a new application version to staging before production), add an override inside
75-
# the "staging" case below — only the constants that actually differ need to be reassigned.
76-
# Note: defined here rather than inside each match arm to avoid SonarCloud flagging the
77-
# nearly-identical blocks as duplicated code (the 3% duplication threshold).
78-
SPOT_0_EXPECTED_RESULT_FILES: list[tuple[str, int | None, int]] = [
79-
("tissue_qc_geojson_polygons.json", None, 10),
80-
("tissue_qc_parquet_polygons.parquet", None, 10),
81-
("tissue_qc_segmentation_map_image.tiff", None, 10),
82-
("tissue_segmentation_geojson_polygons.json", None, 10),
83-
("tissue_segmentation_parquet_polygons.parquet", None, 10),
84-
("tissue_segmentation_segmentation_map_image.tiff", None, 10),
85-
("cell_classification_geojson_polygons.json", None, 10),
86-
("cell_classification_parquet_polygons.parquet", None, 10),
87-
("whole_tumor_region_geojson_polygons.json", None, 10),
88-
("whole_tumor_region_parquet_polygons.parquet", None, 10),
89-
("tumor_cellularity_geojson_polygons.json", None, 10),
90-
("tumor_cellularity_parquet_polygons.parquet", None, 10),
91-
("tertiary_lymphoid_structure_parquet_polygons.parquet", None, 10),
92-
("readout_generation_readouts_bundle.zip", None, 10),
93-
]
94-
95-
SPOT_1_EXPECTED_RESULT_FILES: list[tuple[str, int | None, int]] = [
96-
("tissue_qc_geojson_polygons.json", None, 10),
97-
("tissue_qc_parquet_polygons.parquet", None, 10),
98-
("tissue_qc_segmentation_map_image.tiff", None, 10),
99-
("tissue_segmentation_geojson_polygons.json", None, 10),
100-
("tissue_segmentation_parquet_polygons.parquet", None, 10),
101-
("tissue_segmentation_segmentation_map_image.tiff", None, 10),
102-
("cell_classification_geojson_polygons.json", None, 10),
103-
("cell_classification_parquet_polygons.parquet", None, 10),
104-
("whole_tumor_region_geojson_polygons.json", None, 10),
105-
("whole_tumor_region_parquet_polygons.parquet", None, 10),
106-
("tumor_cellularity_geojson_polygons.json", None, 10),
107-
("tumor_cellularity_parquet_polygons.parquet", None, 10),
108-
("tertiary_lymphoid_structure_parquet_polygons.parquet", None, 10),
109-
("readout_generation_readouts_bundle.zip", None, 10),
110-
]
70+
HETA_EXPECTED_RESULT_FILES = {
71+
"tissue_qc_geojson_polygons.json",
72+
"tissue_qc_parquet_polygons.parquet",
73+
"tissue_qc_segmentation_map_image.tiff",
74+
"tissue_segmentation_geojson_polygons.json",
75+
"tissue_segmentation_parquet_polygons.parquet",
76+
"tissue_segmentation_segmentation_map_image.tiff",
77+
"cell_classification_geojson_polygons.json",
78+
"cell_classification_parquet_polygons.parquet",
79+
"whole_tumor_region_geojson_polygons.json",
80+
"whole_tumor_region_parquet_polygons.parquet",
81+
"tumor_cellularity_geojson_polygons.json",
82+
"tumor_cellularity_parquet_polygons.parquet",
83+
"tertiary_lymphoid_structure_parquet_polygons.parquet",
84+
"readout_generation_readouts_bundle.zip",
85+
}
11186

11287
match os.getenv("AIGNOSTICS_PLATFORM_ENVIRONMENT", "production"):
11388
case "production":
@@ -140,10 +115,6 @@
140115
PIPELINE_CPU_PROVISIONING_MODE = "SPOT"
141116
PIPELINE_NODE_ACQUISITION_TIMEOUT_MINUTES = 25
142117

143-
# If staging outputs differ from the defaults above, override them here, e.g.:
144-
# SPOT_0_EXPECTED_RESULT_FILES = [("tissue_qc_segmentation_map_image.tiff", <bytes>, 10), ...]
145-
# SPOT_1_EXPECTED_RESULT_FILES = [("tissue_qc_segmentation_map_image.tiff", <bytes>, 10), ...]
146-
147118
case _:
148119
message = f"Unsupported AIGNOSTICS_PLATFORM_ENVIRONMENT value: {os.getenv('AIGNOSTICS_PLATFORM_ENVIRONMENT')}"
149120
raise ValueError(message)

0 commit comments

Comments
 (0)