Skip to content

Commit bd2d3c4

Browse files
test: Improve e2e functional tests for classify_single
Better Logging, Enhanced Error Handling, and Updated Expected Outputs
1 parent 8524807 commit bd2d3c4

4 files changed

Lines changed: 16 additions & 18 deletions

File tree

examples/classify_single_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ async def main() -> int:
229229
resize_images=True,
230230
compress_images=True,
231231
timeout=30.0, # Shorter timeout for single requests
232-
affiliate="Crisp",
232+
affiliate=os.getenv("ATHENA_AFFILIATE", "athena-test"),
233233
deployment_id="single-example-deployment", # Not used
234234
)
235235

src/resolver_athena_client/client/transformers/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def process_image() -> tuple[bytes, bool]:
5050
# Resize if needed
5151
if rgb_image.size != _target_size:
5252
resized_image = rgb_image.resize(
53-
_target_size, Image.Resampling.LANCZOS
53+
_target_size, Image.Resampling.BILINEAR
5454
)
5555
else:
5656
resized_image = rgb_image

tests/functional/e2e/test_classify_single.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
load_test_cases,
1515
)
1616

17-
TEST_CASES = load_test_cases("live_model")
17+
TEST_CASES = load_test_cases("benign_model")
1818

1919
FP_ERROR_TOLERANCE = 1e-4
2020

@@ -59,12 +59,10 @@ async def test_classify_single(
5959
)
6060
actual_output = {k: actual_output[k] for k in test_case.expected_output}
6161

62-
max_diff = max(
63-
abs(test_case.expected_output[label] - actual_output[label])
64-
for label in test_case.expected_output
65-
)
66-
assert max_diff < FP_ERROR_TOLERANCE, (
67-
"Output weights differ from expected by more than",
68-
f" {FP_ERROR_TOLERANCE}: ",
69-
f"expected={test_case.expected_output}, actual={actual_output}",
70-
)
62+
for label in test_case.expected_output:
63+
expected = test_case.expected_output[label]
64+
actual = actual_output[label]
65+
assert abs(expected - actual) < FP_ERROR_TOLERANCE, (
66+
f"Weight for label '{label}' differs by more than {FP_ERROR_TOLERANCE}: "
67+
f"expected={expected}, actual={actual}, diff={abs(expected - actual)}"
68+
)

tests/functional/e2e/testcases/benign_model/expected_outputs.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"classification_labels": [
3-
"Lakeside",
4-
"Mountains",
5-
"Trees",
6-
"Seashore",
7-
"Ducks",
8-
"Goose"
3+
"UnknownCSAM-Lakeside",
4+
"UnknownCSAM-Mountains",
5+
"UnknownCSAM-Trees",
6+
"UnknownCSAM-Seashore",
7+
"UnknownCSAM-Ducks",
8+
"UnknownCSAM-Goose"
99
],
1010
"images": [
1111
[

0 commit comments

Comments
 (0)