updated to use new data classes and bugfixes

This commit is contained in:
Brian Bjarke Jensen
2024-04-03 21:01:36 +02:00
parent 12d043b220
commit 1975b13151
+18 -13
View File
@@ -13,15 +13,14 @@ from dash_auth import BasicAuth
from pydantic import ValidationError from pydantic import ValidationError
from .layout import app_layout from .layout import app_layout
from src.database import connect from core.database import connect
from src.database import get_visual_communication from core.database import count_documents
from src.database import ModelOutputs from core.database import get_visual_communication
from src.database import NoDocumentFoundException from core.database import NoDocumentFoundException
from src.database import total_annotated from core.database import upsert_annotation
from src.database import total_documents from core.database import upsert_visual_communication
from src.database import upsert_annotations from core.database import VisualCommunication
from src.database import upsert_visual_communication from core.dto import ModelData
from src.database import VisualCommunication
# setup app # setup app
app = Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP]) app = Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])
@@ -82,8 +81,14 @@ def update_progress_bar(
logging.info('began updating progress bar') logging.info('began updating progress bar')
global collection global collection
# get values from database # get values from database
num_total = total_documents(collection=collection) num_total = count_documents(
num_handled = total_annotated(collection=collection) collection=collection,
only_with_annotation=False,
)
num_handled = count_documents(
collection=collection,
only_with_annotation=True,
)
limit = int(num_total/20) limit = int(num_total/20)
label_str = f"{num_handled}/{num_total}" if num_handled >= limit else '' label_str = f"{num_handled}/{num_total}" if num_handled >= limit else ''
return num_handled, num_total, label_str return num_handled, num_total, label_str
@@ -200,9 +205,9 @@ def cycle_visual_communication_data(
in zip(annotation_keys, annotation_values) in zip(annotation_keys, annotation_values)
} }
# instantiate ModelOutputs object # instantiate ModelOutputs object
annotations = ModelOutputs.from_annotations(**annotation_map) annotations = ModelData.from_annotations(**annotation_map)
# save data to database # save data to database
upsert_annotations( upsert_annotation(
collection=collection, collection=collection,
vis_com_name=vis_com_name, vis_com_name=vis_com_name,
annotations=annotations, annotations=annotations,