Spaces:
Running
Running
""" | |
File: event_handlers.py | |
Author: Elena Ryumina and Dmitry Ryumin | |
Description: File containing functions for configuring event handlers for Gradio components. | |
License: MIT License | |
""" | |
import gradio as gr | |
# Importing necessary components for the Gradio app | |
from app.event_handlers.languages import event_handler_languages | |
from app.event_handlers.switching_modes import event_handler_switching_modes | |
from app.event_handlers.files import ( | |
event_handler_files, | |
event_handler_files_select, | |
event_handler_files_delete, | |
) | |
from app.event_handlers.webcam import event_handler_webcam | |
from app.event_handlers.examples_blocks import event_handler_examples_blocks | |
from app.event_handlers.clear_blocks import event_handler_clear_blocks | |
from app.event_handlers.calculate_pt_scores_blocks import ( | |
event_handler_calculate_pt_scores_blocks, | |
) | |
from app.event_handlers.practical_tasks import event_handler_practical_tasks | |
from app.event_handlers.practical_subtasks import event_handler_practical_subtasks | |
from app.event_handlers.dropdown_candidates import event_handler_dropdown_candidates | |
from app.event_handlers.calculate_practical_tasks import ( | |
event_handler_calculate_practical_task_blocks, | |
) | |
from app.event_handlers.practical_task_sorted import event_handler_practical_task_sorted | |
def setup_app_event_handlers( | |
description, | |
step_1, | |
notifications, | |
files, | |
webcam, | |
switching_modes, | |
type_modes, | |
video, | |
examples, | |
calculate_pt_scores, | |
clear_app, | |
pt_scores, | |
csv_pt_scores, | |
step_2, | |
practical_tasks, | |
practical_subtasks, | |
settings_practical_tasks, | |
dropdown_mbti, | |
threshold_mbti, | |
threshold_professional_skills, | |
dropdown_professional_skills, | |
target_score_ope, | |
target_score_con, | |
target_score_ext, | |
target_score_agr, | |
target_score_nneu, | |
equal_coefficient, | |
number_priority, | |
number_importance_traits, | |
threshold_consumer_preferences, | |
dropdown_candidates, | |
number_openness, | |
number_conscientiousness, | |
number_extraversion, | |
number_agreeableness, | |
number_non_neuroticism, | |
calculate_practical_task, | |
practical_subtasks_selected, | |
practical_tasks_column, | |
sorted_videos, | |
sorted_videos_column, | |
practical_task_sorted, | |
csv_practical_task_sorted, | |
mbti_accordion, | |
mbti_description, | |
mbti_description_data, | |
video_sorted_column, | |
video_sorted, | |
metadata, | |
metadata_1, | |
name_row, | |
name_logo, | |
name, | |
surname_row, | |
surname_logo, | |
surname, | |
metadata_2, | |
email_row, | |
email_logo, | |
email, | |
phone_row, | |
phone_logo, | |
phone, | |
in_development, | |
tab1, | |
tab2, | |
tab3, | |
tab4, | |
languages_row, | |
country_flags, | |
languages, | |
): | |
# Events | |
languages.select( | |
fn=event_handler_languages, | |
inputs=[ | |
languages, | |
files, | |
video, | |
type_modes, | |
pt_scores, | |
csv_pt_scores, | |
practical_tasks, | |
practical_subtasks, | |
], | |
outputs=[ | |
description, | |
step_1, | |
country_flags, | |
languages, | |
tab1, | |
tab2, | |
tab3, | |
tab4, | |
files, | |
webcam, | |
switching_modes, | |
video, | |
examples, | |
calculate_pt_scores, | |
clear_app, | |
notifications, | |
pt_scores, | |
csv_pt_scores, | |
step_2, | |
practical_tasks_column, | |
practical_tasks, | |
practical_subtasks, | |
], | |
queue=True, | |
) | |
switching_modes.click( | |
fn=event_handler_switching_modes, | |
inputs=[languages, type_modes], | |
outputs=[ | |
notifications, | |
files, | |
webcam, | |
switching_modes, | |
type_modes, | |
video, | |
calculate_pt_scores, | |
clear_app, | |
pt_scores, | |
csv_pt_scores, | |
step_2, | |
practical_tasks_column, | |
practical_tasks, | |
practical_subtasks, | |
practical_subtasks_selected, | |
settings_practical_tasks, | |
dropdown_mbti, | |
threshold_mbti, | |
threshold_professional_skills, | |
dropdown_professional_skills, | |
target_score_ope, | |
target_score_con, | |
target_score_ext, | |
target_score_agr, | |
target_score_nneu, | |
equal_coefficient, | |
number_priority, | |
number_importance_traits, | |
threshold_consumer_preferences, | |
dropdown_candidates, | |
number_openness, | |
number_conscientiousness, | |
number_extraversion, | |
number_agreeableness, | |
number_non_neuroticism, | |
sorted_videos, | |
sorted_videos_column, | |
practical_task_sorted, | |
csv_practical_task_sorted, | |
mbti_accordion, | |
mbti_description, | |
mbti_description_data, | |
video_sorted_column, | |
video_sorted, | |
metadata, | |
metadata_1, | |
name_row, | |
name_logo, | |
name, | |
surname_row, | |
surname_logo, | |
surname, | |
metadata_2, | |
email_row, | |
email_logo, | |
email, | |
phone_row, | |
phone_logo, | |
phone, | |
in_development, | |
], | |
queue=True, | |
) | |
files.change( | |
event_handler_files, | |
[languages, files, video, pt_scores], | |
[notifications, video, calculate_pt_scores, clear_app], | |
queue=True, | |
) | |
files.select( | |
event_handler_files_select, | |
[languages, files], | |
[video], | |
queue=True, | |
) | |
files.delete( | |
event_handler_files_delete, | |
[languages, files, video], | |
[video], | |
queue=True, | |
) | |
gr.on( | |
triggers=[webcam.upload, webcam.stop_recording], | |
fn=event_handler_webcam, | |
inputs=[languages, webcam, pt_scores], | |
outputs=[notifications, video, webcam, calculate_pt_scores, clear_app], | |
queue=True, | |
) | |
gr.on( | |
triggers=[calculate_pt_scores.click], | |
fn=event_handler_calculate_pt_scores_blocks, | |
inputs=[languages, type_modes, files, video], | |
outputs=[ | |
notifications, | |
pt_scores, | |
csv_pt_scores, | |
step_2, | |
practical_tasks_column, | |
practical_tasks, | |
practical_subtasks, | |
practical_subtasks_selected, | |
settings_practical_tasks, | |
dropdown_mbti, | |
threshold_mbti, | |
threshold_professional_skills, | |
dropdown_professional_skills, | |
target_score_ope, | |
target_score_con, | |
target_score_ext, | |
target_score_agr, | |
target_score_nneu, | |
equal_coefficient, | |
number_priority, | |
number_importance_traits, | |
threshold_consumer_preferences, | |
dropdown_candidates, | |
number_openness, | |
number_conscientiousness, | |
number_extraversion, | |
number_agreeableness, | |
number_non_neuroticism, | |
calculate_practical_task, | |
sorted_videos, | |
sorted_videos_column, | |
practical_task_sorted, | |
csv_practical_task_sorted, | |
mbti_accordion, | |
mbti_description, | |
mbti_description_data, | |
video_sorted_column, | |
video_sorted, | |
metadata, | |
metadata_1, | |
name_row, | |
name_logo, | |
name, | |
surname_row, | |
surname_logo, | |
surname, | |
metadata_2, | |
email_row, | |
email_logo, | |
email, | |
phone_row, | |
phone_logo, | |
phone, | |
in_development, | |
], | |
queue=True, | |
) | |
examples.click( | |
fn=event_handler_examples_blocks, | |
inputs=[languages], | |
outputs=[ | |
notifications, | |
files, | |
webcam, | |
switching_modes, | |
type_modes, | |
video, | |
calculate_pt_scores, | |
clear_app, | |
pt_scores, | |
csv_pt_scores, | |
step_2, | |
practical_tasks_column, | |
practical_tasks, | |
practical_subtasks, | |
practical_subtasks_selected, | |
settings_practical_tasks, | |
dropdown_mbti, | |
threshold_mbti, | |
threshold_professional_skills, | |
dropdown_professional_skills, | |
target_score_ope, | |
target_score_con, | |
target_score_ext, | |
target_score_agr, | |
target_score_nneu, | |
equal_coefficient, | |
number_priority, | |
number_importance_traits, | |
threshold_consumer_preferences, | |
dropdown_candidates, | |
number_openness, | |
number_conscientiousness, | |
number_extraversion, | |
number_agreeableness, | |
number_non_neuroticism, | |
sorted_videos, | |
sorted_videos_column, | |
practical_task_sorted, | |
csv_practical_task_sorted, | |
mbti_accordion, | |
mbti_description, | |
mbti_description_data, | |
video_sorted_column, | |
video_sorted, | |
metadata, | |
metadata_1, | |
name_row, | |
name_logo, | |
name, | |
surname_row, | |
surname_logo, | |
surname, | |
metadata_2, | |
email_row, | |
email_logo, | |
email, | |
phone_row, | |
phone_logo, | |
phone, | |
in_development, | |
], | |
queue=True, | |
) | |
clear_app.click( | |
fn=event_handler_clear_blocks, | |
inputs=[languages, type_modes], | |
outputs=[ | |
notifications, | |
files, | |
webcam, | |
video, | |
calculate_pt_scores, | |
clear_app, | |
pt_scores, | |
csv_pt_scores, | |
step_2, | |
practical_tasks_column, | |
practical_tasks, | |
practical_subtasks, | |
practical_subtasks_selected, | |
settings_practical_tasks, | |
dropdown_mbti, | |
threshold_mbti, | |
threshold_professional_skills, | |
dropdown_professional_skills, | |
target_score_ope, | |
target_score_con, | |
target_score_ext, | |
target_score_agr, | |
target_score_nneu, | |
equal_coefficient, | |
number_priority, | |
number_importance_traits, | |
threshold_consumer_preferences, | |
dropdown_candidates, | |
number_openness, | |
number_conscientiousness, | |
number_extraversion, | |
number_agreeableness, | |
number_non_neuroticism, | |
sorted_videos, | |
sorted_videos_column, | |
practical_task_sorted, | |
csv_practical_task_sorted, | |
mbti_accordion, | |
mbti_description, | |
mbti_description_data, | |
video_sorted_column, | |
video_sorted, | |
metadata, | |
metadata_1, | |
name_row, | |
name_logo, | |
name, | |
surname_row, | |
surname_logo, | |
surname, | |
metadata_2, | |
email_row, | |
email_logo, | |
email, | |
phone_row, | |
phone_logo, | |
phone, | |
in_development, | |
], | |
queue=True, | |
) | |
practical_tasks.change( | |
event_handler_practical_tasks, | |
[languages, type_modes, practical_tasks, practical_subtasks_selected], | |
[practical_subtasks], | |
queue=True, | |
) | |
practical_subtasks.change( | |
event_handler_practical_subtasks, | |
[ | |
languages, | |
type_modes, | |
practical_tasks, | |
practical_subtasks, | |
practical_subtasks_selected, | |
], | |
[ | |
practical_subtasks_selected, | |
settings_practical_tasks, | |
dropdown_mbti, | |
threshold_mbti, | |
threshold_professional_skills, | |
dropdown_professional_skills, | |
target_score_ope, | |
target_score_con, | |
target_score_ext, | |
target_score_agr, | |
target_score_nneu, | |
equal_coefficient, | |
number_priority, | |
number_importance_traits, | |
threshold_consumer_preferences, | |
dropdown_candidates, | |
number_openness, | |
number_conscientiousness, | |
number_extraversion, | |
number_agreeableness, | |
number_non_neuroticism, | |
], | |
queue=True, | |
) | |
dropdown_candidates.change( | |
fn=event_handler_dropdown_candidates, | |
inputs=[practical_subtasks, dropdown_candidates], | |
outputs=[ | |
number_openness, | |
number_conscientiousness, | |
number_extraversion, | |
number_agreeableness, | |
number_non_neuroticism, | |
], | |
queue=True, | |
) | |
calculate_practical_task.click( | |
fn=event_handler_calculate_practical_task_blocks, | |
inputs=[ | |
languages, | |
type_modes, | |
files, | |
video, | |
practical_subtasks, | |
pt_scores, | |
dropdown_mbti, | |
threshold_mbti, | |
threshold_professional_skills, | |
dropdown_professional_skills, | |
target_score_ope, | |
target_score_con, | |
target_score_ext, | |
target_score_agr, | |
target_score_nneu, | |
equal_coefficient, | |
number_priority, | |
number_importance_traits, | |
threshold_consumer_preferences, | |
number_openness, | |
number_conscientiousness, | |
number_extraversion, | |
number_agreeableness, | |
number_non_neuroticism, | |
], | |
outputs=[ | |
sorted_videos, | |
sorted_videos_column, | |
practical_task_sorted, | |
csv_practical_task_sorted, | |
mbti_accordion, | |
mbti_description, | |
mbti_description_data, | |
video_sorted_column, | |
video_sorted, | |
metadata, | |
metadata_1, | |
name_row, | |
name_logo, | |
name, | |
surname_row, | |
surname_logo, | |
surname, | |
metadata_2, | |
email_row, | |
email_logo, | |
email, | |
phone_row, | |
phone_logo, | |
phone, | |
in_development, | |
], | |
queue=True, | |
) | |
practical_task_sorted.select( | |
event_handler_practical_task_sorted, | |
[type_modes, files, video, practical_task_sorted], | |
[ | |
video_sorted_column, | |
video_sorted, | |
metadata, | |
metadata_1, | |
name_row, | |
name_logo, | |
name, | |
surname_row, | |
surname_logo, | |
surname, | |
metadata_2, | |
email_row, | |
email_logo, | |
email, | |
phone_row, | |
phone_logo, | |
phone, | |
], | |
queue=True, | |
) | |