Merge pull request 'add_progress_bar' (#22) from add_progress_bar into main
Reviewed-on: http://192.168.1.2:3000/brian/visual_critical_discourse_analysis/pulls/22
This commit was merged in pull request #22.
This commit is contained in:
@@ -17,6 +17,8 @@ from src.database import connect
|
|||||||
from src.database import get_visual_communication
|
from src.database import get_visual_communication
|
||||||
from src.database import ModelOutputs
|
from src.database import ModelOutputs
|
||||||
from src.database import NoDocumentFoundException
|
from src.database import NoDocumentFoundException
|
||||||
|
from src.database import total_annotated
|
||||||
|
from src.database import total_documents
|
||||||
from src.database import upsert_annotations
|
from src.database import upsert_annotations
|
||||||
from src.database import upsert_visual_communication
|
from src.database import upsert_visual_communication
|
||||||
from src.database import VisualCommunication
|
from src.database import VisualCommunication
|
||||||
@@ -66,6 +68,27 @@ def show_success(
|
|||||||
return True, msg
|
return True, msg
|
||||||
|
|
||||||
|
|
||||||
|
@app.callback(
|
||||||
|
Output('progress-bar', 'value'),
|
||||||
|
Output('progress-bar', 'max'),
|
||||||
|
Output('progress-bar', 'label'),
|
||||||
|
Input('next-button', 'n_clicks'),
|
||||||
|
Input('upload-data', 'filename'),
|
||||||
|
)
|
||||||
|
def update_progress_bar(
|
||||||
|
n_clicks: int,
|
||||||
|
filename_list: list[str] | None,
|
||||||
|
):
|
||||||
|
logging.info('began updating progress bar')
|
||||||
|
global collection
|
||||||
|
# get values from database
|
||||||
|
num_total = total_documents(collection=collection)
|
||||||
|
num_handled = total_annotated(collection=collection)
|
||||||
|
limit = int(num_total/20)
|
||||||
|
label_str = f"{num_handled}/{num_total}" if num_handled >= limit else ''
|
||||||
|
return num_handled, num_total, label_str
|
||||||
|
|
||||||
|
|
||||||
@app.callback(
|
@app.callback(
|
||||||
Output('success-message', 'data', allow_duplicate=True),
|
Output('success-message', 'data', allow_duplicate=True),
|
||||||
Output('alert-message', 'data', allow_duplicate=True),
|
Output('alert-message', 'data', allow_duplicate=True),
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import dash_bootstrap_components as dbc
|
||||||
import dash_mantine_components as dmc
|
import dash_mantine_components as dmc
|
||||||
from dash import dcc
|
from dash import dcc
|
||||||
from dash import html
|
from dash import html
|
||||||
@@ -14,6 +15,17 @@ title_element = dmc.Center(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
progress_bar_element = dbc.Progress(
|
||||||
|
id='progress-bar',
|
||||||
|
max=100,
|
||||||
|
value=0,
|
||||||
|
color='lime',
|
||||||
|
label='',
|
||||||
|
style={
|
||||||
|
'width': '400px',
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
upload_button_element = dcc.Upload(
|
upload_button_element = dcc.Upload(
|
||||||
children=[
|
children=[
|
||||||
dmc.Button(
|
dmc.Button(
|
||||||
@@ -37,6 +49,7 @@ header_element = dmc.Header(
|
|||||||
dmc.Group(
|
dmc.Group(
|
||||||
children=[
|
children=[
|
||||||
title_element,
|
title_element,
|
||||||
|
progress_bar_element,
|
||||||
upload_button_element,
|
upload_button_element,
|
||||||
],
|
],
|
||||||
position='apart',
|
position='apart',
|
||||||
|
|||||||
Reference in New Issue
Block a user