Spaces:
Running
Running
DmitryRyumin
commited on
Commit
•
98c66ee
1
Parent(s):
cd90a16
Summary
Browse files- app.css +4 -0
- app/components.py +9 -2
- app/event_handlers/calculate_practical_tasks.py +1 -1
- app/event_handlers/calculate_pt_scores_blocks.py +38 -16
- app/event_handlers/clear_blocks.py +6 -1
- app/event_handlers/event_handlers.py +1 -1
- app/event_handlers/examples_blocks.py +6 -1
- app/event_handlers/files.py +7 -1
- app/event_handlers/languages.py +5 -1
- app/event_handlers/practical_tasks.py +15 -2
- app/event_handlers/switching_modes.py +6 -1
- app/event_handlers/webcam.py +7 -1
- app/tabs.py +1 -0
app.css
CHANGED
@@ -140,6 +140,10 @@ div.files-container label[data-testid="block-label"] {
|
|
140 |
max-width: fit-content;
|
141 |
}
|
142 |
|
|
|
|
|
|
|
|
|
143 |
div.languages-container_wrapper {
|
144 |
display: grid;
|
145 |
justify-content: end;
|
|
|
140 |
max-width: fit-content;
|
141 |
}
|
142 |
|
143 |
+
div.notifications {
|
144 |
+
height: 85px;
|
145 |
+
}
|
146 |
+
|
147 |
div.languages-container_wrapper {
|
148 |
display: grid;
|
149 |
justify-content: end;
|
app/components.py
CHANGED
@@ -13,11 +13,18 @@ from app.config import config_data
|
|
13 |
|
14 |
|
15 |
def html_message(
|
16 |
-
message: str = "",
|
|
|
|
|
|
|
17 |
) -> gr.HTML:
|
18 |
css_class = "noti_err" if not error else "noti_true"
|
19 |
|
20 |
-
return gr.HTML(
|
|
|
|
|
|
|
|
|
21 |
|
22 |
|
23 |
def files_create_ui(
|
|
|
13 |
|
14 |
|
15 |
def html_message(
|
16 |
+
message: str = "",
|
17 |
+
error: bool = True,
|
18 |
+
visible: bool = True,
|
19 |
+
elem_classes: Optional[str] = "html-container",
|
20 |
) -> gr.HTML:
|
21 |
css_class = "noti_err" if not error else "noti_true"
|
22 |
|
23 |
+
return gr.HTML(
|
24 |
+
value=f"<h3 class='{css_class}'>{message}</h3>",
|
25 |
+
visible=visible,
|
26 |
+
elem_classes=elem_classes,
|
27 |
+
)
|
28 |
|
29 |
|
30 |
def files_create_ui(
|
app/event_handlers/calculate_practical_tasks.py
CHANGED
@@ -270,7 +270,7 @@ def event_handler_calculate_practical_task_blocks(
|
|
270 |
+ config_data.Settings_DROPDOWN_MBTI_DEL_COLS_WEBCAM
|
271 |
)
|
272 |
|
273 |
-
df_hidden.insert(0, "
|
274 |
|
275 |
df_hidden.rename(
|
276 |
columns={
|
|
|
270 |
+ config_data.Settings_DROPDOWN_MBTI_DEL_COLS_WEBCAM
|
271 |
)
|
272 |
|
273 |
+
df_hidden.insert(0, "Popular Occupations", dropdown_mbti)
|
274 |
|
275 |
df_hidden.rename(
|
276 |
columns={
|
app/event_handlers/calculate_pt_scores_blocks.py
CHANGED
@@ -25,10 +25,14 @@ from app.components import (
|
|
25 |
textbox_create_ui,
|
26 |
)
|
27 |
|
|
|
|
|
28 |
|
29 |
def event_handler_calculate_pt_scores_blocks(
|
30 |
language, type_modes, files, video, evt_data: gr.EventData
|
31 |
):
|
|
|
|
|
32 |
_ = evt_data.target.__class__.__name__
|
33 |
|
34 |
lang_id, _ = get_language_settings(language)
|
@@ -48,14 +52,29 @@ def event_handler_calculate_pt_scores_blocks(
|
|
48 |
except TypeError:
|
49 |
out = True
|
50 |
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
if out or len(b5.df_files_) == 0:
|
54 |
gr.Warning(config_data.OtherMessages_CALCULATE_PT_SCORES_ERR[lang_id])
|
55 |
|
56 |
return (
|
57 |
html_message(
|
58 |
-
config_data.OtherMessages_CALCULATE_PT_SCORES_ERR[lang_id],
|
|
|
|
|
59 |
),
|
60 |
dataframe(visible=False),
|
61 |
files_create_ui(
|
@@ -73,24 +92,24 @@ def event_handler_calculate_pt_scores_blocks(
|
|
73 |
radio_create_ui(
|
74 |
first_practical_task,
|
75 |
config_data.Labels_PRACTICAL_TASKS_LABEL,
|
76 |
-
list(map(str,
|
77 |
config_data.InformationMessages_PRACTICAL_TASKS_INFO[lang_id],
|
78 |
True,
|
79 |
True,
|
80 |
),
|
81 |
radio_create_ui(
|
82 |
-
|
83 |
config_data.Labels_PRACTICAL_SUBTASKS_LABEL[lang_id],
|
84 |
-
|
85 |
config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO[lang_id],
|
86 |
True,
|
87 |
True,
|
88 |
),
|
89 |
gr.JSON(
|
90 |
value={
|
91 |
-
str(task):
|
92 |
-
for index in range(len(
|
93 |
-
for task in
|
94 |
},
|
95 |
visible=False,
|
96 |
render=True,
|
@@ -166,20 +185,23 @@ def event_handler_calculate_pt_scores_blocks(
|
|
166 |
|
167 |
if type_modes == config_data.Settings_TYPE_MODES[0]:
|
168 |
practical_tasks_choices = list(
|
169 |
-
map(str,
|
170 |
)
|
171 |
elif type_modes == config_data.Settings_TYPE_MODES[1]:
|
172 |
practical_tasks_choices = [
|
173 |
value
|
174 |
for i, value in enumerate(
|
175 |
-
map(str,
|
176 |
)
|
177 |
if i not in {1}
|
178 |
]
|
179 |
|
180 |
return (
|
181 |
html_message(
|
182 |
-
config_data.InformationMessages_NOTI_VIDEOS[lang_id],
|
|
|
|
|
|
|
183 |
),
|
184 |
dataframe(
|
185 |
headers=(config_data.Dataframes_PT_SCORES[lang_id]),
|
@@ -207,18 +229,18 @@ def event_handler_calculate_pt_scores_blocks(
|
|
207 |
True,
|
208 |
),
|
209 |
radio_create_ui(
|
210 |
-
|
211 |
config_data.Labels_PRACTICAL_SUBTASKS_LABEL[lang_id],
|
212 |
-
|
213 |
config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO[lang_id],
|
214 |
True,
|
215 |
True,
|
216 |
),
|
217 |
gr.JSON(
|
218 |
value={
|
219 |
-
str(task):
|
220 |
-
for index in range(len(
|
221 |
-
for task in
|
222 |
},
|
223 |
visible=False,
|
224 |
render=True,
|
|
|
25 |
textbox_create_ui,
|
26 |
)
|
27 |
|
28 |
+
import time
|
29 |
+
|
30 |
|
31 |
def event_handler_calculate_pt_scores_blocks(
|
32 |
language, type_modes, files, video, evt_data: gr.EventData
|
33 |
):
|
34 |
+
time.sleep(2000)
|
35 |
+
|
36 |
_ = evt_data.target.__class__.__name__
|
37 |
|
38 |
lang_id, _ = get_language_settings(language)
|
|
|
52 |
except TypeError:
|
53 |
out = True
|
54 |
|
55 |
+
if type_modes == config_data.Settings_TYPE_MODES[0]:
|
56 |
+
supported_practical_tasks_ren = supported_practical_tasks
|
57 |
+
elif type_modes == config_data.Settings_TYPE_MODES[1]:
|
58 |
+
rename_map = {
|
59 |
+
"Ranking potential candidates by professional responsibilities": "Determine professional possibilities",
|
60 |
+
"Ранжирование потенциальных кандидатов по профессиональным обязанностям": "Определить профессиональные возможности",
|
61 |
+
}
|
62 |
+
|
63 |
+
supported_practical_tasks_ren = [
|
64 |
+
{rename_map.get(k, k): v for k, v in d.items()}
|
65 |
+
for d in supported_practical_tasks
|
66 |
+
]
|
67 |
+
|
68 |
+
first_practical_task = next(iter(supported_practical_tasks_ren[lang_id]))
|
69 |
|
70 |
if out or len(b5.df_files_) == 0:
|
71 |
gr.Warning(config_data.OtherMessages_CALCULATE_PT_SCORES_ERR[lang_id])
|
72 |
|
73 |
return (
|
74 |
html_message(
|
75 |
+
config_data.OtherMessages_CALCULATE_PT_SCORES_ERR[lang_id],
|
76 |
+
False,
|
77 |
+
"notifications",
|
78 |
),
|
79 |
dataframe(visible=False),
|
80 |
files_create_ui(
|
|
|
92 |
radio_create_ui(
|
93 |
first_practical_task,
|
94 |
config_data.Labels_PRACTICAL_TASKS_LABEL,
|
95 |
+
list(map(str, supported_practical_tasks_ren[lang_id].keys())),
|
96 |
config_data.InformationMessages_PRACTICAL_TASKS_INFO[lang_id],
|
97 |
True,
|
98 |
True,
|
99 |
),
|
100 |
radio_create_ui(
|
101 |
+
supported_practical_tasks_ren[lang_id][first_practical_task][0],
|
102 |
config_data.Labels_PRACTICAL_SUBTASKS_LABEL[lang_id],
|
103 |
+
supported_practical_tasks_ren[lang_id][first_practical_task],
|
104 |
config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO[lang_id],
|
105 |
True,
|
106 |
True,
|
107 |
),
|
108 |
gr.JSON(
|
109 |
value={
|
110 |
+
str(task): supported_practical_tasks_ren[index].get(task, [None])[0]
|
111 |
+
for index in range(len(supported_practical_tasks_ren))
|
112 |
+
for task in supported_practical_tasks_ren[index].keys()
|
113 |
},
|
114 |
visible=False,
|
115 |
render=True,
|
|
|
185 |
|
186 |
if type_modes == config_data.Settings_TYPE_MODES[0]:
|
187 |
practical_tasks_choices = list(
|
188 |
+
map(str, supported_practical_tasks_ren[lang_id].keys())
|
189 |
)
|
190 |
elif type_modes == config_data.Settings_TYPE_MODES[1]:
|
191 |
practical_tasks_choices = [
|
192 |
value
|
193 |
for i, value in enumerate(
|
194 |
+
map(str, supported_practical_tasks_ren[lang_id].keys())
|
195 |
)
|
196 |
if i not in {1}
|
197 |
]
|
198 |
|
199 |
return (
|
200 |
html_message(
|
201 |
+
config_data.InformationMessages_NOTI_VIDEOS[lang_id],
|
202 |
+
False,
|
203 |
+
False,
|
204 |
+
"notifications",
|
205 |
),
|
206 |
dataframe(
|
207 |
headers=(config_data.Dataframes_PT_SCORES[lang_id]),
|
|
|
229 |
True,
|
230 |
),
|
231 |
radio_create_ui(
|
232 |
+
supported_practical_tasks_ren[lang_id][first_practical_task][0],
|
233 |
config_data.Labels_PRACTICAL_SUBTASKS_LABEL[lang_id],
|
234 |
+
supported_practical_tasks_ren[lang_id][first_practical_task],
|
235 |
config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO[lang_id],
|
236 |
True,
|
237 |
True,
|
238 |
),
|
239 |
gr.JSON(
|
240 |
value={
|
241 |
+
str(task): supported_practical_tasks_ren[index].get(task, [None])[0]
|
242 |
+
for index in range(len(supported_practical_tasks_ren))
|
243 |
+
for task in supported_practical_tasks_ren[index].keys()
|
244 |
},
|
245 |
visible=False,
|
246 |
render=True,
|
app/event_handlers/clear_blocks.py
CHANGED
@@ -54,7 +54,12 @@ def event_handler_clear_blocks(language, type_modes):
|
|
54 |
webcam = gr.Video(interactive=True, visible=True)
|
55 |
|
56 |
return (
|
57 |
-
html_message(
|
|
|
|
|
|
|
|
|
|
|
58 |
files_ui,
|
59 |
webcam,
|
60 |
video_create_ui(),
|
|
|
54 |
webcam = gr.Video(interactive=True, visible=True)
|
55 |
|
56 |
return (
|
57 |
+
html_message(
|
58 |
+
config_data.InformationMessages_NOTI_VIDEOS[lang_id],
|
59 |
+
False,
|
60 |
+
True,
|
61 |
+
"notifications",
|
62 |
+
),
|
63 |
files_ui,
|
64 |
webcam,
|
65 |
video_create_ui(),
|
app/event_handlers/event_handlers.py
CHANGED
@@ -430,7 +430,7 @@ def setup_app_event_handlers(
|
|
430 |
)
|
431 |
practical_tasks.change(
|
432 |
event_handler_practical_tasks,
|
433 |
-
[languages, practical_tasks, practical_subtasks_selected],
|
434 |
[practical_subtasks],
|
435 |
queue=True,
|
436 |
)
|
|
|
430 |
)
|
431 |
practical_tasks.change(
|
432 |
event_handler_practical_tasks,
|
433 |
+
[languages, type_modes, practical_tasks, practical_subtasks_selected],
|
434 |
[practical_subtasks],
|
435 |
queue=True,
|
436 |
)
|
app/event_handlers/examples_blocks.py
CHANGED
@@ -61,7 +61,12 @@ def event_handler_examples_blocks(language):
|
|
61 |
)
|
62 |
|
63 |
return (
|
64 |
-
html_message(
|
|
|
|
|
|
|
|
|
|
|
65 |
files_ui,
|
66 |
webcam,
|
67 |
switching_modes,
|
|
|
61 |
)
|
62 |
|
63 |
return (
|
64 |
+
html_message(
|
65 |
+
config_data.InformationMessages_NOTI_VIDEOS[lang_id],
|
66 |
+
False,
|
67 |
+
True,
|
68 |
+
"notifications",
|
69 |
+
),
|
70 |
files_ui,
|
71 |
webcam,
|
72 |
switching_modes,
|
app/event_handlers/files.py
CHANGED
@@ -19,7 +19,12 @@ def event_handler_files(language, files, video, pt_scores):
|
|
19 |
|
20 |
if not files:
|
21 |
return (
|
22 |
-
html_message(
|
|
|
|
|
|
|
|
|
|
|
23 |
video_create_ui(label=config_data.OtherMessages_VIDEO_PLAYER[lang_id]),
|
24 |
button(
|
25 |
config_data.OtherMessages_CALCULATE_PT_SCORES[lang_id],
|
@@ -47,6 +52,7 @@ def event_handler_files(language, files, video, pt_scores):
|
|
47 |
config_data.OtherMessages_NOTI_CALCULATE[lang_id],
|
48 |
True,
|
49 |
False if pt_scores.shape[1] >= 7 else True,
|
|
|
50 |
),
|
51 |
video_create_ui(
|
52 |
value=video,
|
|
|
19 |
|
20 |
if not files:
|
21 |
return (
|
22 |
+
html_message(
|
23 |
+
config_data.InformationMessages_NOTI_VIDEOS[lang_id],
|
24 |
+
False,
|
25 |
+
True,
|
26 |
+
"notifications",
|
27 |
+
),
|
28 |
video_create_ui(label=config_data.OtherMessages_VIDEO_PLAYER[lang_id]),
|
29 |
button(
|
30 |
config_data.OtherMessages_CALCULATE_PT_SCORES[lang_id],
|
|
|
52 |
config_data.OtherMessages_NOTI_CALCULATE[lang_id],
|
53 |
True,
|
54 |
False if pt_scores.shape[1] >= 7 else True,
|
55 |
+
"notifications",
|
56 |
),
|
57 |
video_create_ui(
|
58 |
value=video,
|
app/event_handlers/languages.py
CHANGED
@@ -80,7 +80,10 @@ def event_handler_languages(
|
|
80 |
if not video:
|
81 |
video = video_create_ui(label=config_data.OtherMessages_VIDEO_PLAYER[lang_id])
|
82 |
noti_videos = html_message(
|
83 |
-
config_data.InformationMessages_NOTI_VIDEOS[lang_id],
|
|
|
|
|
|
|
84 |
)
|
85 |
else:
|
86 |
video = video_create_ui(
|
@@ -92,6 +95,7 @@ def event_handler_languages(
|
|
92 |
config_data.OtherMessages_NOTI_CALCULATE[lang_id],
|
93 |
True,
|
94 |
False if pt_scores.shape[1] >= 7 else True,
|
|
|
95 |
)
|
96 |
|
97 |
csv_pt_scores = files_create_ui(
|
|
|
80 |
if not video:
|
81 |
video = video_create_ui(label=config_data.OtherMessages_VIDEO_PLAYER[lang_id])
|
82 |
noti_videos = html_message(
|
83 |
+
config_data.InformationMessages_NOTI_VIDEOS[lang_id],
|
84 |
+
False,
|
85 |
+
True,
|
86 |
+
"notifications",
|
87 |
)
|
88 |
else:
|
89 |
video = video_create_ui(
|
|
|
95 |
config_data.OtherMessages_NOTI_CALCULATE[lang_id],
|
96 |
True,
|
97 |
False if pt_scores.shape[1] >= 7 else True,
|
98 |
+
"notifications",
|
99 |
)
|
100 |
|
101 |
csv_pt_scores = files_create_ui(
|
app/event_handlers/practical_tasks.py
CHANGED
@@ -13,14 +13,27 @@ from app.utils import get_language_settings
|
|
13 |
|
14 |
|
15 |
def event_handler_practical_tasks(
|
16 |
-
language, practical_tasks, practical_subtasks_selected
|
17 |
):
|
18 |
lang_id, _ = get_language_settings(language)
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
return radio_create_ui(
|
21 |
practical_subtasks_selected[practical_tasks],
|
22 |
config_data.Labels_PRACTICAL_SUBTASKS_LABEL[lang_id],
|
23 |
-
|
24 |
config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO[lang_id],
|
25 |
True,
|
26 |
True,
|
|
|
13 |
|
14 |
|
15 |
def event_handler_practical_tasks(
|
16 |
+
language, type_modes, practical_tasks, practical_subtasks_selected
|
17 |
):
|
18 |
lang_id, _ = get_language_settings(language)
|
19 |
|
20 |
+
if type_modes == config_data.Settings_TYPE_MODES[0]:
|
21 |
+
supported_practical_tasks_ren = supported_practical_tasks
|
22 |
+
elif type_modes == config_data.Settings_TYPE_MODES[1]:
|
23 |
+
rename_map = {
|
24 |
+
"Ranking potential candidates by professional responsibilities": "Determine professional possibilities",
|
25 |
+
"Ранжирование потенциальных кандидатов по профессиональным обязанностям": "Определить профессиональные возможности",
|
26 |
+
}
|
27 |
+
|
28 |
+
supported_practical_tasks_ren = [
|
29 |
+
{rename_map.get(k, k): v for k, v in d.items()}
|
30 |
+
for d in supported_practical_tasks
|
31 |
+
]
|
32 |
+
|
33 |
return radio_create_ui(
|
34 |
practical_subtasks_selected[practical_tasks],
|
35 |
config_data.Labels_PRACTICAL_SUBTASKS_LABEL[lang_id],
|
36 |
+
supported_practical_tasks_ren[lang_id][practical_tasks],
|
37 |
config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO[lang_id],
|
38 |
True,
|
39 |
True,
|
app/event_handlers/switching_modes.py
CHANGED
@@ -76,7 +76,12 @@ def event_handler_switching_modes(language, type_modes):
|
|
76 |
)
|
77 |
|
78 |
return (
|
79 |
-
html_message(
|
|
|
|
|
|
|
|
|
|
|
80 |
files_ui,
|
81 |
webcam,
|
82 |
switching_modes,
|
|
|
76 |
)
|
77 |
|
78 |
return (
|
79 |
+
html_message(
|
80 |
+
config_data.InformationMessages_NOTI_VIDEOS[lang_id],
|
81 |
+
False,
|
82 |
+
True,
|
83 |
+
"notifications",
|
84 |
+
),
|
85 |
files_ui,
|
86 |
webcam,
|
87 |
switching_modes,
|
app/event_handlers/webcam.py
CHANGED
@@ -19,7 +19,12 @@ def event_handler_webcam(language, webcam, pt_scores):
|
|
19 |
|
20 |
if not webcam:
|
21 |
return (
|
22 |
-
html_message(
|
|
|
|
|
|
|
|
|
|
|
23 |
video_create_ui(label=config_data.OtherMessages_VIDEO_PLAYER[lang_id]),
|
24 |
gr.Video(value=None),
|
25 |
button(
|
@@ -48,6 +53,7 @@ def event_handler_webcam(language, webcam, pt_scores):
|
|
48 |
config_data.OtherMessages_NOTI_CALCULATE[lang_id],
|
49 |
True,
|
50 |
False if pt_scores.shape[1] >= 7 else True,
|
|
|
51 |
),
|
52 |
video_create_ui(
|
53 |
value=webcam,
|
|
|
19 |
|
20 |
if not webcam:
|
21 |
return (
|
22 |
+
html_message(
|
23 |
+
config_data.InformationMessages_NOTI_VIDEOS[lang_id],
|
24 |
+
False,
|
25 |
+
True,
|
26 |
+
"notifications",
|
27 |
+
),
|
28 |
video_create_ui(label=config_data.OtherMessages_VIDEO_PLAYER[lang_id]),
|
29 |
gr.Video(value=None),
|
30 |
button(
|
|
|
53 |
config_data.OtherMessages_NOTI_CALCULATE[lang_id],
|
54 |
True,
|
55 |
False if pt_scores.shape[1] >= 7 else True,
|
56 |
+
"notifications",
|
57 |
),
|
58 |
video_create_ui(
|
59 |
value=webcam,
|
app/tabs.py
CHANGED
@@ -130,6 +130,7 @@ def app_tab():
|
|
130 |
config_data.AppSettings_DEFAULT_LANG_ID
|
131 |
],
|
132 |
False,
|
|
|
133 |
)
|
134 |
|
135 |
pt_scores = dataframe(visible=False)
|
|
|
130 |
config_data.AppSettings_DEFAULT_LANG_ID
|
131 |
],
|
132 |
False,
|
133 |
+
"notifications",
|
134 |
)
|
135 |
|
136 |
pt_scores = dataframe(visible=False)
|