Skip to content

Commit 6c618db

Browse files
author
Robertson
committed
Merge branch 'main' into feature/e2e-func-tests
2 parents a97bb0e + 725820f commit 6c618db

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

docs/api/client.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ Basic Classification
152152
153153
async for result in results:
154154
for output in result.outputs:
155+
# Manually map classifications, as the generated grpc
156+
# implementation for __str__ will ignore weights of 0.0,
157+
# which are common, especially for binary classifications
158+
# such as hash checks
155159
classifications = {
156160
c.label: c.weight
157161
for c in output.classifications
@@ -274,3 +278,5 @@ Notes
274278
* Enable compression for bandwidth-constrained environments
275279
* Configure appropriate timeouts for your use case
276280
* See :doc:`options` for detailed configuration options
281+
* Carefully handle any logging of classification results, as decribed in the
282+
basic classification example above, to avoid losing important information

tests/functional/test_classify_single.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,14 @@ async def test_classify_single(
3636
if result.error.code:
3737
msg = f"Image Result Error: {result.error.message}"
3838
pytest.fail(msg)
39+
40+
hash_checks = [
41+
classification
42+
for classification in result.classifications
43+
if "hash" in classification.label.lower()
44+
]
45+
46+
assert len(hash_checks) > 0, "No hash checks found in classifications"
47+
48+
for hash_check in hash_checks:
49+
assert hash_check.weight == 0.0

0 commit comments

Comments
 (0)