File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments