flake8 compliant
This commit is contained in:
+20
-8
@@ -20,15 +20,17 @@ def total_annotated(
|
||||
) -> int:
|
||||
"""Get total number of annotated documents in database."""
|
||||
query = {
|
||||
"annotation": { "$ne": None }
|
||||
"annotation": {
|
||||
"$ne": None
|
||||
}
|
||||
}
|
||||
return collection.count_documents(filter=query)
|
||||
|
||||
|
||||
def get_visual_communication(
|
||||
collection: Collection,
|
||||
with_annotation: bool = False
|
||||
) -> VisualCommunication:
|
||||
collection: Collection,
|
||||
with_annotation: bool = False
|
||||
) -> VisualCommunication:
|
||||
"""Get a random visual communication from the database."""
|
||||
query = {}
|
||||
if with_annotation:
|
||||
@@ -36,8 +38,14 @@ def get_visual_communication(
|
||||
else:
|
||||
query["annotation"] = None
|
||||
data = collection.aggregate([
|
||||
{ "$match": query }, # find using filters
|
||||
{ "$sample": { "size": 1 } } # get one random
|
||||
{
|
||||
"$match": query # find using filters
|
||||
},
|
||||
{
|
||||
"$sample": {
|
||||
"size": 1 # get one random
|
||||
}
|
||||
}
|
||||
])
|
||||
data = list(data) # read data from cursor object
|
||||
if len(data) == 0:
|
||||
@@ -58,7 +66,9 @@ def upsert_predictions(
|
||||
"name": vis_com_name
|
||||
}
|
||||
update = {
|
||||
"$set": { "prediction": predictions.model_dump() }
|
||||
"$set": {
|
||||
"prediction": predictions.model_dump()
|
||||
}
|
||||
}
|
||||
res = collection.update_one(
|
||||
filter=query,
|
||||
@@ -79,7 +89,9 @@ def upsert_annotations(
|
||||
"name": vis_com_name
|
||||
}
|
||||
update = {
|
||||
"$set": { "annotation": annotations.model_dump() }
|
||||
"$set": {
|
||||
"annotation": annotations.model_dump()
|
||||
}
|
||||
}
|
||||
res = collection.update_one(
|
||||
filter=query,
|
||||
|
||||
Reference in New Issue
Block a user