flake8 compliant
This commit is contained in:
+7
-5
@@ -30,6 +30,7 @@ BasicAuth(app, AUTH_DICT)
|
||||
# connect to database
|
||||
collection, db, client = connect()
|
||||
|
||||
|
||||
# define callbacks
|
||||
@app.callback(
|
||||
Output("alert-element", "is_open"),
|
||||
@@ -44,6 +45,7 @@ def show_alert(
|
||||
logging.info(f"updated alert message: {msg}")
|
||||
return True, msg
|
||||
|
||||
|
||||
@app.callback(
|
||||
Output("alert-message", "data"),
|
||||
Output("vis-com-name", "data"),
|
||||
@@ -73,7 +75,7 @@ def cycle_visual_communication_data(
|
||||
annotation_values
|
||||
]
|
||||
# check if next-button clicked
|
||||
if n_clicks == 0:
|
||||
if n_clicks == 0:
|
||||
logging.info("stopping early: next-button has not yet been clicked")
|
||||
return response
|
||||
# check if visual communication name is set
|
||||
@@ -102,13 +104,13 @@ def cycle_visual_communication_data(
|
||||
in annotation_values
|
||||
]
|
||||
annotations = {
|
||||
key: value
|
||||
for key, value
|
||||
key: value
|
||||
for key, value
|
||||
in zip(annotation_keys, annotation_values)
|
||||
}
|
||||
# instantiate ModelOutputs object
|
||||
annotations = ModelOutputs.from_annotations(**annotations)
|
||||
# save data to
|
||||
# save data to database
|
||||
upsert_annotations(
|
||||
collection=collection,
|
||||
vis_com_name=vis_com_name,
|
||||
@@ -137,7 +139,7 @@ def cycle_visual_communication_data(
|
||||
# reset annotations
|
||||
annotation_values = [None for elem in annotation_values]
|
||||
except NoDocumentFoundException:
|
||||
msg = f"no unannotated data in database"
|
||||
msg = "no unannotated data in database"
|
||||
logging.warning(msg)
|
||||
response[0] = msg
|
||||
return tuple(response)
|
||||
|
||||
@@ -1 +1 @@
|
||||
from .layout import app_layout
|
||||
from .layout import app_layout
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from dash import html, dcc
|
||||
from dash import html
|
||||
import dash_bootstrap_components as dbc
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import dash_mantine_components as dmc
|
||||
from dash import dcc, html
|
||||
from typing import List
|
||||
|
||||
from .image import image_element
|
||||
from .inputs import inputs_element
|
||||
@@ -17,4 +15,4 @@ body_element = dmc.Container(
|
||||
],
|
||||
)
|
||||
],
|
||||
)
|
||||
)
|
||||
|
||||
@@ -20,4 +20,4 @@ inputs_element = dmc.SimpleGrid(
|
||||
labels_element,
|
||||
next_button
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
@@ -20,6 +20,7 @@ from src.model_textual import (
|
||||
SalienceModelOutput
|
||||
)
|
||||
|
||||
|
||||
def generate_option_labels(model) -> List[str]:
|
||||
"""Generate presentable list of attributes from an OutputModel."""
|
||||
labels = [
|
||||
@@ -28,35 +29,51 @@ def generate_option_labels(model) -> List[str]:
|
||||
]
|
||||
return labels
|
||||
|
||||
|
||||
def generate_visual_syntax_options_map():
|
||||
"""Generate map of titles and options for visual syntax labels."""
|
||||
options_map = {}
|
||||
# add experiential labels
|
||||
options_map["visual syntax"] = generate_option_labels(VisualSyntaxModelOutput)
|
||||
options_map["visual syntax"] = generate_option_labels(
|
||||
VisualSyntaxModelOutput
|
||||
)
|
||||
return options_map
|
||||
|
||||
|
||||
def generate_interpersonal_options_map():
|
||||
"""Generate map of titles and options for interpersonal labels."""
|
||||
options_map = {}
|
||||
# add interpersonal labels
|
||||
options_map["contact"] = generate_option_labels(ContactModelOutput)
|
||||
options_map["angle"] = generate_option_labels(AngleModelOutput)
|
||||
options_map["point of view"] = generate_option_labels(PointOfViewModelOutput)
|
||||
options_map["point of view"] = generate_option_labels(
|
||||
PointOfViewModelOutput
|
||||
)
|
||||
options_map["distance"] = generate_option_labels(DistanceModelOutput)
|
||||
options_map["modality lighting"] = generate_option_labels(ModalityLightingModelOutput)
|
||||
options_map["modality color"] = generate_option_labels(ModalityColorModelOutput)
|
||||
options_map["modality depth"] = generate_option_labels(ModalityDepthModelOutput)
|
||||
options_map["modality lighting"] = generate_option_labels(
|
||||
ModalityLightingModelOutput
|
||||
)
|
||||
options_map["modality color"] = generate_option_labels(
|
||||
ModalityColorModelOutput
|
||||
)
|
||||
options_map["modality depth"] = generate_option_labels(
|
||||
ModalityDepthModelOutput
|
||||
)
|
||||
return options_map
|
||||
|
||||
|
||||
def generate_textual_options_map():
|
||||
"""Generate map of titles and options for textual labels."""
|
||||
options_map = {}
|
||||
# add textual labels
|
||||
options_map["information value"] = generate_option_labels(InformationValueModelOutput)
|
||||
options_map["information value"] = generate_option_labels(
|
||||
InformationValueModelOutput
|
||||
)
|
||||
options_map["framing"] = generate_option_labels(FramingModelOutput)
|
||||
options_map["salience"] = generate_option_labels(SalienceModelOutput)
|
||||
return options_map
|
||||
|
||||
|
||||
# prepare experiential container
|
||||
experiential_map = generate_visual_syntax_options_map()
|
||||
experiential_container = dmc.Col(
|
||||
@@ -118,4 +135,4 @@ labels_element = dmc.Grid(
|
||||
interpersonal_container,
|
||||
textual_container,
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
from dash import dcc
|
||||
import dash_mantine_components as dmc
|
||||
|
||||
from .stores import stores_element
|
||||
|
||||
@@ -5,12 +5,14 @@ import os
|
||||
storage_type = "session"
|
||||
if "ENV" in os.environ and os.getenv("ENV") == "DEV":
|
||||
storage_type = "memory"
|
||||
logging.info(f"ENV=DEV -> dcc.Stores changed to storage_type={storage_type}")
|
||||
|
||||
logging.info(
|
||||
"ENV=DEV -> dcc.Stores changed to storage_type=%s",
|
||||
storage_type
|
||||
)
|
||||
|
||||
stores_element = html.Div(
|
||||
children=[
|
||||
dcc.Store(id="alert-message", storage_type=storage_type, data=""),
|
||||
dcc.Store(id="vis-com-name", storage_type=storage_type, data=""),
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user