.gradio/certificate.pem ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw
3
+ TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
4
+ cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4
5
+ WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu
6
+ ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY
7
+ MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54rVygc
8
+ h77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+
9
+ 0TM8ukj13Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6U
10
+ A5/TR5d8mUgjU+g4rk8Kb4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sW
11
+ T8KOEUt+zwvo/7V3LvSye0rgTBIlDHCNAymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyH
12
+ B5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ4Q7e2RCOFvu396j3x+UC
13
+ B5iPNgiV5+I3lg02dZ77DnKxHZu8A/lJBdiB3QW0KtZB6awBdpUKD9jf1b0SHzUv
14
+ KBds0pjBqAlkd25HN7rOrFleaJ1/ctaJxQZBKT5ZPt0m9STJEadao0xAH0ahmbWn
15
+ OlFuhjuefXKnEgV4We0+UXgVCwOPjdAvBbI+e0ocS3MFEvzG6uBQE3xDk3SzynTn
16
+ jh8BCNAw1FtxNrQHusEwMFxIt4I7mKZ9YIqioymCzLq9gwQbooMDQaHWBfEbwrbw
17
+ qHyGO0aoSCqI3Haadr8faqU9GY/rOPNk3sgrDQoo//fb4hVC1CLQJ13hef4Y53CI
18
+ rU7m2Ys6xt0nUW7/vGT1M0NPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV
19
+ HRMBAf8EBTADAQH/MB0GA1UdDgQWBBR5tFnme7bl5AFzgAiIyBpY9umbbjANBgkq
20
+ hkiG9w0BAQsFAAOCAgEAVR9YqbyyqFDQDLHYGmkgJykIrGF1XIpu+ILlaS/V9lZL
21
+ ubhzEFnTIZd+50xx+7LSYK05qAvqFyFWhfFQDlnrzuBZ6brJFe+GnY+EgPbk6ZGQ
22
+ 3BebYhtF8GaV0nxvwuo77x/Py9auJ/GpsMiu/X1+mvoiBOv/2X/qkSsisRcOj/KK
23
+ NFtY2PwByVS5uCbMiogziUwthDyC3+6WVwW6LLv3xLfHTjuCvjHIInNzktHCgKQ5
24
+ ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJwTdwJx4nLCgdNbOhdjsnvzqvHu7Ur
25
+ TkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nxe5AW0wdeRlN8NwdC
26
+ jNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZAJzVc
27
+ oyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq
28
+ 4RgqsahDYVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPA
29
+ mRGunUHBcnWEvgJBQl9nJEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d
30
+ emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=
31
+ -----END CERTIFICATE-----
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 😀🤓😎😉😤
4
  colorFrom: gray
5
  colorTo: red
6
  sdk: gradio
7
- sdk_version: 5.5.0
8
  app_file: app.py
9
  pinned: false
10
  license: mit
 
4
  colorFrom: gray
5
  colorTo: red
6
  sdk: gradio
7
+ sdk_version: 5.7.1
8
  app_file: app.py
9
  pinned: false
10
  license: mit
app.css CHANGED
@@ -14,9 +14,8 @@ div.app-flex-container {
14
  gap: 6px;
15
  }
16
 
17
- div.video-container {
18
- height: 350px;
19
- max-height: 350px;
20
  }
21
 
22
  div.video-column-container {
@@ -28,11 +27,17 @@ div.video-sorted-container {
28
  max-height: 350px;
29
  }
30
 
 
31
  div.files-container {
32
  height: 350px;
33
  max-height: 350px;
34
  }
35
 
 
 
 
 
 
36
  div.files-container tr {
37
  padding-right: 20px;
38
  }
@@ -42,6 +47,8 @@ div.video-sorted-container div.icon-buttons > button {
42
  display: none;
43
  }
44
 
 
 
45
  div.files-container:hover label[data-testid="block-label"],
46
  div.video-container:hover label[data-testid="block-label"],
47
  div.video-sorted-container:hover label[data-testid="block-label"] {
@@ -58,11 +65,14 @@ div.dataframe div.table-wrap {
58
  height: auto !important;
59
  }
60
 
 
61
  div.files-container div.file-preview-holder {
62
  overflow-y: scroll;
63
  height: 100%;
64
  }
65
 
 
 
66
  div.files-container label[data-testid="block-label"] {
67
  position: absolute;
68
  }
@@ -130,6 +140,10 @@ div.files-container label[data-testid="block-label"] {
130
  max-width: fit-content;
131
  }
132
 
 
 
 
 
133
  div.languages-container_wrapper {
134
  display: grid;
135
  justify-content: end;
@@ -169,6 +183,10 @@ div.languages-container > div.country_flags div.image-container > button > div.i
169
  height: 32px;
170
  }
171
 
 
 
 
 
172
  .dropdown-language-container {
173
  display: contents;
174
  }
 
14
  gap: 6px;
15
  }
16
 
17
+ div.media-container {
18
+ align-items: stretch;
 
19
  }
20
 
21
  div.video-column-container {
 
27
  max-height: 350px;
28
  }
29
 
30
+ div.webcam,
31
  div.files-container {
32
  height: 350px;
33
  max-height: 350px;
34
  }
35
 
36
+ div.webcam div[data-testid="video"] > div.wrap,
37
+ div.webcam div[data-testid="video"] > div.upload-container {
38
+ height: 310px;
39
+ }
40
+
41
  div.files-container tr {
42
  padding-right: 20px;
43
  }
 
47
  display: none;
48
  }
49
 
50
+ div.webcam:hover label[data-testid="block-label"],
51
+ div.video-container:hover label[data-testid="block-label"],
52
  div.files-container:hover label[data-testid="block-label"],
53
  div.video-container:hover label[data-testid="block-label"],
54
  div.video-sorted-container:hover label[data-testid="block-label"] {
 
65
  height: auto !important;
66
  }
67
 
68
+ div.video-container div.file-preview-holder,
69
  div.files-container div.file-preview-holder {
70
  overflow-y: scroll;
71
  height: 100%;
72
  }
73
 
74
+ div.webcam label[data-testid="block-label"],
75
+ div.video-container label[data-testid="block-label"],
76
  div.files-container label[data-testid="block-label"] {
77
  position: absolute;
78
  }
 
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;
 
183
  height: 32px;
184
  }
185
 
186
+ div.languages-container > div.country_flags div.image-container > div.icon-button-wrapper {
187
+ display: none;
188
+ }
189
+
190
  .dropdown-language-container {
191
  display: contents;
192
  }
app.py CHANGED
@@ -12,12 +12,15 @@ from app.config import CONFIG_NAME, config_data, load_tab_creators
12
  from app.event_handlers.event_handlers import setup_app_event_handlers
13
  from app import tabs
14
  from app.components import dropdown_create_ui
 
15
 
16
  gr.set_static_paths(paths=[config_data.StaticPaths_IMAGES])
17
 
18
 
19
  def create_gradio_app() -> gr.Blocks:
20
- with gr.Blocks(css=config_data.AppSettings_CSS_PATH) as gradio_app:
 
 
21
  with gr.Column(
22
  visible=True,
23
  render=True,
@@ -39,6 +42,7 @@ def create_gradio_app() -> gr.Blocks:
39
  visible=True,
40
  show_download_button=False,
41
  elem_classes="country_flags",
 
42
  )
43
 
