Cogniac / cogniac-sdk-py

Python SDK for Cogniac Public API
Apache License 2.0
5 stars 6 forks source link

subject.media_associations(consensus=None) returns some media that is consensus=True #109

Closed bonniegordon closed 3 years ago

bonniegordon commented 3 years ago

When I am searching for subject.media_associations(consensus=None) I am being returned results which are currently consensus = True as well as none.

here's the subject: https://cogniac.co/app/tenants/pdco1qkm6c4f/subjects/shoulder_separation_6wg/media?feedback=false&probabilityLower=0.5&probabilityUpper=1&sort=time

My code is here and it returns a list of every single media in the subject yet there are 299 with consensus=True

import cogniac
import json
cc = cogniac
cc = cogniac.CogniacConnection(tenant_id="pdco1qkm6c4f")
defect_output_subject_uid = "shoulder_separation_6wg"
defect_output_subject = cc.get_subject(defect_output_subject_uid)
media_id_list =[k['media']['media_id'] for k in defect_output_subject.media_associations(consensus=None, abridged_media=True)]
sergii-bond commented 3 years ago

@bonniegordon Please try searching for consensus="None".

bonniegordon commented 3 years ago

This is the result with you search using "None" in quotes:

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-18-affa6c360c14> in <module>
----> 1 media_id_list =[k['media']['media_id'] for k in defect_output_subject.media_associations(consensus="None", abridged_media=True)]

<ipython-input-18-affa6c360c14> in <listcomp>(.0)
----> 1 media_id_list =[k['media']['media_id'] for k in defect_output_subject.media_associations(consensus="None", abridged_media=True)]

~/anaconda3/lib/python3.8/site-packages/cogniac/subject.py in media_associations(self, start, end, reverse, probability_lower, probability_upper, consensus, sort_probability, limit, abridged_media)
    470             args.append("probability_upper=%f" % probability_upper)
    471         if consensus is not None:
--> 472             assert(consensus in ['True', 'False'])
    473             args.append("consensus=%s" % consensus)
    474         if reverse:

AssertionError: 
sergii-bond commented 3 years ago

@bonniegordon thanks, here is the pull request, https://github.com/Cogniac/cogniac-sdk-py/pull/110. After it is approved, the new version shouldn't have this issue. In the meantime you can go to your ~/anaconda3/lib/python3.8/site-packages/cogniac/subject.py and change line 472 to include 'None' into the list.