ElenaRyumina DmitryRyumin commited on
Commit
a26705a
1 Parent(s): 3202b24

- Summary (f6125144e9df803bac37023b6854f03c30d62a31)
- Merge branch 'main' of https://huggingface.co/spaces/ElenaRyumina/OCEANAI (2f050c06a94348ba17660fdf0dd257a7a30f2f9a)
- Summary (8f52d543a1de5a77b59164e6f4f721696fc64299)
- Merge branch 'main' of https://huggingface.co/spaces/ElenaRyumina/OCEANAI (fffa0062f0da04563ce8cd5b8c7e70e3ae783833)
- Summary (1717e06c53138f3eaf52e38f984035d5fbbceac5)
- Merge branch 'main' of https://huggingface.co/spaces/ElenaRyumina/OCEANAI (cd90a1620005039e6998ca3d0ab34fe3bfe1f2dc)
- Summary (98c66eeb6760ebd60d0a4ae4d9d0ac8f896a59df)


Co-authored-by: Dmitry Ryumin <DmitryRyumin@users.noreply.huggingface.co>

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.py CHANGED
@@ -93,6 +93,6 @@ if __name__ == "__main__":
93
 
94
  create_gradio_app().queue(api_open=False).launch(
95
  share=False,
96
- server_name=None,
97
- server_port=None,
98
  )
 
93
 
94
  create_gradio_app().queue(api_open=False).launch(
95
  share=False,
96
+ server_name=config_data.AppSettings_SERVER_NAME,
97
+ server_port=config_data.AppSettings_PORT,
98
  )
app/components.py CHANGED
@@ -13,11 +13,18 @@ from app.config import config_data
13
 
14
 
15
  def html_message(
16
- message: str = "", error: bool = True, visible: bool = True
 
 
 
17
  ) -> gr.HTML:
18
  css_class = "noti_err" if not error else "noti_true"
19
 
20
- return gr.HTML(value=f"<h3 class='{css_class}'>{message}</h3>", visible=visible)
 
 
 
 
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, "Personality Type (Dropdown)", dropdown_mbti)
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
- first_practical_task = next(iter(supported_practical_tasks[lang_id]))
 
 
 
 
 
 
 
 
 
 
 
 
 
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], False
 
 
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, supported_practical_tasks[lang_id].keys())),
77
  config_data.InformationMessages_PRACTICAL_TASKS_INFO[lang_id],
78
  True,
79
  True,
80
  ),
81
  radio_create_ui(
82
- supported_practical_tasks[lang_id][first_practical_task][0],
83
  config_data.Labels_PRACTICAL_SUBTASKS_LABEL[lang_id],
84
- supported_practical_tasks[lang_id][first_practical_task],
85
  config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO[lang_id],
86
  True,
87
  True,
88
  ),
89
  gr.JSON(
90
  value={
91
- str(task): supported_practical_tasks[index].get(task, [None])[0]
92
- for index in range(len(supported_practical_tasks))
93
- for task in supported_practical_tasks[index].keys()
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, supported_practical_tasks[lang_id].keys())
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, supported_practical_tasks[lang_id].keys())
176
  )
177
  if i not in {1}
178
  ]
179
 
180
  return (
181
  html_message(
182
- config_data.InformationMessages_NOTI_VIDEOS[lang_id], False, False
 
 
 
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
- supported_practical_tasks[lang_id][first_practical_task][0],
211
  config_data.Labels_PRACTICAL_SUBTASKS_LABEL[lang_id],
212
- supported_practical_tasks[lang_id][first_practical_task],
213
  config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO[lang_id],
214
  True,
215
  True,
216
  ),
217
  gr.JSON(
218
  value={
219
- str(task): supported_practical_tasks[index].get(task, [None])[0]
220
- for index in range(len(supported_practical_tasks))
221
- for task in supported_practical_tasks[index].keys()
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(config_data.InformationMessages_NOTI_VIDEOS[lang_id], False),
 
 
 
 
 
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(config_data.InformationMessages_NOTI_VIDEOS[lang_id], False),
 
 
 
 
 
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(config_data.InformationMessages_NOTI_VIDEOS[lang_id], False),
 
 
 
 
 
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], False
 
 
 
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
- supported_practical_tasks[lang_id][practical_tasks],
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(config_data.InformationMessages_NOTI_VIDEOS[lang_id], False),
 
 
 
 
 
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(config_data.InformationMessages_NOTI_VIDEOS[lang_id], False),
 
 
 
 
 
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)