44
  languages = dropdown_create_ui(
@@ -81,4 +85,14 @@ def create_gradio_app() -> gr.Blocks:
81
 
82
 
83
  if __name__ == "__main__":
84
- create_gradio_app().queue(api_open=False).launch(share=False)
 
 
 
 
 
 
 
 
 
 
 
12
  from app.event_handlers.event_handlers import setup_app_event_handlers
13
  from app import tabs
14
  from app.components import dropdown_create_ui
15
+ from app.port import is_port_in_use, free_ports
16
 
17
  gr.set_static_paths(paths=[config_data.StaticPaths_IMAGES])
18
 
19
 
20
  def create_gradio_app() -> gr.Blocks:
21
+ with gr.Blocks(
22
+ theme=gr.themes.Default(), css_paths=config_data.AppSettings_CSS_PATH
23
+ ) as gradio_app:
24
  with gr.Column(
25
  visible=True,
26
  render=True,
 
42
  visible=True,
43
  show_download_button=False,
44
  elem_classes="country_flags",
45
+ show_fullscreen_button=False,
46
  )
47
 
48
  languages = dropdown_create_ui(
 
85
 
86
 
87
  if __name__ == "__main__":
88
+ ports_to_check = [config_data.AppSettings_PORT]
89
+
90
+ for port in filter(None, ports_to_check):
91
+ if is_port_in_use(config_data.AppSettings_SERVER_NAME, port):
92
+ free_ports(port)
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/authors.py CHANGED
@@ -76,7 +76,7 @@ AUTHORS = """
76
  <a href="https://github.com/DmitryRyumin" style="display: inline-block;">
77
  <img src="https://github-stats-alpha.vercel.app/api?username=DmitryRyumin&cc=3081F7&tc=FFFFFF&ic=FFFFFF&bc=FFFFFF" alt="" />
78
  </a>
79
- <div style="display: flex; flex-wrap: wrap;">
80
  <img src="https://custom-icon-badges.demolab.com/badge/dynamic/json?style=flat-square&logo=fire&logoColor=fff&color=orange&label=GitHub%20streak&query=%24.currentStreak.length&suffix=%20days&url=https%3A%2F%2Fstreak-stats.demolab.com%2F%3Fuser%3Ddmitryryumin%26type%3Djson" alt="" style="margin-right: 6px; margin-bottom: 6px;" />
81
  <img src="https://komarev.com/ghpvc/?username=DmitryRyumin&style=flat-square" alt="" style="margin-bottom: 6px;" />
82
  </div>
 
76
  <a href="https://github.com/DmitryRyumin" style="display: inline-block;">
77
  <img src="https://github-stats-alpha.vercel.app/api?username=DmitryRyumin&cc=3081F7&tc=FFFFFF&ic=FFFFFF&bc=FFFFFF" alt="" />
78
  </a>
79
+ <div style="display: flex; flex-wrap: wrap; align-items: flex-start;">
80
  <img src="https://custom-icon-badges.demolab.com/badge/dynamic/json?style=flat-square&logo=fire&logoColor=fff&color=orange&label=GitHub%20streak&query=%24.currentStreak.length&suffix=%20days&url=https%3A%2F%2Fstreak-stats.demolab.com%2F%3Fuser%3Ddmitryryumin%26type%3Djson" alt="" style="margin-right: 6px; margin-bottom: 6px;" />
81
  <img src="https://komarev.com/ghpvc/?username=DmitryRyumin&style=flat-square" alt="" style="margin-bottom: 6px;" />
82
  </div>
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(
@@ -53,7 +60,7 @@ def video_create_ui(
53
  show_label: bool = True,
54
  interactive: bool = False,
55
  visible: bool = True,
56
- elem_classes: Optional[str] = "files-container",
57
  ) -> gr.Video:
58
  if file_name is not None:
59
  label += f" ({file_name})"
 
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(
 
60
  show_label: bool = True,
61
  interactive: bool = False,
62
  visible: bool = True,
63
+ elem_classes: Optional[str] = "video-container",
64
  ) -> gr.Video:
65
  if file_name is not None:
66
  label += f" ({file_name})"
app/data_init.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ File: data_init.py
3
+ Author: Elena Ryumina and Dmitry Ryumin
4
+ Description: Data initialization.
5
+ License: MIT License
6
+ """
7
+
8
+ from app.config import config_data
9
+ from app.utils import read_csv_file, extract_profession_weights
10
+
11
+
12
+ df_traits_priority_for_professions = read_csv_file(config_data.Links_PROFESSIONS)
13
+ weights_professions, interactive_professions = extract_profession_weights(
14
+ df_traits_priority_for_professions,
15
+ config_data.Settings_DROPDOWN_CANDIDATES[0],
16
+ )
app/event_handlers/calculate_practical_tasks.py CHANGED
@@ -6,18 +6,23 @@ License: MIT License
6
  """
7
 
8
  from app.oceanai_init import b5
 
9
  import re
10
  import gradio as gr
11
  from pathlib import Path
 
12
 
13
  # Importing necessary components for the Gradio app
14
  from app.config import config_data
15
  from app.video_metadata import video_metadata
16
  from app.mbti_description import MBTI_DESCRIPTION, MBTI_DATA
 
17
  from app.utils import (
18
  read_csv_file,
19
  apply_rounding_and_rename_columns,
20
  preprocess_scores_df,
 
 
21
  )
22
  from app.components import (
23
  html_message,
@@ -166,7 +171,10 @@ def create_person_metadata(person_id, files, video_metadata):
166
 
167
 
168
  def event_handler_calculate_practical_task_blocks(
 
 
169
  files,
 
170
  practical_subtasks,
171
  pt_scores,
172
  dropdown_mbti,
@@ -188,6 +196,11 @@ def event_handler_calculate_practical_task_blocks(
188
  number_agreeableness,
189
  number_non_neuroticism,
190
  ):
 
 
 
 
 
191
  if practical_subtasks.lower() == "16 personality types of mbti":
192
  df_correlation_coefficients = read_csv_file(config_data.Links_MBTI)
193
 
@@ -195,44 +208,107 @@ def event_handler_calculate_practical_task_blocks(
195
 
196
  preprocess_scores_df(pt_scores_copy, config_data.Dataframes_PT_SCORES[0][0])
197
 
198
- b5._professional_match(
199
- df_files=pt_scores_copy,
200
- correlation_coefficients=df_correlation_coefficients,
201
- personality_type=remove_parentheses(dropdown_mbti),
202
- threshold=threshold_mbti,
203
- out=False,
204
- )
 
205
 
206
- df = apply_rounding_and_rename_columns(b5.df_files_MBTI_job_match_)
207
 
208
- df_hidden = df.drop(
209
- columns=config_data.Settings_SHORT_PROFESSIONAL_SKILLS
210
- + config_data.Settings_DROPDOWN_MBTI_DEL_COLS
211
- )
212
 
213
- df_hidden.rename(
214
- columns={
215
- "Path": "Filename",
216
- "MBTI": "Personality Type",
217
- "MBTI_Score": "Personality Type Score",
218
- },
219
- inplace=True,
220
- )
221
 
222
- df_hidden.to_csv(config_data.Filenames_MBTI_JOB)
 
 
 
 
223
 
224
- df_hidden.reset_index(inplace=True)
225
 
226
- person_id = int(df_hidden.iloc[0][config_data.Dataframes_PT_SCORES[0][0]]) - 1
 
 
 
 
 
227
 
228
- short_mbti = extract_text_in_parentheses(dropdown_mbti)
229
- mbti_values = df_hidden["Personality Type"].tolist()
 
230
 
231
- df_hidden["Personality Type"] = [
232
- compare_strings(short_mbti, mbti, False) for mbti in mbti_values
233
- ]
234
 
235
- person_metadata = create_person_metadata(person_id, files, video_metadata)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
236
 
237
  existing_tuple = (
238
  gr.Row(visible=True),
@@ -277,117 +353,226 @@ def event_handler_calculate_practical_task_blocks(
277
 
278
  return existing_tuple[:-1] + person_metadata + existing_tuple[-1:]
279
  elif practical_subtasks.lower() == "professional groups":
280
- sum_weights = sum(
281
- [
282
- number_openness,
283
- number_conscientiousness,
284
- number_extraversion,
285
- number_agreeableness,
286
- number_non_neuroticism,
287
- ]
288
- )
289
-
290
- if sum_weights != 100:
291
- gr.Warning(config_data.InformationMessages_SUM_WEIGHTS.format(sum_weights))
292
-
293
- return (
294
- gr.Row(visible=False),
295
- gr.Column(visible=False),
296
- dataframe(visible=False),
297
- files_create_ui(
298
- None,
299
- "single",
300
- [".csv"],
301
- config_data.OtherMessages_EXPORT_PS,
302
- True,
303
- False,
304
- False,
305
- "csv-container",
306
- ),
307
- gr.Accordion(visible=False),
308
- gr.HTML(visible=False),
309
- dataframe(visible=False),
310
- gr.Column(visible=False),
311
- video_create_ui(visible=False),
312
- gr.Column(visible=False),
313
- gr.Row(visible=False),
314
- gr.Row(visible=False),
315
- gr.Image(visible=False),
316
- textbox_create_ui(visible=False),
317
- gr.Row(visible=False),
318
- gr.Image(visible=False),
319
- textbox_create_ui(visible=False),
320
- gr.Row(visible=False),
321
- gr.Row(visible=False),
322
- gr.Image(visible=False),
323
- textbox_create_ui(visible=False),
324
- gr.Row(visible=False),
325
- gr.Image(visible=False),
326
- textbox_create_ui(visible=False),
327
- html_message(
328
- config_data.InformationMessages_SUM_WEIGHTS.format(sum_weights),
329
- False,
330
- True,
331
- ),
332
- )
333
- else:
334
- b5._candidate_ranking(
335
- df_files=pt_scores.iloc[:, 1:],
336
- weigths_openness=number_openness,
337
- weigths_conscientiousness=number_conscientiousness,
338
- weigths_extraversion=number_extraversion,
339
- weigths_agreeableness=number_agreeableness,
340
- weigths_non_neuroticism=number_non_neuroticism,
341
- out=False,
342
- )
343
-
344
- df = apply_rounding_and_rename_columns(b5.df_files_ranking_)
345
-
346
- df_hidden = df.drop(columns=config_data.Settings_SHORT_PROFESSIONAL_SKILLS)
347
-
348
- df_hidden.to_csv(config_data.Filenames_POTENTIAL_CANDIDATES)
349
-
350
- df_hidden.reset_index(inplace=True)
351
-
352
- person_id = (
353
- int(df_hidden.iloc[0][config_data.Dataframes_PT_SCORES[0][0]]) - 1
354
  )
355
 
356
- person_metadata = create_person_metadata(person_id, files, video_metadata)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
357
 
358
- existing_tuple = (
359
- gr.Row(visible=True),
360
- gr.Column(visible=True),
361
- dataframe(
362
- headers=df_hidden.columns.tolist(),
363
- values=df_hidden.values.tolist(),
364
- visible=True,
365
- ),
366
- files_create_ui(
367
- config_data.Filenames_POTENTIAL_CANDIDATES,
368
- "single",
369
- [".csv"],
370
- config_data.OtherMessages_EXPORT_PG,
371
- True,
372
- False,
373
- True,
374
- "csv-container",
375
- ),
376
- gr.Accordion(visible=False),
377
- gr.HTML(visible=False),
378
- dataframe(visible=False),
379
- gr.Column(visible=True),
380
- video_create_ui(
381
- value=files[person_id],
382
- file_name=Path(files[person_id]).name,
383
- label="Best Person ID - " + str(person_id + 1),
384
- visible=True,
385
- elem_classes="video-sorted-container",
386
- ),
387
- html_message(config_data.InformationMessages_NOTI_IN_DEV, False, False),
388
- )
389
 
390
- return existing_tuple[:-1] + person_metadata + existing_tuple[-1:]
391
  elif practical_subtasks.lower() == "professional skills":
392
  df_professional_skills = read_csv_file(config_data.Links_PROFESSIONAL_SKILLS)
393
 
 
6
  """
7
 
8
  from app.oceanai_init import b5
9
+ import pandas as pd
10
  import re
11
  import gradio as gr
12
  from pathlib import Path
13
+ from bs4 import BeautifulSoup
14
 
15
  # Importing necessary components for the Gradio app
16
  from app.config import config_data
17
  from app.video_metadata import video_metadata
18
  from app.mbti_description import MBTI_DESCRIPTION, MBTI_DATA
19
+ from app.data_init import df_traits_priority_for_professions
20
  from app.utils import (
21
  read_csv_file,
22
  apply_rounding_and_rename_columns,
23
  preprocess_scores_df,
24
+ get_language_settings,
25
+ extract_profession_weights,
26
  )
27
  from app.components import (
28
  html_message,
 
171
 
172
 
173
  def event_handler_calculate_practical_task_blocks(
174
+ language,
175
+ type_modes,
176
  files,
177
+ video,
178
  practical_subtasks,
179
  pt_scores,
180
  dropdown_mbti,
 
196
  number_agreeableness,
197
  number_non_neuroticism,
198
  ):
199
+ lang_id, _ = get_language_settings(language)
200
+
201
+ if type_modes == config_data.Settings_TYPE_MODES[1]:
202
+ files = [video]
203
+
204
  if practical_subtasks.lower() == "16 personality types of mbti":
205
  df_correlation_coefficients = read_csv_file(config_data.Links_MBTI)
206
 
 
208
 
209
  preprocess_scores_df(pt_scores_copy, config_data.Dataframes_PT_SCORES[0][0])
210
 
211
+ if type_modes == config_data.Settings_TYPE_MODES[0]:
212
+ b5._professional_match(
213
+ df_files=pt_scores_copy,
214
+ correlation_coefficients=df_correlation_coefficients,
215
+ personality_type=remove_parentheses(dropdown_mbti),
216
+ threshold=threshold_mbti,
217
+ out=False,
218
+ )
219
 
220
+ df = apply_rounding_and_rename_columns(b5.df_files_MBTI_job_match_)
221
 
222
+ df_hidden = df.drop(
223
+ columns=config_data.Settings_SHORT_PROFESSIONAL_SKILLS
224
+ + config_data.Settings_DROPDOWN_MBTI_DEL_COLS
225
+ )
226
 
227
+ df_hidden.rename(
228
+ columns={
229
+ "Path": "Filename",
230
+ "MBTI": "Personality Type",
231
+ "MBTI_Score": "Personality Type Score",
232
+ },
233
+ inplace=True,
234
+ )
235
 
236
+ df_copy = df_hidden.copy()
237
+ df_copy["Personality Type"] = df_copy["Personality Type"].apply(
238
+ lambda x: "".join(BeautifulSoup(x, "html.parser").stripped_strings)
239
+ )
240
+ df_copy.to_csv(config_data.Filenames_MBTI_JOB, index=False)
241
 
242
+ df_hidden.reset_index(inplace=True)
243
 
244
+ person_id = (
245
+ int(df_hidden.iloc[0][config_data.Dataframes_PT_SCORES[0][0]]) - 1
246
+ )
247
+
248
+ short_mbti = extract_text_in_parentheses(dropdown_mbti)
249
+ mbti_values = df_hidden["Personality Type"].tolist()
250
 
251
+ df_hidden["Personality Type"] = [
252
+ compare_strings(short_mbti, mbti, False) for mbti in mbti_values
253
+ ]
254
 
255
+ person_metadata = create_person_metadata(person_id, files, video_metadata)
256
+ elif type_modes == config_data.Settings_TYPE_MODES[1]:
257
+ all_hidden_dfs = []
258
 
259
+ for dropdown_mbti in config_data.Settings_DROPDOWN_MBTI:
260
+ b5._professional_match(
261
+ df_files=pt_scores_copy,
262
+ correlation_coefficients=df_correlation_coefficients,
263
+ personality_type=remove_parentheses(dropdown_mbti),
264
+ threshold=threshold_mbti,
265
+ out=False,
266
+ )
267
+
268
+ df = apply_rounding_and_rename_columns(b5.df_files_MBTI_job_match_)
269
+
270
+ df_hidden = df.drop(
271
+ columns=config_data.Settings_SHORT_PROFESSIONAL_SKILLS
272
+ + config_data.Settings_DROPDOWN_MBTI_DEL_COLS
273
+ + config_data.Settings_DROPDOWN_MBTI_DEL_COLS_WEBCAM
274
+ )
275
+
276
+ df_hidden.insert(0, "Popular Occupations", dropdown_mbti)
277
+
278
+ df_hidden.rename(
279
+ columns={
280
+ "MBTI": "Personality Type",
281
+ "MBTI_Score": "Personality Type Score",
282
+ },
283
+ inplace=True,
284
+ )
285
+
286
+ short_mbti = extract_text_in_parentheses(dropdown_mbti)
287
+ mbti_values = df_hidden["Personality Type"].tolist()
288
+
289
+ df_hidden["Personality Type"] = [
290
+ compare_strings(short_mbti, mbti, False) for mbti in mbti_values
291
+ ]
292
+
293
+ all_hidden_dfs.append(df_hidden)
294
+
295
+ df_hidden = pd.concat(all_hidden_dfs, ignore_index=True)
296
+
297
+ df_hidden = df_hidden.sort_values(
298
+ by="Personality Type Score", ascending=False
299
+ )
300
+
301
+ df_hidden.reset_index(drop=True, inplace=True)
302
+
303
+ df_copy = df_hidden.copy()
304
+ df_copy["Personality Type"] = df_copy["Personality Type"].apply(
305
+ lambda x: "".join(BeautifulSoup(x, "html.parser").stripped_strings)
306
+ )
307
+ df_copy.to_csv(config_data.Filenames_MBTI_JOB, index=False)
308
+
309
+ person_id = 0
310
+
311
+ person_metadata = create_person_metadata(person_id, files, video_metadata)
312
 
313
  existing_tuple = (
314
  gr.Row(visible=True),
 
353
 
354
  return existing_tuple[:-1] + person_metadata + existing_tuple[-1:]
355
  elif practical_subtasks.lower() == "professional groups":
356
+ if type_modes == config_data.Settings_TYPE_MODES[0]:
357
+ sum_weights = sum(
358
+ [
359
+ number_openness,
360
+ number_conscientiousness,
361
+ number_extraversion,
362
+ number_agreeableness,
363
+ number_non_neuroticism,
364
+ ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
365
  )
366
 
367
+ if sum_weights != 100:
368
+ gr.Warning(
369
+ config_data.InformationMessages_SUM_WEIGHTS.format(sum_weights)
370
+ )
371
+
372
+ return (
373
+ gr.Row(visible=False),
374
+ gr.Column(visible=False),
375
+ dataframe(visible=False),
376
+ files_create_ui(
377
+ None,
378
+ "single",
379
+ [".csv"],
380
+ config_data.OtherMessages_EXPORT_PS,
381
+ True,
382
+ False,
383
+ False,
384
+ "csv-container",
385
+ ),
386
+ gr.Accordion(visible=False),
387
+ gr.HTML(visible=False),
388
+ dataframe(visible=False),
389
+ gr.Column(visible=False),
390
+ video_create_ui(visible=False),
391
+ gr.Column(visible=False),
392
+ gr.Row(visible=False),
393
+ gr.Row(visible=False),
394
+ gr.Image(visible=False),
395
+ textbox_create_ui(visible=False),
396
+ gr.Row(visible=False),
397
+ gr.Image(visible=False),
398
+ textbox_create_ui(visible=False),
399
+ gr.Row(visible=False),
400
+ gr.Row(visible=False),
401
+ gr.Image(visible=False),
402
+ textbox_create_ui(visible=False),
403
+ gr.Row(visible=False),
404
+ gr.Image(visible=False),
405
+ textbox_create_ui(visible=False),
406
+ html_message(
407
+ config_data.InformationMessages_SUM_WEIGHTS.format(sum_weights),
408
+ False,
409
+ True,
410
+ ),
411
+ )
412
+ else:
413
+ b5._candidate_ranking(
414
+ df_files=pt_scores.iloc[:, 1:],
415
+ weigths_openness=number_openness,
416
+ weigths_conscientiousness=number_conscientiousness,
417
+ weigths_extraversion=number_extraversion,
418
+ weigths_agreeableness=number_agreeableness,
419
+ weigths_non_neuroticism=number_non_neuroticism,
420
+ out=False,
421
+ )
422
+
423
+ df = apply_rounding_and_rename_columns(b5.df_files_ranking_)
424
+
425
+ df_hidden = df.drop(
426
+ columns=config_data.Settings_SHORT_PROFESSIONAL_SKILLS
427
+ )
428
+
429
+ df_hidden.to_csv(config_data.Filenames_POTENTIAL_CANDIDATES)
430
+
431
+ df_hidden.reset_index(inplace=True)
432
+
433
+ person_id = (
434
+ int(df_hidden.iloc[0][config_data.Dataframes_PT_SCORES[0][0]]) - 1
435
+ )
436
+
437
+ person_metadata = create_person_metadata(
438
+ person_id, files, video_metadata
439
+ )
440
+ elif type_modes == config_data.Settings_TYPE_MODES[1]:
441
+ all_hidden_dfs = []
442
+
443
+ for dropdown_candidate in config_data.Settings_DROPDOWN_CANDIDATES[:-1]:
444
+ weights, _ = extract_profession_weights(
445
+ df_traits_priority_for_professions,
446
+ dropdown_candidate,
447
+ )
448
+
449
+ sum_weights = sum(weights)
450
+
451
+ if sum_weights != 100:
452
+ gr.Warning(
453
+ config_data.InformationMessages_SUM_WEIGHTS.format(sum_weights)
454
+ )
455
+
456
+ return (
457
+ gr.Row(visible=False),
458
+ gr.Column(visible=False),
459
+ dataframe(visible=False),
460
+ files_create_ui(
461
+ None,
462
+ "single",
463
+ [".csv"],
464
+ config_data.OtherMessages_EXPORT_PS,
465
+ True,
466
+ False,
467
+ False,
468
+ "csv-container",
469
+ ),
470
+ gr.Accordion(visible=False),
471
+ gr.HTML(visible=False),
472
+ dataframe(visible=False),
473
+ gr.Column(visible=False),
474
+ video_create_ui(visible=False),
475
+ gr.Column(visible=False),
476
+ gr.Row(visible=False),
477
+ gr.Row(visible=False),
478
+ gr.Image(visible=False),
479
+ textbox_create_ui(visible=False),
480
+ gr.Row(visible=False),
481
+ gr.Image(visible=False),
482
+ textbox_create_ui(visible=False),
483
+ gr.Row(visible=False),
484
+ gr.Row(visible=False),
485
+ gr.Image(visible=False),
486
+ textbox_create_ui(visible=False),
487
+ gr.Row(visible=False),
488
+ gr.Image(visible=False),
489
+ textbox_create_ui(visible=False),
490
+ html_message(
491
+ config_data.InformationMessages_SUM_WEIGHTS.format(
492
+ sum_weights
493
+ ),
494
+ False,
495
+ True,
496
+ ),
497
+ )
498
+ else:
499
+ b5._candidate_ranking(
500
+ df_files=pt_scores.iloc[:, 1:],
501
+ weigths_openness=weights[0],
502
+ weigths_conscientiousness=weights[1],
503
+ weigths_extraversion=weights[2],
504
+ weigths_agreeableness=weights[3],
505
+ weigths_non_neuroticism=weights[4],
506
+ out=False,
507
+ )
508
+
509
+ df = apply_rounding_and_rename_columns(b5.df_files_ranking_)
510
+
511
+ df_hidden = df.drop(
512
+ columns=config_data.Settings_SHORT_PROFESSIONAL_SKILLS
513
+ + config_data.Settings_DROPDOWN_MBTI_DEL_COLS_WEBCAM
514
+ )
515
+
516
+ df_hidden.insert(0, "Professional Group", dropdown_candidate)
517
+
518
+ all_hidden_dfs.append(df_hidden)
519
+
520
+ df_hidden = pd.concat(all_hidden_dfs, ignore_index=True)
521
+
522
+ df_hidden.rename(
523
+ columns={
524
+ "Candidate score": "Summary Score",
525
+ },
526
+ inplace=True,
527
+ )
528
+
529
+ df_hidden = df_hidden.sort_values(by="Summary Score", ascending=False)
530
+
531
+ df_hidden.reset_index(drop=True, inplace=True)
532
+
533
+ df_hidden.to_csv(
534
+ config_data.Filenames_POTENTIAL_CANDIDATES, index=False
535
+ )
536
+
537
+ person_id = 0
538
+
539
+ person_metadata = create_person_metadata(
540
+ person_id, files, video_metadata
541
+ )
542
 
543
+ existing_tuple = (
544
+ gr.Row(visible=True),
545
+ gr.Column(visible=True),
546
+ dataframe(
547
+ headers=df_hidden.columns.tolist(),
548
+ values=df_hidden.values.tolist(),
549
+ visible=True,
550
+ ),
551
+ files_create_ui(
552
+ config_data.Filenames_POTENTIAL_CANDIDATES,
553
+ "single",
554
+ [".csv"],
555
+ config_data.OtherMessages_EXPORT_PG,
556
+ True,
557
+ False,
558
+ True,
559
+ "csv-container",
560
+ ),
561
+ gr.Accordion(visible=False),
562
+ gr.HTML(visible=False),
563
+ dataframe(visible=False),
564
+ gr.Column(visible=True),
565
+ video_create_ui(
566
+ value=files[person_id],
567
+ file_name=Path(files[person_id]).name,
568
+ label="Best Person ID - " + str(person_id + 1),
569
+ visible=True,
570
+ elem_classes="video-sorted-container",
571
+ ),
572
+ html_message(config_data.InformationMessages_NOTI_IN_DEV, False, False),
573
+ )
574
 
575
+ return existing_tuple[:-1] + person_metadata + existing_tuple[-1:]
576
  elif practical_subtasks.lower() == "professional skills":
577
  df_professional_skills = read_csv_file(config_data.Links_PROFESSIONAL_SKILLS)
578
 
app/event_handlers/calculate_pt_scores_blocks.py CHANGED
@@ -26,23 +26,52 @@ from app.components import (
26
  )
27
 
28
 
29
- def event_handler_calculate_pt_scores_blocks(language, files, evt_data: gr.EventData):
 
 
30
  _ = evt_data.target.__class__.__name__
31
 
32
  lang_id, _ = get_language_settings(language)
33
 
34
  out = False
35
- b5.get_avt_predictions_gradio(
36
- paths=files, url_accuracy="", accuracy=False, lang="en", out=out
37
- )
38
 
39
- first_practical_task = next(iter(supported_practical_tasks))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
- if len(b5.df_files_) == 0:
42
- gr.Warning(config_data.OtherMessages_CALCULATE_PT_SCORES_ERR)
 
 
 
 
 
 
 
43
 
44
  return (
45
- html_message(config_data.OtherMessages_CALCULATE_PT_SCORES_ERR, False),
 
 
 
 
46
  dataframe(visible=False),
47
  files_create_ui(
48
  None,
@@ -59,23 +88,24 @@ def event_handler_calculate_pt_scores_blocks(language, files, evt_data: gr.Event
59
  radio_create_ui(
60
  first_practical_task,
61
  config_data.Labels_PRACTICAL_TASKS_LABEL,
62
- list(map(str, supported_practical_tasks.keys())),
63
- config_data.InformationMessages_PRACTICAL_TASKS_INFO,
64
  True,
65
  True,
66
  ),
67
  radio_create_ui(
68
- supported_practical_tasks[first_practical_task][0],
69
- config_data.Labels_PRACTICAL_SUBTASKS_LABEL,
70
- supported_practical_tasks[first_practical_task],
71
- config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO,
72
  True,
73
  True,
74
  ),
75
  gr.JSON(
76
  value={
77
- str(task): supported_practical_tasks.get(task, [None])[0]
78
- for task in supported_practical_tasks.keys()
 
79
  },
80
  visible=False,
81
  render=True,
@@ -149,9 +179,25 @@ def event_handler_calculate_pt_scores_blocks(language, files, evt_data: gr.Event
149
  df_files = b5.df_files_.copy()
150
  df_files.reset_index(inplace=True)
151
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
  return (
153
  html_message(
154
- config_data.InformationMessages_NOTI_VIDEOS[lang_id], False, False
 
 
 
155
  ),
156
  dataframe(
157
  headers=(config_data.Dataframes_PT_SCORES[lang_id]),
@@ -172,35 +218,38 @@ def event_handler_calculate_pt_scores_blocks(language, files, evt_data: gr.Event
172
  gr.Column(visible=True),
173
  radio_create_ui(
174
  first_practical_task,
175
- "Practical tasks",
176
- list(map(str, supported_practical_tasks.keys())),
177
- config_data.InformationMessages_PRACTICAL_TASKS_INFO,
178
  True,
179
  True,
180
  ),
181
  radio_create_ui(
182
- supported_practical_tasks[first_practical_task][0],
183
- "Practical subtasks",
184
- supported_practical_tasks[first_practical_task],
185
- config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO,
186
  True,
187
  True,
188
  ),
189
  gr.JSON(
190
  value={
191
- str(task): supported_practical_tasks.get(task, [None])[0]
192
- for task in supported_practical_tasks.keys()
 
193
  },
194
  visible=False,
195
  render=True,
196
  ),
197
- gr.Column(visible=True),
 
 
198
  dropdown_create_ui(
199
  label=f"Potential candidates by Personality Type of MBTI ({len(config_data.Settings_DROPDOWN_MBTI)})",
200
  info=config_data.InformationMessages_DROPDOWN_MBTI_INFO,
201
  choices=config_data.Settings_DROPDOWN_MBTI,
202
  value=config_data.Settings_DROPDOWN_MBTI[0],
203
- visible=True,
204
  elem_classes="dropdown-container",
205
  ),
206
  number_create_ui(
@@ -212,7 +261,7 @@ def event_handler_calculate_pt_scores_blocks(language, files, evt_data: gr.Event
212
  info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(0, 1.0),
213
  show_label=True,
214
  interactive=True,
215
- visible=True,
216
  render=True,
217
  elem_classes="number-container",
218
  ),
 
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)
35
 
36
  out = False
 
 
 
37
 
38
+ try:
39
+ b5.get_avt_predictions_gradio(
40
+ paths=(
41
+ files if type_modes == config_data.Settings_TYPE_MODES[0] else [video]
42
+ ),
43
+ url_accuracy="",
44
+ accuracy=False,
45
+ lang="en",
46
+ out=out,
47
+ )
48
+ except TypeError:
49
+ out = True
50
+
51
+ if type_modes == config_data.Settings_TYPE_MODES[0]:
52
+ supported_practical_tasks_ren = supported_practical_tasks
53
+ elif type_modes == config_data.Settings_TYPE_MODES[1]:
54
+ rename_map = {
55
+ "Ranking potential candidates by professional responsibilities": "Determine professional possibilities",
56
+ "Ранжирование потенциальных кандидатов по профессиональным обязанностям": "Определить профессиональные возможности",
57
+ }
58
 
59
+ supported_practical_tasks_ren = [
60
+ {rename_map.get(k, k): v for k, v in d.items()}
61
+ for d in supported_practical_tasks
62
+ ]
63
+
64
+ first_practical_task = next(iter(supported_practical_tasks_ren[lang_id]))
65
+
66
+ if out or len(b5.df_files_) == 0:
67
+ gr.Warning(config_data.OtherMessages_CALCULATE_PT_SCORES_ERR[lang_id])
68
 
69
  return (
70
+ html_message(
71
+ config_data.OtherMessages_CALCULATE_PT_SCORES_ERR[lang_id],
72
+ False,
73
+ "notifications",
74
+ ),
75
  dataframe(visible=False),
76
  files_create_ui(
77
  None,
 
88
  radio_create_ui(
89
  first_practical_task,
90
  config_data.Labels_PRACTICAL_TASKS_LABEL,
91
+ list(map(str, supported_practical_tasks_ren[lang_id].keys())),
92
+ config_data.InformationMessages_PRACTICAL_TASKS_INFO[lang_id],
93
  True,
94
  True,
95
  ),
96
  radio_create_ui(
97
+ supported_practical_tasks_ren[lang_id][first_practical_task][0],
98
+ config_data.Labels_PRACTICAL_SUBTASKS_LABEL[lang_id],
99
+ supported_practical_tasks_ren[lang_id][first_practical_task],
100
+ config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO[lang_id],
101
  True,
102
  True,
103
  ),
104
  gr.JSON(
105
  value={
106
+ str(task): supported_practical_tasks_ren[index].get(task, [None])[0]
107
+ for index in range(len(supported_practical_tasks_ren))
108
+ for task in supported_practical_tasks_ren[index].keys()
109
  },
110
  visible=False,
111
  render=True,
 
179
  df_files = b5.df_files_.copy()
180
  df_files.reset_index(inplace=True)
181
 
182
+ if type_modes == config_data.Settings_TYPE_MODES[0]:
183
+ practical_tasks_choices = list(
184
+ map(str, supported_practical_tasks_ren[lang_id].keys())
185
+ )
186
+ elif type_modes == config_data.Settings_TYPE_MODES[1]:
187
+ practical_tasks_choices = [
188
+ value
189
+ for i, value in enumerate(
190
+ map(str, supported_practical_tasks_ren[lang_id].keys())
191
+ )
192
+ if i not in {1}
193
+ ]
194
+
195
  return (
196
  html_message(
197
+ config_data.InformationMessages_NOTI_VIDEOS[lang_id],
198
+ False,
199
+ False,
200
+ "notifications",
201
  ),
202
  dataframe(
203
  headers=(config_data.Dataframes_PT_SCORES[lang_id]),
 
218
  gr.Column(visible=True),
219
  radio_create_ui(
220
  first_practical_task,
221
+ config_data.Labels_PRACTICAL_TASKS_LABEL[lang_id],
222
+ practical_tasks_choices,
223
+ config_data.InformationMessages_PRACTICAL_TASKS_INFO[lang_id],
224
  True,
225
  True,
226
  ),
227
  radio_create_ui(
228
+ supported_practical_tasks_ren[lang_id][first_practical_task][0],
229
+ config_data.Labels_PRACTICAL_SUBTASKS_LABEL[lang_id],
230
+ supported_practical_tasks_ren[lang_id][first_practical_task],
231
+ config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO[lang_id],
232
  True,
233
  True,
234
  ),
235
  gr.JSON(
236
  value={
237
+ str(task): supported_practical_tasks_ren[index].get(task, [None])[0]
238
+ for index in range(len(supported_practical_tasks_ren))
239
+ for task in supported_practical_tasks_ren[index].keys()
240
  },
241
  visible=False,
242
  render=True,
243
  ),
244
+ gr.Column(
245
+ visible=True if type_modes == config_data.Settings_TYPE_MODES[0] else False
246
+ ),
247
  dropdown_create_ui(
248
  label=f"Potential candidates by Personality Type of MBTI ({len(config_data.Settings_DROPDOWN_MBTI)})",
249
  info=config_data.InformationMessages_DROPDOWN_MBTI_INFO,
250
  choices=config_data.Settings_DROPDOWN_MBTI,
251
  value=config_data.Settings_DROPDOWN_MBTI[0],
252
+ visible=True if type_modes == config_data.Settings_TYPE_MODES[0] else False,
253
  elem_classes="dropdown-container",
254
  ),
255
  number_create_ui(
 
261
  info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(0, 1.0),
262
  show_label=True,
263
  interactive=True,
264
+ visible=True if type_modes == config_data.Settings_TYPE_MODES[0] else False,
265
  render=True,
266
  elem_classes="number-container",
267
  ),
app/event_handlers/clear_blocks.py CHANGED
@@ -25,20 +25,43 @@ from app.components import (
25
  from app.utils import get_language_settings
26
 
27
 
28
- def event_handler_clear_blocks(language):
29
  lang_id, _ = get_language_settings(language)
30
 
31
- first_practical_task = next(iter(supported_practical_tasks))
32
 
33
- return (
34
- html_message(config_data.InformationMessages_NOTI_VIDEOS[lang_id], False),
35
- files_create_ui(
 
 
 
 
 
 
 
 
 
 
36
  label="{} ({})".format(
37
  config_data.OtherMessages_VIDEO_FILES[lang_id],
38
  ", ".join(config_data.Settings_SUPPORTED_VIDEO_EXT),
39
  ),
40
  file_types=[f".{ext}" for ext in config_data.Settings_SUPPORTED_VIDEO_EXT],
 
 
 
 
 
 
 
 
 
 
 
41
  ),
 
 
42
  video_create_ui(),
43
  button(
44
  config_data.OtherMessages_CALCULATE_PT_SCORES[lang_id],
@@ -71,24 +94,25 @@ def event_handler_clear_blocks(language):
71
  gr.Column(visible=False),
72
  radio_create_ui(
73
  first_practical_task,
74
- "Practical tasks",
75
- list(map(str, supported_practical_tasks.keys())),
76
- config_data.InformationMessages_PRACTICAL_TASKS_INFO,
77
  True,
78
  True,
79
  ),
80
  radio_create_ui(
81
- supported_practical_tasks[first_practical_task][0],
82
- "Practical subtasks",
83
- supported_practical_tasks[first_practical_task],
84
- config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO,
85
  True,
86
  True,
87
  ),
88
  gr.JSON(
89
  value={
90
- str(task): supported_practical_tasks.get(task, [None])[0]
91
- for task in supported_practical_tasks.keys()
 
92
  },
93
  visible=False,
94
  render=True,
 
25
  from app.utils import get_language_settings
26
 
27
 
28
+ def event_handler_clear_blocks(language, type_modes):
29
  lang_id, _ = get_language_settings(language)
30
 
31
+ first_practical_task = next(iter(supported_practical_tasks[lang_id]))
32
 
33
+ if type_modes == config_data.Settings_TYPE_MODES[0]:
34
+ files_ui = files_create_ui(
35
+ label="{} ({})".format(
36
+ config_data.OtherMessages_VIDEO_FILES[
37
+ config_data.AppSettings_DEFAULT_LANG_ID
38
+ ],
39
+ ", ".join(config_data.Settings_SUPPORTED_VIDEO_EXT),
40
+ ),
41
+ file_types=[f".{ext}" for ext in config_data.Settings_SUPPORTED_VIDEO_EXT],
42
+ )
43
+ webcam = gr.Video(interactive=False, visible=False)
44
+ elif type_modes == config_data.Settings_TYPE_MODES[1]:
45
+ files_ui = files_create_ui(
46
  label="{} ({})".format(
47
  config_data.OtherMessages_VIDEO_FILES[lang_id],
48
  ", ".join(config_data.Settings_SUPPORTED_VIDEO_EXT),
49
  ),
50
  file_types=[f".{ext}" for ext in config_data.Settings_SUPPORTED_VIDEO_EXT],
51
+ interactive=False,
52
+ visible=False,
53
+ )
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(),
66
  button(
67
  config_data.OtherMessages_CALCULATE_PT_SCORES[lang_id],
 
94
  gr.Column(visible=False),
95
  radio_create_ui(
96
  first_practical_task,
97
+ config_data.Labels_PRACTICAL_TASKS_LABEL[lang_id],
98
+ list(map(str, supported_practical_tasks[lang_id].keys())),
99
+ config_data.InformationMessages_PRACTICAL_TASKS_INFO[lang_id],
100
  True,
101
  True,
102
  ),
103
  radio_create_ui(
104
+ supported_practical_tasks[lang_id][first_practical_task][0],
105
+ config_data.Labels_PRACTICAL_SUBTASKS_LABEL[lang_id],
106
+ supported_practical_tasks[lang_id][first_practical_task],
107
+ config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO[lang_id],
108
  True,
109
  True,
110
  ),
111
  gr.JSON(
112
  value={
113
+ str(task): supported_practical_tasks[index].get(task, [None])[0]
114
+ for index in range(len(supported_practical_tasks))
115
+ for task in supported_practical_tasks[index].keys()
116
  },
117
  visible=False,
118
  render=True,
app/event_handlers/dropdown_candidates.py CHANGED
@@ -7,16 +7,13 @@ License: MIT License
7
 
8
  # Importing necessary components for the Gradio app
9
  from app.config import config_data
10
- from app.utils import read_csv_file, extract_profession_weights
11
- from app.components import number_create_ui, dropdown_create_ui
 
12
 
13
 
14
  def event_handler_dropdown_candidates(practical_subtasks, dropdown_candidates):
15
  if practical_subtasks.lower() == "professional groups":
16
- df_traits_priority_for_professions = read_csv_file(
17
- config_data.Links_PROFESSIONS
18
- )
19
-
20
  weights, interactive = extract_profession_weights(
21
  df_traits_priority_for_professions,
22
  dropdown_candidates,
 
7
 
8
  # Importing necessary components for the Gradio app
9
  from app.config import config_data
10
+ from app.utils import extract_profession_weights
11
+ from app.data_init import df_traits_priority_for_professions
12
+ from app.components import number_create_ui
13
 
14
 
15
  def event_handler_dropdown_candidates(practical_subtasks, dropdown_candidates):
16
  if practical_subtasks.lower() == "professional groups":
 
 
 
 
17
  weights, interactive = extract_profession_weights(
18
  df_traits_priority_for_professions,
19
  dropdown_candidates,
app/event_handlers/event_handlers.py CHANGED
@@ -9,11 +9,13 @@ import gradio as gr
9
 
10
  # Importing necessary components for the Gradio app
11
  from app.event_handlers.languages import event_handler_languages
 
12
  from app.event_handlers.files import (
13
  event_handler_files,
14
  event_handler_files_select,
15
  event_handler_files_delete,
16
  )
 
17
  from app.event_handlers.examples_blocks import event_handler_examples_blocks
18
  from app.event_handlers.clear_blocks import event_handler_clear_blocks
19
  from app.event_handlers.calculate_pt_scores_blocks import (
@@ -33,6 +35,9 @@ def setup_app_event_handlers(
33
  step_1,
34
  notifications,
35
  files,
 
 
 
36
  video,
37
  examples,
38
  calculate_pt_scores,
@@ -101,7 +106,16 @@ def setup_app_event_handlers(
101
  # Events
102
  languages.select(
103
  fn=event_handler_languages,
104
- inputs=[languages, files, video, pt_scores, csv_pt_scores],
 
 
 
 
 
 
 
 
 
105
  outputs=[
106
  description,
107
  step_1,
@@ -112,6 +126,8 @@ def setup_app_event_handlers(
112
  tab3,
113
  tab4,
114
  files,
 
 
115
  video,
116
  examples,
117
  calculate_pt_scores,
@@ -120,6 +136,76 @@ def setup_app_event_handlers(
120
  pt_scores,
121
  csv_pt_scores,
122
  step_2,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  ],
124
  queue=True,
125
  )
@@ -141,13 +227,17 @@ def setup_app_event_handlers(
141
  [video],
142
  queue=True,
143
  )
 
 
 
 
 
 
 
144
  gr.on(
145
  triggers=[calculate_pt_scores.click],
146
  fn=event_handler_calculate_pt_scores_blocks,
147
- inputs=[
148
- languages,
149
- files,
150
- ],
151
  outputs=[
152
  notifications,
153
  pt_scores,
@@ -208,18 +298,78 @@ def setup_app_event_handlers(
208
  )
209
  examples.click(
210
  fn=event_handler_examples_blocks,
211
- inputs=[],
212
  outputs=[
 
213
  files,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
  ],
215
  queue=True,
216
  )
217
  clear_app.click(
218
  fn=event_handler_clear_blocks,
219
- inputs=[languages],
220
  outputs=[
221
  notifications,
222
  files,
 
223
  video,
224
  calculate_pt_scores,
225
  clear_app,
@@ -280,13 +430,19 @@ def setup_app_event_handlers(
280
  )
281
  practical_tasks.change(
282
  event_handler_practical_tasks,
283
- [practical_tasks, practical_subtasks_selected],
284
  [practical_subtasks],
285
  queue=True,
286
  )
287
  practical_subtasks.change(
288
  event_handler_practical_subtasks,
289
- [practical_tasks, practical_subtasks, practical_subtasks_selected],
 
 
 
 
 
 
290
  [
291
  practical_subtasks_selected,
292
  settings_practical_tasks,
@@ -327,7 +483,10 @@ def setup_app_event_handlers(
327
  calculate_practical_task.click(
328
  fn=event_handler_calculate_practical_task_blocks,
329
  inputs=[
 
 
330
  files,
 
331
  practical_subtasks,
332
  pt_scores,
333
  dropdown_mbti,
@@ -380,7 +539,7 @@ def setup_app_event_handlers(
380
  )
381
  practical_task_sorted.select(
382
  event_handler_practical_task_sorted,
383
- [files, practical_task_sorted],
384
  [
385
  video_sorted_column,
386
  video_sorted,
 
9
 
10
  # Importing necessary components for the Gradio app
11
  from app.event_handlers.languages import event_handler_languages
12
+ from app.event_handlers.switching_modes import event_handler_switching_modes
13
  from app.event_handlers.files import (
14
  event_handler_files,
15
  event_handler_files_select,
16
  event_handler_files_delete,
17
  )
18
+ from app.event_handlers.webcam import event_handler_webcam
19
  from app.event_handlers.examples_blocks import event_handler_examples_blocks
20
  from app.event_handlers.clear_blocks import event_handler_clear_blocks
21
  from app.event_handlers.calculate_pt_scores_blocks import (
 
35
  step_1,
36
  notifications,
37
  files,
38
+ webcam,
39
+ switching_modes,
40
+ type_modes,
41
  video,
42
  examples,
43
  calculate_pt_scores,
 
106
  # Events
107
  languages.select(
108
  fn=event_handler_languages,
109
+ inputs=[
110
+ languages,
111
+ files,
112
+ video,
113
+ type_modes,
114
+ pt_scores,
115
+ csv_pt_scores,
116
+ practical_tasks,
117
+ practical_subtasks,
118
+ ],
119
  outputs=[
120
  description,
121
  step_1,
 
126
  tab3,
127
  tab4,
128
  files,
129
+ webcam,
130
+ switching_modes,
131
  video,
132
  examples,
133
  calculate_pt_scores,
 
136
  pt_scores,
137
  csv_pt_scores,
138
  step_2,
139
+ practical_tasks_column,
140
+ practical_tasks,
141
+ practical_subtasks,
142
+ ],
143
+ queue=True,
144
+ )
145
+ switching_modes.click(
146
+ fn=event_handler_switching_modes,
147
+ inputs=[languages, type_modes],
148
+ outputs=[
149
+ notifications,
150
+ files,
151
+ webcam,
152
+ switching_modes,
153
+ type_modes,
154
+ video,
155
+ calculate_pt_scores,
156
+ clear_app,
157
+ pt_scores,
158
+ csv_pt_scores,
159
+ step_2,
160
+ practical_tasks_column,
161
+ practical_tasks,
162
+ practical_subtasks,
163
+ practical_subtasks_selected,
164
+ settings_practical_tasks,
165
+ dropdown_mbti,
166
+ threshold_mbti,
167
+ threshold_professional_skills,
168
+ dropdown_professional_skills,
169
+ target_score_ope,
170
+ target_score_con,
171
+ target_score_ext,
172
+ target_score_agr,
173
+ target_score_nneu,
174
+ equal_coefficient,
175
+ number_priority,
176
+ number_importance_traits,
177
+ threshold_consumer_preferences,
178
+ dropdown_candidates,
179
+ number_openness,
180
+ number_conscientiousness,
181
+ number_extraversion,
182
+ number_agreeableness,
183
+ number_non_neuroticism,
184
+ sorted_videos,
185
+ sorted_videos_column,
186
+ practical_task_sorted,
187
+ csv_practical_task_sorted,
188
+ mbti_accordion,
189
+ mbti_description,
190
+ mbti_description_data,
191
+ video_sorted_column,
192
+ video_sorted,
193
+ metadata,
194
+ metadata_1,
195
+ name_row,
196
+ name_logo,
197
+ name,
198
+ surname_row,
199
+ surname_logo,
200
+ surname,
201
+ metadata_2,
202
+ email_row,
203
+ email_logo,
204
+ email,
205
+ phone_row,
206
+ phone_logo,
207
+ phone,
208
+ in_development,
209
  ],
210
  queue=True,
211
  )
 
227
  [video],
228
  queue=True,
229
  )
230
+ gr.on(
231
+ triggers=[webcam.upload, webcam.stop_recording],
232
+ fn=event_handler_webcam,
233
+ inputs=[languages, webcam, pt_scores],
234
+ outputs=[notifications, video, webcam, calculate_pt_scores, clear_app],
235
+ queue=True,
236
+ )
237
  gr.on(
238
  triggers=[calculate_pt_scores.click],
239
  fn=event_handler_calculate_pt_scores_blocks,
240
+ inputs=[languages, type_modes, files, video],
 
 
 
241
  outputs=[
242
  notifications,
243
  pt_scores,
 
298
  )
299
  examples.click(
300
  fn=event_handler_examples_blocks,
301
+ inputs=[languages],
302
  outputs=[
303
+ notifications,
304
  files,
305
+ webcam,
306
+ switching_modes,
307
+ type_modes,
308
+ video,
309
+ calculate_pt_scores,
310
+ clear_app,
311
+ pt_scores,
312
+ csv_pt_scores,
313
+ step_2,
314
+ practical_tasks_column,
315
+ practical_tasks,
316
+ practical_subtasks,
317
+ practical_subtasks_selected,
318
+ settings_practical_tasks,
319
+ dropdown_mbti,
320
+ threshold_mbti,
321
+ threshold_professional_skills,
322
+ dropdown_professional_skills,
323
+ target_score_ope,
324
+ target_score_con,
325
+ target_score_ext,
326
+ target_score_agr,
327
+ target_score_nneu,
328
+ equal_coefficient,
329
+ number_priority,
330
+ number_importance_traits,
331
+ threshold_consumer_preferences,
332
+ dropdown_candidates,
333
+ number_openness,
334
+ number_conscientiousness,
335
+ number_extraversion,
336
+ number_agreeableness,
337
+ number_non_neuroticism,
338
+ sorted_videos,
339
+ sorted_videos_column,
340
+ practical_task_sorted,
341
+ csv_practical_task_sorted,
342
+ mbti_accordion,
343
+ mbti_description,
344
+ mbti_description_data,
345
+ video_sorted_column,
346
+ video_sorted,
347
+ metadata,
348
+ metadata_1,
349
+ name_row,
350
+ name_logo,
351
+ name,
352
+ surname_row,
353
+ surname_logo,
354
+ surname,
355
+ metadata_2,
356
+ email_row,
357
+ email_logo,
358
+ email,
359
+ phone_row,
360
+ phone_logo,
361
+ phone,
362
+ in_development,
363
  ],
364
  queue=True,
365
  )
366
  clear_app.click(
367
  fn=event_handler_clear_blocks,
368
+ inputs=[languages, type_modes],
369
  outputs=[
370
  notifications,
371
  files,
372
+ webcam,
373
  video,
374
  calculate_pt_scores,
375
  clear_app,
 
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
  )
437
  practical_subtasks.change(
438
  event_handler_practical_subtasks,
439
+ [
440
+ languages,
441
+ type_modes,
442
+ practical_tasks,
443
+ practical_subtasks,
444
+ practical_subtasks_selected,
445
+ ],
446
  [
447
  practical_subtasks_selected,
448
  settings_practical_tasks,
 
483
  calculate_practical_task.click(
484
  fn=event_handler_calculate_practical_task_blocks,
485
  inputs=[
486
+ languages,
487
+ type_modes,
488
  files,
489
+ video,
490
  practical_subtasks,
491
  pt_scores,
492
  dropdown_mbti,
 
539
  )
540
  practical_task_sorted.select(
541
  event_handler_practical_task_sorted,
542
+ [type_modes, files, video, practical_task_sorted],
543
  [
544
  video_sorted_column,
545
  video_sorted,
app/event_handlers/examples_blocks.py CHANGED
@@ -6,25 +6,182 @@ License: MIT License
6
  """
7
 
8
  import re
 
9
  from pathlib import Path
10
 
11
  # Importing necessary components for the Gradio app
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
- # import hashlib
14
- # import time
15
 
16
- # for _ in range(6):
17
- # current_time = time.time()
18
- # time_bytes = str(current_time).encode("utf-8")
19
- # hash_object = hashlib.sha256(time_bytes)
20
- # hex_digest = hash_object.hexdigest()
21
- # print(hex_digest[:15])
22
 
 
23
 
24
- def event_handler_examples_blocks():
25
  videos_dir = Path("videos")
26
  video_files = sorted(
27
  (str(p) for p in videos_dir.glob("*.mp4")),
28
  key=lambda x: int(re.search(r"\d+", Path(x).stem).group()),
29
  )
30
- return video_files
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  """
7
 
8
  import re
9
+ import gradio as gr
10
  from pathlib import Path
11
 
12
  # Importing necessary components for the Gradio app
13
+ from app.config import config_data
14
+ from app.description_steps import STEP_2
15
+ from app.practical_tasks import supported_practical_tasks
16
+ from app.components import (
17
+ html_message,
18
+ files_create_ui,
19
+ video_create_ui,
20
+ button,
21
+ dataframe,
22
+ radio_create_ui,
23
+ number_create_ui,
24
+ dropdown_create_ui,
25
+ textbox_create_ui,
26
+ )
27
+ from app.utils import get_language_settings
28
 
 
 
29
 
30
+ def event_handler_examples_blocks(language):
31
+ lang_id, _ = get_language_settings(language)
 
 
 
 
32
 
33
+ first_practical_task = next(iter(supported_practical_tasks[lang_id]))
34
 
 
35
  videos_dir = Path("videos")
36
  video_files = sorted(
37
  (str(p) for p in videos_dir.glob("*.mp4")),
38
  key=lambda x: int(re.search(r"\d+", Path(x).stem).group()),
39
  )
40
+
41
+ files_ui = files_create_ui(
42
+ value=video_files,
43
+ label="{} ({})".format(
44
+ config_data.OtherMessages_VIDEO_FILES[lang_id],
45
+ ", ".join(config_data.Settings_SUPPORTED_VIDEO_EXT),
46
+ ),
47
+ file_types=[f".{ext}" for ext in config_data.Settings_SUPPORTED_VIDEO_EXT],
48
+ )
49
+ webcam = gr.Video(interactive=False, visible=False)
50
+ switching_modes = button(
51
+ config_data.OtherMessages_SWITCHEHG_MODES_ONLINE[lang_id],
52
+ True,
53
+ 1,
54
+ "./images/webcam.ico",
55
+ True,
56
+ "switching_modes",
57
+ )
58
+ type_modes_ui = gr.Radio(
59
+ choices=config_data.Settings_TYPE_MODES,
60
+ value=config_data.Settings_TYPE_MODES[0],
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,
73
+ type_modes_ui,
74
+ video_create_ui(
75
+ value=video_files[0],
76
+ label=config_data.OtherMessages_VIDEO_PLAYER[lang_id],
77
+ file_name=Path(Path(video_files[0]).name).name,
78
+ ),
79
+ button(
80
+ config_data.OtherMessages_CALCULATE_PT_SCORES[lang_id],
81
+ False,
82
+ 3,
83
+ "./images/calculate_pt_scores.ico",
84
+ True,
85
+ "calculate_oceanai",
86
+ ),
87
+ button(
88
+ config_data.OtherMessages_CLEAR_APP[lang_id],
89
+ False,
90
+ 1,
91
+ "./images/clear.ico",
92
+ True,
93
+ "clear_oceanai",
94
+ ),
95
+ dataframe(visible=False),
96
+ files_create_ui(
97
+ None,
98
+ "single",
99
+ [".csv"],
100
+ config_data.OtherMessages_EXPORT_PT_SCORES[lang_id],
101
+ True,
102
+ False,
103
+ False,
104
+ "csv-container",
105
+ ),
106
+ gr.HTML(value=STEP_2[lang_id], visible=False),
107
+ gr.Column(visible=False),
108
+ radio_create_ui(
109
+ first_practical_task,
110
+ config_data.Labels_PRACTICAL_TASKS_LABEL[lang_id],
111
+ list(map(str, supported_practical_tasks[lang_id].keys())),
112
+ config_data.InformationMessages_PRACTICAL_TASKS_INFO[lang_id],
113
+ True,
114
+ True,
115
+ ),
116
+ radio_create_ui(
117
+ supported_practical_tasks[lang_id][first_practical_task][0],
118
+ config_data.Labels_PRACTICAL_SUBTASKS_LABEL[lang_id],
119
+ supported_practical_tasks[lang_id][first_practical_task],
120
+ config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO[lang_id],
121
+ True,
122
+ True,
123
+ ),
124
+ gr.JSON(
125
+ value={
126
+ str(task): supported_practical_tasks[index].get(task, [None])[0]
127
+ for index in range(len(supported_practical_tasks))
128
+ for task in supported_practical_tasks[index].keys()
129
+ },
130
+ visible=False,
131
+ render=True,
132
+ ),
133
+ gr.Column(visible=False),
134
+ dropdown_create_ui(visible=False),
135
+ number_create_ui(visible=False),
136
+ number_create_ui(visible=False),
137
+ dropdown_create_ui(visible=False),
138
+ number_create_ui(visible=False),
139
+ number_create_ui(visible=False),
140
+ number_create_ui(visible=False),
141
+ number_create_ui(visible=False),
142
+ number_create_ui(visible=False),
143
+ number_create_ui(visible=False),
144
+ number_create_ui(visible=False),
145
+ number_create_ui(visible=False),
146
+ number_create_ui(visible=False),
147
+ dropdown_create_ui(visible=False),
148
+ number_create_ui(visible=False),
149
+ number_create_ui(visible=False),
150
+ number_create_ui(visible=False),
151
+ number_create_ui(visible=False),
152
+ number_create_ui(visible=False),
153
+ gr.Row(visible=False),
154
+ gr.Column(visible=False),
155
+ dataframe(visible=False),
156
+ files_create_ui(
157
+ None,
158
+ "single",
159
+ [".csv"],
160
+ config_data.OtherMessages_EXPORT_PS,
161
+ True,
162
+ False,
163
+ False,
164
+ "csv-container",
165
+ ),
166
+ gr.Accordion(visible=False),
167
+ gr.HTML(visible=False),
168
+ dataframe(visible=False),
169
+ gr.Column(visible=False),
170
+ video_create_ui(visible=False),
171
+ gr.Column(visible=False),
172
+ gr.Row(visible=False),
173
+ gr.Row(visible=False),
174
+ gr.Image(visible=False),
175
+ textbox_create_ui(visible=False),
176
+ gr.Row(visible=False),
177
+ gr.Image(visible=False),
178
+ textbox_create_ui(visible=False),
179
+ gr.Row(visible=False),
180
+ gr.Row(visible=False),
181
+ gr.Image(visible=False),
182
+ textbox_create_ui(visible=False),
183
+ gr.Row(visible=False),
184
+ gr.Image(visible=False),
185
+ textbox_create_ui(visible=False),
186
+ html_message(config_data.InformationMessages_NOTI_IN_DEV, False, False),
187
+ )
app/event_handlers/files.py CHANGED
@@ -1,7 +1,7 @@
1
  """
2
- File: search.py
3
  Author: Elena Ryumina and Dmitry Ryumin
4
- Description: Event handler for searching and filtering papers in the Gradio app.
5
  License: MIT License
6
  """
7
 
@@ -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,
 
1
  """
2
+ File: files.py
3
  Author: Elena Ryumina and Dmitry Ryumin
4
+ Description: Event handler for files.
5
  License: MIT License
6
  """
7
 
 
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
@@ -19,17 +19,71 @@ from app.components import (
19
  button,
20
  html_message,
21
  dataframe,
 
22
  )
23
  from app.utils import get_language_settings
 
24
 
25
 
26
- def event_handler_languages(languages, files, video, pt_scores, csv_pt_scores):
 
 
 
 
 
 
 
 
 
27
  lang_id, choices = get_language_settings(languages)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  if not video:
30
  video = video_create_ui(label=config_data.OtherMessages_VIDEO_PLAYER[lang_id])
31
  noti_videos = html_message(
32
- config_data.InformationMessages_NOTI_VIDEOS[lang_id], False
 
 
 
33
  )
34
  else:
35
  video = video_create_ui(
@@ -41,6 +95,7 @@ def event_handler_languages(languages, files, video, pt_scores, csv_pt_scores):
41
  config_data.OtherMessages_NOTI_CALCULATE[lang_id],
42
  True,
43
  False if pt_scores.shape[1] >= 7 else True,
 
44
  )
45
 
46
  csv_pt_scores = files_create_ui(
@@ -57,6 +112,10 @@ def event_handler_languages(languages, files, video, pt_scores, csv_pt_scores):
57
  value=STEP_2[lang_id], visible=True if pt_scores.shape[1] >= 7 else False
58
  )
59
 
 
 
 
 
60
  if pt_scores.shape[1] >= 7:
61
  pt_scores = dataframe(
62
  headers=(config_data.Dataframes_PT_SCORES[lang_id]),
@@ -66,6 +125,22 @@ def event_handler_languages(languages, files, video, pt_scores, csv_pt_scores):
66
  else:
67
  pt_scores = dataframe(visible=False)
68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  return (
70
  gr.Markdown(value=DESCRIPTIONS[lang_id]),
71
  gr.HTML(value=STEP_1[lang_id]),
@@ -85,14 +160,9 @@ def event_handler_languages(languages, files, video, pt_scores, csv_pt_scores):
85
  gr.Tab(config_data.Labels_ABOUT_APP_LABEL[lang_id]),
86
  gr.Tab(config_data.Labels_ABOUT_AUTHORS_LABEL[lang_id]),
87
  gr.Tab(config_data.Labels_REQUIREMENTS_LABEL[lang_id]),
88
- files_create_ui(
89
- value=files,
90
- label="{} ({})".format(
91
- config_data.OtherMessages_VIDEO_FILES[lang_id],
92
- ", ".join(config_data.Settings_SUPPORTED_VIDEO_EXT),
93
- ),
94
- file_types=[f".{ext}" for ext in config_data.Settings_SUPPORTED_VIDEO_EXT],
95
- ),
96
  video,
97
  button(
98
  config_data.OtherMessages_EXAMPLES_APP[lang_id],
@@ -122,4 +192,21 @@ def event_handler_languages(languages, files, video, pt_scores, csv_pt_scores):
122
  pt_scores,
123
  csv_pt_scores,
124
  step_2,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  )
 
19
  button,
20
  html_message,
21
  dataframe,
22
+ radio_create_ui,
23
  )
24
  from app.utils import get_language_settings
25
+ from app.practical_tasks import supported_practical_tasks
26
 
27
 
28
+ def event_handler_languages(
29
+ languages,
30
+ files,
31
+ video,
32
+ type_modes,
33
+ pt_scores,
34
+ csv_pt_scores,
35
+ practical_tasks,
36
+ practical_subtasks,
37
+ ):
38
  lang_id, choices = get_language_settings(languages)
39
+ lang_id_inverse = {0: 1, 1: 0}.get(lang_id, None)
40
+
41
+ if type_modes == config_data.Settings_TYPE_MODES[0]:
42
+ files_ui = files_create_ui(
43
+ label="{} ({})".format(
44
+ config_data.OtherMessages_VIDEO_FILES[
45
+ config_data.AppSettings_DEFAULT_LANG_ID
46
+ ],
47
+ ", ".join(config_data.Settings_SUPPORTED_VIDEO_EXT),
48
+ ),
49
+ file_types=[f".{ext}" for ext in config_data.Settings_SUPPORTED_VIDEO_EXT],
50
+ )
51
+ webcam = gr.Video(interactive=False, visible=False)
52
+ switching_modes = button(
53
+ config_data.OtherMessages_SWITCHEHG_MODES_ONLINE[lang_id],
54
+ True,
55
+ 1,
56
+ "./images/webcam.ico",
57
+ True,
58
+ "switching_modes",
59
+ )
60
+ elif type_modes == config_data.Settings_TYPE_MODES[1]:
61
+ files_ui = files_create_ui(
62
+ label="{} ({})".format(
63
+ config_data.OtherMessages_VIDEO_FILES[lang_id],
64
+ ", ".join(config_data.Settings_SUPPORTED_VIDEO_EXT),
65
+ ),
66
+ file_types=[f".{ext}" for ext in config_data.Settings_SUPPORTED_VIDEO_EXT],
67
+ interactive=False,
68
+ visible=False,
69
+ )
70
+ webcam = gr.Video(interactive=True, visible=True)
71
+ switching_modes = button(
72
+ config_data.OtherMessages_SWITCHEHG_MODES_OFFLINE[lang_id],
73
+ True,
74
+ 1,
75
+ "./images/videos.ico",
76
+ True,
77
+ "switching_modes",
78
+ )
79
 
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(
 
112
  value=STEP_2[lang_id], visible=True if pt_scores.shape[1] >= 7 else False
113
  )
114
 
115
+ practical_tasks_column = gr.Column(
116
+ visible=True if pt_scores.shape[1] >= 7 else False
117
+ )
118
+
119
  if pt_scores.shape[1] >= 7:
120
  pt_scores = dataframe(
121
  headers=(config_data.Dataframes_PT_SCORES[lang_id]),
 
125
  else:
126
  pt_scores = dataframe(visible=False)
127
 
128
+ current_lang_tasks = list(map(str, supported_practical_tasks[lang_id].keys()))
129
+ inverse_lang_tasks = list(
130
+ map(str, supported_practical_tasks[lang_id_inverse].keys())
131
+ )
132
+
133
+ if practical_tasks in inverse_lang_tasks:
134
+ practical_task = current_lang_tasks[inverse_lang_tasks.index(practical_tasks)]
135
+ else:
136
+ practical_task = next(iter(supported_practical_tasks[lang_id]))
137
+
138
+ print(current_lang_tasks, "\n")
139
+ print(inverse_lang_tasks, "\n")
140
+ print(practical_tasks, "\n")
141
+ print(supported_practical_tasks, "\n")
142
+ print(practical_subtasks, "\n")
143
+
144
  return (
145
  gr.Markdown(value=DESCRIPTIONS[lang_id]),
146
  gr.HTML(value=STEP_1[lang_id]),
 
160
  gr.Tab(config_data.Labels_ABOUT_APP_LABEL[lang_id]),
161
  gr.Tab(config_data.Labels_ABOUT_AUTHORS_LABEL[lang_id]),
162
  gr.Tab(config_data.Labels_REQUIREMENTS_LABEL[lang_id]),
163
+ files_ui,
164
+ webcam,
165
+ switching_modes,
 
 
 
 
 
166
  video,
167
  button(
168
  config_data.OtherMessages_EXAMPLES_APP[lang_id],
 
192
  pt_scores,
193
  csv_pt_scores,
194
  step_2,
195
+ practical_tasks_column,
196
+ radio_create_ui(
197
+ practical_task,
198
+ config_data.Labels_PRACTICAL_TASKS_LABEL[lang_id],
199
+ current_lang_tasks,
200
+ config_data.InformationMessages_PRACTICAL_TASKS_INFO[lang_id],
201
+ True,
202
+ True,
203
+ ),
204
+ radio_create_ui(
205
+ supported_practical_tasks[lang_id][practical_task][0],
206
+ config_data.Labels_PRACTICAL_SUBTASKS_LABEL[lang_id],
207
+ supported_practical_tasks[lang_id][practical_task],
208
+ config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO[lang_id],
209
+ True,
210
+ True,
211
+ ),
212
  )
app/event_handlers/practical_subtasks.py CHANGED
@@ -9,25 +9,36 @@ import gradio as gr
9
 
10
  # Importing necessary components for the Gradio app
11
  from app.config import config_data
12
- from app.utils import read_csv_file, extract_profession_weights
 
13
  from app.components import number_create_ui, dropdown_create_ui
14
 
15
 
16
  def event_handler_practical_subtasks(
17
- practical_tasks, practical_subtasks, practical_subtasks_selected
 
 
 
 
18
  ):
 
 
19
  practical_subtasks_selected[practical_tasks] = practical_subtasks
20
 
 
 
 
 
21
  if practical_subtasks.lower() == "16 personality types of mbti":
22
  return (
23
  practical_subtasks_selected,
24
- gr.Column(visible=True),
25
  dropdown_create_ui(
26
  label=f"Potential candidates by Personality Type of MBTI ({len(config_data.Settings_DROPDOWN_MBTI)})",
27
  info=config_data.InformationMessages_DROPDOWN_MBTI_INFO,
28
  choices=config_data.Settings_DROPDOWN_MBTI,
29
  value=config_data.Settings_DROPDOWN_MBTI[0],
30
- visible=True,
31
  elem_classes="dropdown-container",
32
  ),
33
  number_create_ui(
@@ -39,7 +50,7 @@ def event_handler_practical_subtasks(
39
  info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(0, 1.0),
40
  show_label=True,
41
  interactive=True,
42
- visible=True,
43
  render=True,
44
  elem_classes="number-container",
45
  ),
@@ -62,17 +73,9 @@ def event_handler_practical_subtasks(
62
  number_create_ui(visible=False),
63
  )
64
  elif practical_subtasks.lower() == "professional groups":
65
- df_traits_priority_for_professions = read_csv_file(
66
- config_data.Links_PROFESSIONS
67
- )
68
- weights_professions, interactive_professions = extract_profession_weights(
69
- df_traits_priority_for_professions,
70
- config_data.Settings_DROPDOWN_CANDIDATES[0],
71
- )
72
-
73
  return (
74
  practical_subtasks_selected,
75
- gr.Column(visible=True),
76
  dropdown_create_ui(visible=False),
77
  number_create_ui(visible=False),
78
  number_create_ui(visible=False),
@@ -91,7 +94,7 @@ def event_handler_practical_subtasks(
91
  info=config_data.InformationMessages_DROPDOWN_CANDIDATES_INFO,
92
  choices=config_data.Settings_DROPDOWN_CANDIDATES,
93
  value=config_data.Settings_DROPDOWN_CANDIDATES[0],
94
- visible=True,
95
  elem_classes="dropdown-container",
96
  ),
97
  number_create_ui(
@@ -105,7 +108,7 @@ def event_handler_practical_subtasks(
105
  ),
106
  show_label=True,
107
  interactive=interactive_professions,
108
- visible=True,
109
  render=True,
110
  elem_classes="number-container",
111
  ),
@@ -120,7 +123,7 @@ def event_handler_practical_subtasks(
120
  ),
121
  show_label=True,
122
  interactive=interactive_professions,
123
- visible=True,
124
  render=True,
125
  elem_classes="number-container",
126
  ),
@@ -135,7 +138,7 @@ def event_handler_practical_subtasks(
135
  ),
136
  show_label=True,
137
  interactive=interactive_professions,
138
- visible=True,
139
  render=True,
140
  elem_classes="number-container",
141
  ),
@@ -150,7 +153,7 @@ def event_handler_practical_subtasks(
150
  ),
151
  show_label=True,
152
  interactive=interactive_professions,
153
- visible=True,
154
  render=True,
155
  elem_classes="number-container",
156
  ),
@@ -165,7 +168,7 @@ def event_handler_practical_subtasks(
165
  ),
166
  show_label=True,
167
  interactive=interactive_professions,
168
- visible=True,
169
  render=True,
170
  elem_classes="number-container",
171
  ),
@@ -173,7 +176,7 @@ def event_handler_practical_subtasks(
173
  elif practical_subtasks.lower() == "professional skills":
174
  return (
175
  practical_subtasks_selected,
176
- gr.Column(visible=True),
177
  dropdown_create_ui(visible=False),
178
  number_create_ui(visible=False),
179
  number_create_ui(
@@ -185,7 +188,7 @@ def event_handler_practical_subtasks(
185
  info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(0, 1.0),
186
  show_label=True,
187
  interactive=True,
188
- visible=True,
189
  render=True,
190
  elem_classes="number-container",
191
  ),
@@ -194,7 +197,7 @@ def event_handler_practical_subtasks(
194
  info=config_data.InformationMessages_DROPDOWN_PROFESSIONAL_SKILLS_INFO,
195
  choices=config_data.Settings_DROPDOWN_PROFESSIONAL_SKILLS,
196
  value=config_data.Settings_DROPDOWN_PROFESSIONAL_SKILLS[0],
197
- visible=True,
198
  elem_classes="dropdown-container",
199
  ),
200
  number_create_ui(visible=False),
@@ -219,7 +222,7 @@ def event_handler_practical_subtasks(
219
  ):
220
  return (
221
  practical_subtasks_selected,
222
- gr.Column(visible=True),
223
  dropdown_create_ui(visible=False),
224
  number_create_ui(visible=False),
225
  number_create_ui(visible=False),
@@ -233,7 +236,7 @@ def event_handler_practical_subtasks(
233
  info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(0, 1.0),
234
  show_label=True,
235
  interactive=True,
236
- visible=True,
237
  render=True,
238
  elem_classes="number-container",
239
  ),
@@ -246,7 +249,7 @@ def event_handler_practical_subtasks(
246
  info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(0, 1.0),
247
  show_label=True,
248
  interactive=True,
249
- visible=True,
250
  render=True,
251
  elem_classes="number-container",
252
  ),
@@ -259,7 +262,7 @@ def event_handler_practical_subtasks(
259
  info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(0, 1.0),
260
  show_label=True,
261
  interactive=True,
262
- visible=True,
263
  render=True,
264
  elem_classes="number-container",
265
  ),
@@ -272,7 +275,7 @@ def event_handler_practical_subtasks(
272
  info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(0, 1.0),
273
  show_label=True,
274
  interactive=True,
275
- visible=True,
276
  render=True,
277
  elem_classes="number-container",
278
  ),
@@ -285,7 +288,7 @@ def event_handler_practical_subtasks(
285
  info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(0, 1.0),
286
  show_label=True,
287
  interactive=True,
288
- visible=True,
289
  render=True,
290
  elem_classes="number-container",
291
  ),
@@ -298,7 +301,7 @@ def event_handler_practical_subtasks(
298
  info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(0, 1.0),
299
  show_label=True,
300
  interactive=True,
301
- visible=True,
302
  render=True,
303
  elem_classes="number-container",
304
  ),
 
9
 
10
  # Importing necessary components for the Gradio app
11
  from app.config import config_data
12
+ from app.utils import read_csv_file, get_language_settings
13
+ from app.data_init import weights_professions, interactive_professions
14
  from app.components import number_create_ui, dropdown_create_ui
15
 
16
 
17
  def event_handler_practical_subtasks(
18
+ language,
19
+ type_modes,
20
+ practical_tasks,
21
+ practical_subtasks,
22
+ practical_subtasks_selected,
23
  ):
24
+ lang_id, _ = get_language_settings(language)
25
+
26
  practical_subtasks_selected[practical_tasks] = practical_subtasks
27
 
28
+ visible_subtasks = (
29
+ True if type_modes == config_data.Settings_TYPE_MODES[0] else False
30
+ )
31
+
32
  if practical_subtasks.lower() == "16 personality types of mbti":
33
  return (
34
  practical_subtasks_selected,
35
+ gr.Column(visible=visible_subtasks),
36
  dropdown_create_ui(
37
  label=f"Potential candidates by Personality Type of MBTI ({len(config_data.Settings_DROPDOWN_MBTI)})",
38
  info=config_data.InformationMessages_DROPDOWN_MBTI_INFO,
39
  choices=config_data.Settings_DROPDOWN_MBTI,
40
  value=config_data.Settings_DROPDOWN_MBTI[0],
41
+ visible=visible_subtasks,
42
  elem_classes="dropdown-container",
43
  ),
44
  number_create_ui(
 
50
  info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(0, 1.0),
51
  show_label=True,
52
  interactive=True,
53
+ visible=visible_subtasks,
54
  render=True,
55
  elem_classes="number-container",
56
  ),
 
73
  number_create_ui(visible=False),
74
  )
75
  elif practical_subtasks.lower() == "professional groups":
 
 
 
 
 
 
 
 
76
  return (
77
  practical_subtasks_selected,
78
+ gr.Column(visible=visible_subtasks),
79
  dropdown_create_ui(visible=False),
80
  number_create_ui(visible=False),
81
  number_create_ui(visible=False),
 
94
  info=config_data.InformationMessages_DROPDOWN_CANDIDATES_INFO,
95
  choices=config_data.Settings_DROPDOWN_CANDIDATES,
96
  value=config_data.Settings_DROPDOWN_CANDIDATES[0],
97
+ visible=visible_subtasks,
98
  elem_classes="dropdown-container",
99
  ),
100
  number_create_ui(
 
108
  ),
109
  show_label=True,
110
  interactive=interactive_professions,
111
+ visible=visible_subtasks,
112
  render=True,
113
  elem_classes="number-container",
114
  ),
 
123
  ),
124
  show_label=True,
125
  interactive=interactive_professions,
126
+ visible=visible_subtasks,
127
  render=True,
128
  elem_classes="number-container",
129
  ),
 
138
  ),
139
  show_label=True,
140
  interactive=interactive_professions,
141
+ visible=visible_subtasks,
142
  render=True,
143
  elem_classes="number-container",
144
  ),
 
153
  ),
154
  show_label=True,
155
  interactive=interactive_professions,
156
+ visible=visible_subtasks,
157
  render=True,
158
  elem_classes="number-container",
159
  ),
 
168
  ),
169
  show_label=True,
170
  interactive=interactive_professions,
171
+ visible=visible_subtasks,
172
  render=True,
173
  elem_classes="number-container",
174
  ),
 
176
  elif practical_subtasks.lower() == "professional skills":
177
  return (
178
  practical_subtasks_selected,
179
+ gr.Column(visible=visible_subtasks),
180
  dropdown_create_ui(visible=False),
181
  number_create_ui(visible=False),
182
  number_create_ui(
 
188
  info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(0, 1.0),
189
  show_label=True,
190
  interactive=True,
191
+ visible=visible_subtasks,
192
  render=True,
193
  elem_classes="number-container",
194
  ),
 
197
  info=config_data.InformationMessages_DROPDOWN_PROFESSIONAL_SKILLS_INFO,
198
  choices=config_data.Settings_DROPDOWN_PROFESSIONAL_SKILLS,
199
  value=config_data.Settings_DROPDOWN_PROFESSIONAL_SKILLS[0],
200
+ visible=visible_subtasks,
201
  elem_classes="dropdown-container",
202
  ),
203
  number_create_ui(visible=False),
 
222
  ):
223
  return (
224
  practical_subtasks_selected,
225
+ gr.Column(visible=visible_subtasks),
226
  dropdown_create_ui(visible=False),
227
  number_create_ui(visible=False),
228
  number_create_ui(visible=False),
 
236
  info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(0, 1.0),
237
  show_label=True,
238
  interactive=True,
239
+ visible=visible_subtasks,
240
  render=True,
241
  elem_classes="number-container",
242
  ),
 
249
  info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(0, 1.0),
250
  show_label=True,
251
  interactive=True,
252
+ visible=visible_subtasks,
253
  render=True,
254
  elem_classes="number-container",
255
  ),
 
262
  info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(0, 1.0),
263
  show_label=True,
264
  interactive=True,
265
+ visible=visible_subtasks,
266
  render=True,
267
  elem_classes="number-container",
268
  ),
 
275
  info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(0, 1.0),
276
  show_label=True,
277
  interactive=True,
278
+ visible=visible_subtasks,
279
  render=True,
280
  elem_classes="number-container",
281
  ),
 
288
  info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(0, 1.0),
289
  show_label=True,
290
  interactive=True,
291
+ visible=visible_subtasks,
292
  render=True,
293
  elem_classes="number-container",
294
  ),
 
301
  info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(0, 1.0),
302
  show_label=True,
303
  interactive=True,
304
+ visible=visible_subtasks,
305
  render=True,
306
  elem_classes="number-container",
307
  ),
app/event_handlers/practical_task_sorted.py CHANGED
@@ -15,16 +15,21 @@ from app.components import video_create_ui, textbox_create_ui
15
 
16
 
17
  def event_handler_practical_task_sorted(
18
- files, practical_task_sorted, evt_data: gr.SelectData
19
  ):
20
- person_id = (
21
- int(
22
- practical_task_sorted.iloc[evt_data.index[0]][
23
- config_data.Dataframes_PT_SCORES[0][0]
24
- ]
 
 
 
25
  )
26
- - 1
27
- )
 
 
28
 
29
  if evt_data.index[0] == 0:
30
  label = "Best"
 
15
 
16
 
17
  def event_handler_practical_task_sorted(
18
+ type_modes, files, video, practical_task_sorted, evt_data: gr.SelectData
19
  ):
20
+ if type_modes == config_data.Settings_TYPE_MODES[0]:
21
+ person_id = (
22
+ int(
23
+ practical_task_sorted.iloc[evt_data.index[0]][
24
+ config_data.Dataframes_PT_SCORES[0][0]
25
+ ]
26
+ )
27
+ - 1
28
  )
29
+ elif type_modes == config_data.Settings_TYPE_MODES[1]:
30
+ files = [video]
31
+
32
+ person_id = 0
33
 
34
  if evt_data.index[0] == 0:
35
  label = "Best"
app/event_handlers/practical_tasks.py CHANGED
@@ -9,14 +9,32 @@ License: MIT License
9
  from app.config import config_data
10
  from app.practical_tasks import supported_practical_tasks
11
  from app.components import radio_create_ui
 
12
 
13
 
14
- def event_handler_practical_tasks(practical_tasks, practical_subtasks_selected):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  return radio_create_ui(
16
  practical_subtasks_selected[practical_tasks],
17
- config_data.Labels_PRACTICAL_SUBTASKS_LABEL,
18
- supported_practical_tasks[practical_tasks],
19
- config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO,
20
  True,
21
  True,
22
  )
 
9
  from app.config import config_data
10
  from app.practical_tasks import supported_practical_tasks
11
  from app.components import radio_create_ui
12
+ from app.utils import get_language_settings
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,
40
  )
app/event_handlers/switching_modes.py ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ File: switching_modes.py
3
+ Author: Elena Ryumina and Dmitry Ryumin
4
+ Description: Event handler for switching modes.
5
+ License: MIT License
6
+ """
7
+
8
+ import gradio as gr
9
+
10
+ # Importing necessary components for the Gradio app
11
+ from app.config import config_data
12
+ from app.description_steps import STEP_2
13
+ from app.practical_tasks import supported_practical_tasks
14
+ from app.components import (
15
+ html_message,
16
+ files_create_ui,
17
+ video_create_ui,
18
+ button,
19
+ dataframe,
20
+ radio_create_ui,
21
+ number_create_ui,
22
+ dropdown_create_ui,
23
+ textbox_create_ui,
24
+ )
25
+ from app.utils import get_language_settings
26
+
27
+
28
+ def event_handler_switching_modes(language, type_modes):
29
+ lang_id, _ = get_language_settings(language)
30
+
31
+ first_practical_task = next(iter(supported_practical_tasks[lang_id]))
32
+
33
+ if type_modes == config_data.Settings_TYPE_MODES[0]:
34
+ files_ui = files_create_ui(
35
+ label="{} ({})".format(
36
+ config_data.OtherMessages_VIDEO_FILES[lang_id],
37
+ ", ".join(config_data.Settings_SUPPORTED_VIDEO_EXT),
38
+ ),
39
+ file_types=[f".{ext}" for ext in config_data.Settings_SUPPORTED_VIDEO_EXT],
40
+ interactive=False,
41
+ visible=False,
42
+ )
43
+ webcam = gr.Video(interactive=True, visible=True)
44
+ switching_modes = button(
45
+ config_data.OtherMessages_SWITCHEHG_MODES_OFFLINE[lang_id],
46
+ True,
47
+ 1,
48
+ "./images/videos.ico",
49
+ True,
50
+ "switching_modes",
51
+ )
52
+ type_modes_ui = gr.Radio(
53
+ choices=config_data.Settings_TYPE_MODES,
54
+ value=config_data.Settings_TYPE_MODES[1],
55
+ )
56
+ elif type_modes == config_data.Settings_TYPE_MODES[1]:
57
+ files_ui = files_create_ui(
58
+ label="{} ({})".format(
59
+ config_data.OtherMessages_VIDEO_FILES[lang_id],
60
+ ", ".join(config_data.Settings_SUPPORTED_VIDEO_EXT),
61
+ ),
62
+ file_types=[f".{ext}" for ext in config_data.Settings_SUPPORTED_VIDEO_EXT],
63
+ )
64
+ webcam = gr.Video(interactive=False, visible=False)
65
+ switching_modes = button(
66
+ config_data.OtherMessages_SWITCHEHG_MODES_ONLINE[lang_id],
67
+ True,
68
+ 1,
69
+ "./images/webcam.ico",
70
+ True,
71
+ "switching_modes",
72
+ )
73
+ type_modes_ui = gr.Radio(
74
+ choices=config_data.Settings_TYPE_MODES,
75
+ value=config_data.Settings_TYPE_MODES[0],
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,
88
+ type_modes_ui,
89
+ video_create_ui(),
90
+ button(
91
+ config_data.OtherMessages_CALCULATE_PT_SCORES[lang_id],
92
+ False,
93
+ 3,
94
+ "./images/calculate_pt_scores.ico",
95
+ True,
96
+ "calculate_oceanai",
97
+ ),
98
+ button(
99
+ config_data.OtherMessages_CLEAR_APP[lang_id],
100
+ False,
101
+ 1,
102
+ "./images/clear.ico",
103
+ True,
104
+ "clear_oceanai",
105
+ ),
106
+ dataframe(visible=False),
107
+ files_create_ui(
108
+ None,
109
+ "single",
110
+ [".csv"],
111
+ config_data.OtherMessages_EXPORT_PT_SCORES[lang_id],
112
+ True,
113
+ False,
114
+ False,
115
+ "csv-container",
116
+ ),
117
+ gr.HTML(value=STEP_2[lang_id], visible=False),
118
+ gr.Column(visible=False),
119
+ radio_create_ui(
120
+ first_practical_task,
121
+ config_data.Labels_PRACTICAL_TASKS_LABEL[lang_id],
122
+ list(map(str, supported_practical_tasks[lang_id].keys())),
123
+ config_data.InformationMessages_PRACTICAL_TASKS_INFO[lang_id],
124
+ True,
125
+ True,
126
+ ),
127
+ radio_create_ui(
128
+ supported_practical_tasks[lang_id][first_practical_task][0],
129
+ config_data.Labels_PRACTICAL_SUBTASKS_LABEL[lang_id],
130
+ supported_practical_tasks[lang_id][first_practical_task],
131
+ config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO[lang_id],
132
+ True,
133
+ True,
134
+ ),
135
+ gr.JSON(
136
+ value={
137
+ str(task): supported_practical_tasks[index].get(task, [None])[0]
138
+ for index in range(len(supported_practical_tasks))
139
+ for task in supported_practical_tasks[index].keys()
140
+ },
141
+ visible=False,
142
+ render=True,
143
+ ),
144
+ gr.Column(visible=False),
145
+ dropdown_create_ui(visible=False),
146
+ number_create_ui(visible=False),
147
+ number_create_ui(visible=False),
148
+ dropdown_create_ui(visible=False),
149
+ number_create_ui(visible=False),
150
+ number_create_ui(visible=False),
151
+ number_create_ui(visible=False),
152
+ number_create_ui(visible=False),
153
+ number_create_ui(visible=False),
154
+ number_create_ui(visible=False),
155
+ number_create_ui(visible=False),
156
+ number_create_ui(visible=False),
157
+ number_create_ui(visible=False),
158
+ dropdown_create_ui(visible=False),
159
+ number_create_ui(visible=False),
160
+ number_create_ui(visible=False),
161
+ number_create_ui(visible=False),
162
+ number_create_ui(visible=False),
163
+ number_create_ui(visible=False),
164
+ gr.Row(visible=False),
165
+ gr.Column(visible=False),
166
+ dataframe(visible=False),
167
+ files_create_ui(
168
+ None,
169
+ "single",
170
+ [".csv"],
171
+ config_data.OtherMessages_EXPORT_PS,
172
+ True,
173
+ False,
174
+ False,
175
+ "csv-container",
176
+ ),
177
+ gr.Accordion(visible=False),
178
+ gr.HTML(visible=False),
179
+ dataframe(visible=False),
180
+ gr.Column(visible=False),
181
+ video_create_ui(visible=False),
182
+ gr.Column(visible=False),
183
+ gr.Row(visible=False),
184
+ gr.Row(visible=False),
185
+ gr.Image(visible=False),
186
+ textbox_create_ui(visible=False),
187
+ gr.Row(visible=False),
188
+ gr.Image(visible=False),
189
+ textbox_create_ui(visible=False),
190
+ gr.Row(visible=False),
191
+ gr.Row(visible=False),
192
+ gr.Image(visible=False),
193
+ textbox_create_ui(visible=False),
194
+ gr.Row(visible=False),
195
+ gr.Image(visible=False),
196
+ textbox_create_ui(visible=False),
197
+ html_message(config_data.InformationMessages_NOTI_IN_DEV, False, False),
198
+ )
app/event_handlers/webcam.py ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ File: webcam.py
3
+ Author: Elena Ryumina and Dmitry Ryumin
4
+ Description: Event handler for webcam.
5
+ License: MIT License
6
+ """
7
+
8
+ import gradio as gr
9
+ from pathlib import Path
10
+
11
+ # Importing necessary components for the Gradio app
12
+ from app.config import config_data
13
+ from app.components import html_message, video_create_ui, button
14
+ from app.utils import get_language_settings, webm2mp4
15
+
16
+
17
+ def event_handler_webcam(language, webcam, pt_scores):
18
+ lang_id, _ = get_language_settings(language)
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(
31
+ config_data.OtherMessages_CALCULATE_PT_SCORES[lang_id],
32
+ False,
33
+ 3,
34
+ "./images/calculate_pt_scores.ico",
35
+ True,
36
+ "calculate_oceanai",
37
+ ),
38
+ button(
39
+ config_data.OtherMessages_CLEAR_APP[lang_id],
40
+ False,
41
+ 1,
42
+ "./images/clear.ico",
43
+ True,
44
+ "clear_oceanai",
45
+ ),
46
+ )
47
+
48
+ if webcam.split(".")[-1] == "webm":
49
+ webcam = webm2mp4(webcam)
50
+
51
+ return (
52
+ html_message(
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,
60
+ label=config_data.OtherMessages_VIDEO_PLAYER[lang_id],
61
+ file_name=Path(Path(webcam).name).name,
62
+ ),
63
+ gr.Video(value=None),
64
+ button(
65
+ config_data.OtherMessages_CALCULATE_PT_SCORES[lang_id],
66
+ True,
67
+ 3,
68
+ "./images/calculate_pt_scores.ico",
69
+ True,
70
+ "calculate_oceanai",
71
+ ),
72
+ button(
73
+ config_data.OtherMessages_CLEAR_APP[lang_id],
74
+ True,
75
+ 1,
76
+ "./images/clear.ico",
77
+ True,
78
+ "clear_oceanai",
79
+ ),
80
+ )
app/port.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ File: port.py
3
+ Author: Elena Ryumina and Dmitry Ryumin
4
+ Description: Utility functions to check and free ports by terminating processes holding them.
5
+ License: MIT License
6
+ """
7
+
8
+ import socket
9
+ import psutil
10
+ from typing import Iterable, Union
11
+
12
+
13
+ def is_port_in_use(host: str, port: int) -> bool:
14
+ try:
15
+ with socket.create_connection((host, port), timeout=1):
16
+ return True
17
+ except (ConnectionRefusedError, OSError):
18
+ return False
19
+
20
+
21
+ def free_ports(ports: Union[int, Iterable[int]]) -> None:
22
+ ports_to_free = {ports} if isinstance(ports, int) else set(ports)
23
+
24
+ for proc in psutil.process_iter(attrs=["pid", "name"]):
25
+ try:
26
+ connections = proc.net_connections(kind="inet")
27
+ for conn in connections:
28
+ if conn.laddr.port in ports_to_free:
29
+ proc.terminate()
30
+ proc.wait()
31
+ ports_to_free.discard(conn.laddr.port)
32
+ if not ports_to_free:
33
+ return
34
+ except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
35
+ continue
app/practical_tasks.py CHANGED
@@ -11,17 +11,27 @@ from typing import Dict, List
11
  # Importing necessary components for the Gradio app
12
 
13
 
14
- def load_practical_tasks_data(file_path: str) -> List:
15
- with open(file_path, "r") as file:
16
- return yaml.safe_load(file) or []
17
 
 
 
 
 
18
 
19
- def transform_practical_tasks_data(data: List) -> Dict:
20
- output_dict = {item["task"]: item["subtasks"] for item in data}
21
 
22
- return output_dict
23
 
 
 
24
 
25
- yaml_file_path = "./practical_tasks.yaml"
26
- practical_tasks_data = load_practical_tasks_data(yaml_file_path)
 
 
 
 
 
 
 
27
  supported_practical_tasks = transform_practical_tasks_data(practical_tasks_data)
 
11
  # Importing necessary components for the Gradio app
12
 
13
 
14
+ def load_practical_tasks_data(file_paths: List[str]) -> List[Dict]:
15
+ all_tasks_data = []
 
16
 
17
+ for file_path in file_paths:
18
+ with open(file_path, "r") as file:
19
+ data = yaml.safe_load(file) or []
20
+ all_tasks_data.append(data)
21
 
22
+ return all_tasks_data
 
23
 
 
24
 
25
+ def transform_practical_tasks_data(data: List[Dict]) -> List[Dict]:
26
+ output_list = []
27
 
28
+ for task_data in data:
29
+ output_dict = {item["task"]: item["subtasks"] for item in task_data}
30
+ output_list.append(output_dict)
31
+
32
+ return output_list
33
+
34
+
35
+ yaml_file_paths = ["./practical_tasks_en.yaml", "./practical_tasks_ru.yaml"]
36
+ practical_tasks_data = load_practical_tasks_data(yaml_file_paths)
37
  supported_practical_tasks = transform_practical_tasks_data(practical_tasks_data)
app/tabs.py CHANGED
@@ -13,10 +13,11 @@ from app.description_steps import STEP_1, STEP_2
13
  from app.mbti_description import MBTI_DESCRIPTION, MBTI_DATA
14
  from app.app import APP
15
  from app.authors import AUTHORS
 
16
  from app.requirements_app import read_requirements_to_df
17
  from app.config import config_data
18
  from app.practical_tasks import supported_practical_tasks
19
- from app.utils import read_csv_file, extract_profession_weights
20
  from app.components import (
21
  html_message,
22
  files_create_ui,
@@ -37,16 +38,59 @@ def app_tab():
37
 
38
  step_1 = gr.HTML(value=STEP_1[config_data.AppSettings_DEFAULT_LANG_ID])
39
 
40
- with gr.Row():
41
- files = files_create_ui(
42
- label="{} ({})".format(
43
- config_data.OtherMessages_VIDEO_FILES[
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  config_data.AppSettings_DEFAULT_LANG_ID
45
  ],
46
- ", ".join(config_data.Settings_SUPPORTED_VIDEO_EXT),
47
- ),
48
- file_types=[f".{ext}" for ext in config_data.Settings_SUPPORTED_VIDEO_EXT],
49
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
  video = video_create_ui()
52
 
@@ -87,6 +131,7 @@ def app_tab():
87
  config_data.AppSettings_DEFAULT_LANG_ID
88
  ],
89
  False,
 
90
  )
91
 
92
  pt_scores = dataframe(visible=False)
@@ -108,23 +153,42 @@ def app_tab():
108
  value=STEP_2[config_data.AppSettings_DEFAULT_LANG_ID], visible=False
109
  )
110
 
111
- first_practical_task = next(iter(supported_practical_tasks))
 
 
112
 
113
  with gr.Column(scale=1, visible=False, render=True) as practical_tasks_column:
114
  practical_tasks = radio_create_ui(
115
  first_practical_task,
116
  config_data.Labels_PRACTICAL_TASKS_LABEL,
117
- list(map(str, supported_practical_tasks.keys())),
118
- config_data.InformationMessages_PRACTICAL_TASKS_INFO,
 
 
 
 
 
 
 
 
 
119
  True,
120
  True,
121
  )
122
 
123
  practical_subtasks = radio_create_ui(
124
- supported_practical_tasks[first_practical_task][0],
125
- config_data.Labels_PRACTICAL_SUBTASKS_LABEL,
126
- supported_practical_tasks[first_practical_task],
127
- config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO,
 
 
 
 
 
 
 
 
128
  True,
129
  True,
130
  )
@@ -323,14 +387,6 @@ def app_tab():
323
  elem_classes="dropdown-container",
324
  )
325
 
326
- df_traits_priority_for_professions = read_csv_file(
327
- config_data.Links_PROFESSIONS
328
- )
329
- weights_professions, interactive_professions = extract_profession_weights(
330
- df_traits_priority_for_professions,
331
- config_data.Settings_DROPDOWN_CANDIDATES[0],
332
- )
333
-
334
  number_openness = number_create_ui(
335
  value=weights_professions[0],
336
  minimum=config_data.Values_0_100[0],
@@ -481,6 +537,7 @@ def app_tab():
481
  visible=False,
482
  show_download_button=False,
483
  elem_classes="metadata_name-logo",
 
484
  )
485
 
486
  name = textbox_create_ui(
@@ -512,6 +569,7 @@ def app_tab():
512
  visible=False,
513
  show_download_button=False,
514
  elem_classes="metadata_surname-logo",
 
515
  )
516
 
517
  surname = textbox_create_ui(
@@ -545,6 +603,7 @@ def app_tab():
545
  visible=False,
546
  show_download_button=False,
547
  elem_classes="metadata_email-logo",
 
548
  )
549
 
550
  email = textbox_create_ui(
@@ -576,6 +635,7 @@ def app_tab():
576
  visible=False,
577
  show_download_button=False,
578
  elem_classes="metadata_phone-logo",
 
579
  )
580
 
581
  phone = textbox_create_ui(
@@ -595,8 +655,9 @@ def app_tab():
595
 
596
  practical_subtasks_selected = gr.JSON(
597
  value={
598
- str(task): supported_practical_tasks.get(task, [None])[0]
599
- for task in supported_practical_tasks.keys()
 
600
  },
601
  visible=False,
602
  render=True,
@@ -611,6 +672,9 @@ def app_tab():
611
  step_1,
612
  notifications,
613
  files,
 
 
 
614
  video,
615
  examples,
616
  calculate_pt_scores,
 
13
  from app.mbti_description import MBTI_DESCRIPTION, MBTI_DATA
14
  from app.app import APP
15
  from app.authors import AUTHORS
16
+ from app.data_init import weights_professions, interactive_professions
17
  from app.requirements_app import read_requirements_to_df
18
  from app.config import config_data
19
  from app.practical_tasks import supported_practical_tasks
20
+ from app.utils import read_csv_file
21
  from app.components import (
22
  html_message,
23
  files_create_ui,
 
38
 
39
  step_1 = gr.HTML(value=STEP_1[config_data.AppSettings_DEFAULT_LANG_ID])
40
 
41
+ with gr.Row(elem_classes="media-container"):
42
+ with gr.Column():
43
+ files = files_create_ui(
44
+ label="{} ({})".format(
45
+ config_data.OtherMessages_VIDEO_FILES[
46
+ config_data.AppSettings_DEFAULT_LANG_ID
47
+ ],
48
+ ", ".join(config_data.Settings_SUPPORTED_VIDEO_EXT),
49
+ ),
50
+ file_types=[
51
+ f".{ext}" for ext in config_data.Settings_SUPPORTED_VIDEO_EXT
52
+ ],
53
+ )
54
+
55
+ webcam = gr.Video(
56
+ label="{} ({})".format(
57
+ config_data.OtherMessages_VIDEO_FILES[
58
+ config_data.AppSettings_DEFAULT_LANG_ID
59
+ ],
60
+ ", ".join(config_data.Settings_SUPPORTED_VIDEO_EXT),
61
+ ),
62
+ show_label=True,
63
+ interactive=False,
64
+ visible=False,
65
+ mirror_webcam=False,
66
+ include_audio=True,
67
+ elem_classes="webcam",
68
+ autoplay=False,
69
+ )
70
+
71
+ switching_modes = button(
72
+ config_data.OtherMessages_SWITCHEHG_MODES_ONLINE[
73
  config_data.AppSettings_DEFAULT_LANG_ID
74
  ],
75
+ True,
76
+ 1,
77
+ "./images/webcam.ico",
78
+ True,
79
+ "switching_modes",
80
+ )
81
+
82
+ type_modes = gr.Radio(
83
+ choices=config_data.Settings_TYPE_MODES,
84
+ value=config_data.Settings_TYPE_MODES[0],
85
+ label=None,
86
+ info=None,
87
+ show_label=False,
88
+ container=False,
89
+ interactive=False,
90
+ visible=False,
91
+ render=True,
92
+ elem_classes="type_modes",
93
+ )
94
 
95
  video = video_create_ui()
96
 
 
131
  config_data.AppSettings_DEFAULT_LANG_ID
132
  ],
133
  False,
134
+ "notifications",
135
  )
136
 
137
  pt_scores = dataframe(visible=False)
 
153
  value=STEP_2[config_data.AppSettings_DEFAULT_LANG_ID], visible=False
154
  )
155
 
156
+ first_practical_task = next(
157
+ iter(supported_practical_tasks[config_data.AppSettings_DEFAULT_LANG_ID])
158
+ )
159
 
160
  with gr.Column(scale=1, visible=False, render=True) as practical_tasks_column:
161
  practical_tasks = radio_create_ui(
162
  first_practical_task,
163
  config_data.Labels_PRACTICAL_TASKS_LABEL,
164
+ list(
165
+ map(
166
+ str,
167
+ supported_practical_tasks[
168
+ config_data.AppSettings_DEFAULT_LANG_ID
169
+ ].keys(),
170
+ )
171
+ ),
172
+ config_data.InformationMessages_PRACTICAL_TASKS_INFO[
173
+ config_data.AppSettings_DEFAULT_LANG_ID
174
+ ],
175
  True,
176
  True,
177
  )
178
 
179
  practical_subtasks = radio_create_ui(
180
+ supported_practical_tasks[config_data.AppSettings_DEFAULT_LANG_ID][
181
+ first_practical_task
182
+ ][0],
183
+ config_data.Labels_PRACTICAL_SUBTASKS_LABEL[
184
+ config_data.AppSettings_DEFAULT_LANG_ID
185
+ ],
186
+ supported_practical_tasks[config_data.AppSettings_DEFAULT_LANG_ID][
187
+ first_practical_task
188
+ ],
189
+ config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO[
190
+ config_data.AppSettings_DEFAULT_LANG_ID
191
+ ],
192
  True,
193
  True,
194
  )
 
387
  elem_classes="dropdown-container",
388
  )
389
 
 
 
 
 
 
 
 
 
390
  number_openness = number_create_ui(
391
  value=weights_professions[0],
392
  minimum=config_data.Values_0_100[0],
 
537
  visible=False,
538
  show_download_button=False,
539
  elem_classes="metadata_name-logo",
540
+ show_fullscreen_button=False,
541
  )
542
 
543
  name = textbox_create_ui(
 
569
  visible=False,
570
  show_download_button=False,
571
  elem_classes="metadata_surname-logo",
572
+ show_fullscreen_button=False,
573
  )
574
 
575
  surname = textbox_create_ui(
 
603
  visible=False,
604
  show_download_button=False,
605
  elem_classes="metadata_email-logo",
606
+ show_fullscreen_button=False,
607
  )
608
 
609
  email = textbox_create_ui(
 
635
  visible=False,
636
  show_download_button=False,
637
  elem_classes="metadata_phone-logo",
638
+ show_fullscreen_button=False,
639
  )
640
 
641
  phone = textbox_create_ui(
 
655
 
656
  practical_subtasks_selected = gr.JSON(
657
  value={
658
+ str(task): supported_practical_tasks[index].get(task, [None])[0]
659
+ for index in range(len(supported_practical_tasks))
660
+ for task in supported_practical_tasks[index].keys()
661
  },
662
  visible=False,
663
  render=True,
 
672
  step_1,
673
  notifications,
674
  files,
675
+ webcam,
676
+ switching_modes,
677
+ type_modes,
678
  video,
679
  examples,
680
  calculate_pt_scores,
app/utils.py CHANGED
@@ -6,6 +6,8 @@ License: MIT License
6
  """
7
 
8
  import pandas as pd
 
 
9
 
10
  # Importing necessary components for the Gradio app
11
  from app.config import config_data
@@ -84,3 +86,27 @@ def extract_profession_weights(df, dropdown_candidates):
84
  weights_professions = list(map(int, weights_professions))
85
 
86
  return weights_professions, interactive_professions
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  """
7
 
8
  import pandas as pd
9
+ import subprocess
10
+ from pathlib import Path
11
 
12
  # Importing necessary components for the Gradio app
13
  from app.config import config_data
 
86
  weights_professions = list(map(int, weights_professions))
87
 
88
  return weights_professions, interactive_professions
89
+
90
+
91
+ def webm2mp4(input_file):
92
+ input_path = Path(input_file)
93
+ output_path = input_path.with_suffix(".mp4")
94
+
95
+ if not output_path.exists():
96
+ subprocess.run(
97
+ [
98
+ "ffmpeg",
99
+ "-i",
100
+ str(input_path),
101
+ "-c:v",
102
+ "copy",
103
+ "-c:a",
104
+ "aac",
105
+ "-strict",
106
+ "experimental",
107
+ str(output_path),
108
+ ],
109
+ check=True,
110
+ )
111
+
112
+ return str(output_path)
config.toml CHANGED
@@ -1,5 +1,7 @@
1
  [AppSettings]
2
- APP_VERSION = "0.9.2"
 
 
3
  CSS_PATH = "app.css"
4
  DEFAULT_LANG_ID = 0
5
 
@@ -9,8 +11,8 @@ DESCRIPTIONS = [
9
  "- библиотека с открытым исходным кодом для оценивания большой пятерки качеств личности человека и автоматизации HR-процессов",
10
  ]
11
  NOTI_VIDEOS = ["Select the video(s)", "Выберите видео"]
12
- PRACTICAL_TASKS_INFO = "Choose a practical task"
13
- PRACTICAL_SUBTASKS_INFO = "Choose a practical subtask"
14
  NOTI_IN_DEV = "In development"
15
  DROPDOWN_MBTI_INFO = "What personality type indicator are you interested in?"
16
  DROPDOWN_PROFESSIONAL_SKILLS_INFO = "What professional skill are you interested in?"
@@ -31,8 +33,14 @@ STEP_2 = [
31
  [OtherMessages]
32
  VIDEO_FILES = ["Video Files", "Видеофайлы"]
33
  VIDEO_PLAYER = ["Video Player", "Видео проигрыватель"]
34
- CALCULATE_PT_SCORES = ["Calculation of Big Five personality traits scores", "Вычисление показателей Большой пятерки персональных качеств личности человека"]
35
- CALCULATE_PT_SCORES_ERR = "Personality traits scores have not been calculated. Try uploading a different file(s)"
 
 
 
 
 
 
36
  CALCULATE_PRACTICAL_TASK = "Solving practical task"
37
  CLEAR_APP = ["Clear", "Сброс"]
38
  EXAMPLES_APP = ["Examples", "Примеры"]
@@ -45,14 +53,16 @@ EXPORT_WT = "Export ranking effective work teams results to a CSV file"
45
  EXPORT_CP = "Export consumer preferences for industrial goods results to a CSV file"
46
  EXPORT_MBTI = "Export ranking personality type results to a CSV file"
47
  NOTI_CALCULATE = ["You can calculate Big Five personality traits scores", "Вы можете рассчитать показатели Большой пятерки персональных качеств личности человека"]
 
 
48
 
49
  [Labels]
50
  APP_LABEL = ["⭐ App", "⭐ Приложение"]
51
  ABOUT_APP_LABEL = ["💡 About the App", "💡 О приложении"]
52
  ABOUT_AUTHORS_LABEL = ["🎭 About the Authors", "🎭 Об авторах"]
53
  REQUIREMENTS_LABEL = ["📋 Requirements", "📋 Зависимости"]
54
- PRACTICAL_TASKS_LABEL = "Practical tasks"
55
- PRACTICAL_SUBTASKS_LABEL = "Practical subtasks"
56
  THRESHOLD_MBTI_LABEL = "Polarity traits threshold"
57
  THRESHOLD_PROFESSIONAL_SKILLS_LABEL = "Polarity traits threshold"
58
  TARGET_SCORE_OPE_LABEL = "Openness target score"
@@ -138,8 +148,10 @@ DROPDOWN_MBTI = [
138
  "The Commander (ENTJ): Construction Supervisor, Health Services Administrator, Financial Accountant, Auditor, Lawyer, School Principal, Chemical Engineer, Database Manager, etc.",
139
  ]
140
  DROPDOWN_MBTI_DEL_COLS = ["EI", "SN", "TF", "JP", "Match"]
 
141
  SHOW_VIDEO_METADATA = true
142
  SUPPORTED_VIDEO_EXT = ["mp4", "mov", "avi", "flv"]
 
143
 
144
  [Values]
145
  TARGET_SCORES = [0.527886, 0.522337, 0.458468, 0.51761, 0.444649]
 
1
  [AppSettings]
2
+ APP_VERSION = "0.10.4"
3
+ SERVER_NAME = "127.0.0.1"
4
+ PORT = 7860
5
  CSS_PATH = "app.css"
6
  DEFAULT_LANG_ID = 0
7
 
 
11
  "- библиотека с открытым исходным кодом для оценивания большой пятерки качеств личности человека и автоматизации HR-процессов",
12
  ]
13
  NOTI_VIDEOS = ["Select the video(s)", "Выберите видео"]
14
+ PRACTICAL_TASKS_INFO = ["Choose a practical task", "Выберите практическую задачу"]
15
+ PRACTICAL_SUBTASKS_INFO = ["Choose a practical subtask", "Выберите практическую подзадачу"]
16
  NOTI_IN_DEV = "In development"
17
  DROPDOWN_MBTI_INFO = "What personality type indicator are you interested in?"
18
  DROPDOWN_PROFESSIONAL_SKILLS_INFO = "What professional skill are you interested in?"
 
33
  [OtherMessages]
34
  VIDEO_FILES = ["Video Files", "Видеофайлы"]
35
  VIDEO_PLAYER = ["Video Player", "Видео проигрыватель"]
36
+ CALCULATE_PT_SCORES = [
37
+ "Calculation of Big Five personality traits scores",
38
+ "Вычисление показателей Большой пятерки персональных качеств личности человека"
39
+ ]
40
+ CALCULATE_PT_SCORES_ERR = [
41
+ "Personality traits scores have not been calculated. Ensure that there are uncovered face and speech of person in the video",
42
+ "Оценки персональных качеств личностей человека не были вычислены. Убедитесь, что в видео присутствует не перекрытое лицо и речь человека"
43
+ ]
44
  CALCULATE_PRACTICAL_TASK = "Solving practical task"
45
  CLEAR_APP = ["Clear", "Сброс"]
46
  EXAMPLES_APP = ["Examples", "Примеры"]
 
53
  EXPORT_CP = "Export consumer preferences for industrial goods results to a CSV file"
54
  EXPORT_MBTI = "Export ranking personality type results to a CSV file"
55
  NOTI_CALCULATE = ["You can calculate Big Five personality traits scores", "Вы можете рассчитать показатели Большой пятерки персональных качеств личности человека"]
56
+ SWITCHEHG_MODES_ONLINE = ["Webcam", "Веб камера"]
57
+ SWITCHEHG_MODES_OFFLINE = ["Video Files", "Видеофайлы"]
58
 
59
  [Labels]
60
  APP_LABEL = ["⭐ App", "⭐ Приложение"]
61
  ABOUT_APP_LABEL = ["💡 About the App", "💡 О приложении"]
62
  ABOUT_AUTHORS_LABEL = ["🎭 About the Authors", "🎭 Об авторах"]
63
  REQUIREMENTS_LABEL = ["📋 Requirements", "📋 Зависимости"]
64
+ PRACTICAL_TASKS_LABEL = ["Practical tasks", "Практические задачи"]
65
+ PRACTICAL_SUBTASKS_LABEL = ["Practical subtasks", "Практические подзадачи"]
66
  THRESHOLD_MBTI_LABEL = "Polarity traits threshold"
67
  THRESHOLD_PROFESSIONAL_SKILLS_LABEL = "Polarity traits threshold"
68
  TARGET_SCORE_OPE_LABEL = "Openness target score"
 
148
  "The Commander (ENTJ): Construction Supervisor, Health Services Administrator, Financial Accountant, Auditor, Lawyer, School Principal, Chemical Engineer, Database Manager, etc.",
149
  ]
150
  DROPDOWN_MBTI_DEL_COLS = ["EI", "SN", "TF", "JP", "Match"]
151
+ DROPDOWN_MBTI_DEL_COLS_WEBCAM = ["Path"]
152
  SHOW_VIDEO_METADATA = true
153
  SUPPORTED_VIDEO_EXT = ["mp4", "mov", "avi", "flv"]
154
+ TYPE_MODES = ["Files", "Web"]
155
 
156
  [Values]
157
  TARGET_SCORES = [0.527886, 0.522337, 0.458468, 0.51761, 0.444649]
images/videos.ico ADDED
images/webcam.ico ADDED
practical_tasks.yaml → practical_tasks_en.yaml RENAMED
File without changes
practical_tasks_ru.yaml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ - task: "Ранжирование потенциальных кандидатов по профессиональным обязанностям"
2
+ subtasks:
3
+ - "16 персональных типов личности MBTI"
4
+ - "Профессиональные группы"
5
+ - "Профессиональные навыки"
6
+ - task: "Формирование эффективных рабочих коллективов"
7
+ subtasks:
8
+ - "Поиск подходящего младшего коллеги"
9
+ - "Поиск подходящего старшего коллеги"
10
+ - task: "Прогнозирование потребительских предпочтений в отношении промышленных товаров"
11
+ subtasks:
12
+ - "Характеристики автомобиля"
13
+ - "Категории приложений для мобильных устройств"
14
+ - "Стиль одежды"
requirements.txt CHANGED
@@ -1,5 +1,7 @@
1
- gradio==5.5.0
2
- PyYAML==6.0.1
3
  toml==0.10.2
4
- oceanai==1.0.0a43
5
- tf-keras
 
 
 
1
+ gradio==5.7.1
2
+ PyYAML==6.0.2
3
  toml==0.10.2
4
+ oceanai==1.0.0a46
5
+ torch==2.2.2
6
+ psutil==6.1.0
7
+ beautifulsoup4==4.12.3