OCEANAI / app /event_handlers /dropdown_candidates.py
ElenaRyumina's picture
v0.7.0 (#7)
c0f084a verified
raw
history blame
4.31 kB
"""
File: dropdown_candidates.py
Author: Elena Ryumina and Dmitry Ryumin
Description: Event handler for Gradio app to filter dropdown candidates based on selected dropdown candidates.
License: MIT License
"""
# Importing necessary components for the Gradio app
from app.config import config_data
from app.utils import read_csv_file, extract_profession_weights
from app.components import number_create_ui, dropdown_create_ui
def event_handler_dropdown_candidates(practical_subtasks, dropdown_candidates):
if practical_subtasks.lower() == "professional groups":
df_traits_priority_for_professions = read_csv_file(
config_data.Links_PROFESSIONS
)
weights, interactive = extract_profession_weights(
df_traits_priority_for_professions,
dropdown_candidates,
)
return (
number_create_ui(
value=weights[0],
minimum=config_data.Values_0_100[0],
maximum=config_data.Values_0_100[1],
step=1,
label=config_data.Labels_NUMBER_IMPORTANCE_OPE_LABEL,
info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(
config_data.Values_0_100[0], config_data.Values_0_100[1]
),
show_label=True,
interactive=interactive,
visible=True,
render=True,
elem_classes="number-container",
),
number_create_ui(
value=weights[1],
minimum=config_data.Values_0_100[0],
maximum=config_data.Values_0_100[1],
step=1,
label=config_data.Labels_NUMBER_IMPORTANCE_CON_LABEL,
info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(
config_data.Values_0_100[0], config_data.Values_0_100[1]
),
show_label=True,
interactive=interactive,
visible=True,
render=True,
elem_classes="number-container",
),
number_create_ui(
value=weights[2],
minimum=config_data.Values_0_100[0],
maximum=config_data.Values_0_100[1],
step=1,
label=config_data.Labels_NUMBER_IMPORTANCE_EXT_LABEL,
info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(
config_data.Values_0_100[0], config_data.Values_0_100[1]
),
show_label=True,
interactive=interactive,
visible=True,
render=True,
elem_classes="number-container",
),
number_create_ui(
value=weights[3],
minimum=config_data.Values_0_100[0],
maximum=config_data.Values_0_100[1],
step=1,
label=config_data.Labels_NUMBER_IMPORTANCE_AGR_LABEL,
info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(
config_data.Values_0_100[0], config_data.Values_0_100[1]
),
show_label=True,
interactive=interactive,
visible=True,
render=True,
elem_classes="number-container",
),
number_create_ui(
value=weights[4],
minimum=config_data.Values_0_100[0],
maximum=config_data.Values_0_100[1],
step=1,
label=config_data.Labels_NUMBER_IMPORTANCE_NNEU_LABEL,
info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(
config_data.Values_0_100[0], config_data.Values_0_100[1]
),
show_label=True,
interactive=interactive,
visible=True,
render=True,
elem_classes="number-container",
),
)
else:
return (
number_create_ui(visible=False),
number_create_ui(visible=False),
number_create_ui(visible=False),
number_create_ui(visible=False),
number_create_ui(visible=False),
)