DmitryRyumin commited on
Commit
b5ab0e1
β€’
1 Parent(s): f01044d
README.md CHANGED
@@ -8,6 +8,7 @@ sdk_version: 4.24.0
8
  app_file: app.py
9
  pinned: false
10
  license: mit
 
11
  ---
12
 
13
  Check out the configuration reference at <https://huggingface.co/docs/hub/spaces-config-reference>
 
8
  app_file: app.py
9
  pinned: false
10
  license: mit
11
+ short_description: Automate HR processes by assessing the Big Five personality traits
12
  ---
13
 
14
  Check out the configuration reference at <https://huggingface.co/docs/hub/spaces-config-reference>
app.css CHANGED
@@ -26,7 +26,8 @@ div.files-container label[data-testid="block-label"] {
26
  position: absolute;
27
  }
28
 
29
- .calculate_oceanai {
 
30
  display: inline-block;
31
  padding: 10px 20px;
32
  font-size: 16px;
@@ -54,19 +55,22 @@ div.files-container label[data-testid="block-label"] {
54
  }
55
 
56
  .calculate_oceanai[disabled],
 
57
  .examples_oceanai[disabled],
58
  .clear_oceanai[disabled] {
59
  cursor: not-allowed;
60
  opacity: 0.6;
61
  }
62
 
63
- .calculate_oceanai:hover:not([disabled]) {
 
64
  border-color: var(--button-primary-border-color-hover);
65
  background: var(--button-primary-background-fill-hover);
66
  color: var(--button-primary-text-color-hover);
67
  }
68
 
69
  .calculate_oceanai:active:not([disabled]),
 
70
  .examples_oceanai:active:not([disabled]),
71
  .clear_oceanai:active:not([disabled]) {
72
  transform: scale(0.98);
 
26
  position: absolute;
27
  }
28
 
29
+ .calculate_oceanai,
30
+ .calculate_practical_task {
31
  display: inline-block;
32
  padding: 10px 20px;
33
  font-size: 16px;
 
55
  }
56
 
57
  .calculate_oceanai[disabled],
58
+ .calculate_practical_task[disabled],
59
  .examples_oceanai[disabled],
60
  .clear_oceanai[disabled] {
61
  cursor: not-allowed;
62
  opacity: 0.6;
63
  }
64
 
65
+ .calculate_oceanai:hover:not([disabled]),
66
+ .calculate_practical_task:hover:not([disabled]) {
67
  border-color: var(--button-primary-border-color-hover);
68
  background: var(--button-primary-background-fill-hover);
69
  color: var(--button-primary-text-color-hover);
70
  }
71
 
72
  .calculate_oceanai:active:not([disabled]),
73
+ .calculate_practical_task:active:not([disabled]),
74
  .examples_oceanai:active:not([disabled]),
75
  .clear_oceanai:active:not([disabled]) {
76
  transform: scale(0.98);
app/components.py CHANGED
@@ -97,3 +97,23 @@ def button(
97
  visible=visible,
98
  elem_classes=elem_classes,
99
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  visible=visible,
98
  elem_classes=elem_classes,
99
  )
100
+
101
+
102
+ def radio_create_ui(
103
+ value: Union[str, int, float, Callable, None],
104
+ label: str,
105
+ choices: Union[List, None],
106
+ info: str,
107
+ interactive: bool,
108
+ visible: bool,
109
+ ):
110
+ return gr.Radio(
111
+ value=value,
112
+ label=label,
113
+ choices=choices,
114
+ info=info,
115
+ show_label=True,
116
+ container=True,
117
+ interactive=interactive,
118
+ visible=visible,
119
+ )
app/event_handlers/calculate_practical_tasks.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ File: calculate_practical_tasks.py
3
+ Author: Elena Ryumina and Dmitry Ryumin
4
+ Description: Event handler for Gradio app to calculate practical tasks.
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.components import html_message
13
+
14
+
15
+ def event_handler_calculate_practical_task_blocks():
16
+ gr.Info(config_data.InformationMessages_NOTI_IN_DEV)
17
+
18
+ return html_message(config_data.InformationMessages_NOTI_IN_DEV, False, True)
app/event_handlers/calculate_pt_scores_blocks.py CHANGED
@@ -40,4 +40,5 @@ def event_handler_calculate_pt_scores_blocks(files, evt_data: gr.EventData):
40
  True,
41
  "csv-container",
42
  ),
 
43
  )
 
40
  True,
41
  "csv-container",
42
  ),
43
+ gr.Column(visible=True),
44
  )
app/event_handlers/clear_blocks.py CHANGED
@@ -5,18 +5,24 @@ Description: Event handler for clearing Gradio app blocks and components.
5
  License: MIT License
6
  """
7
 
 
 
8
  # Importing necessary components for the Gradio app
9
  from app.config import config_data
 
10
  from app.components import (
11
  html_message,
12
  files_create_ui,
13
  video_create_ui,
14
  button,
15
  dataframe,
 
16
  )
17
 
18
 
19
  def event_handler_clear_blocks():
 
 
20
  return (
21
  html_message(config_data.InformationMessages_NOTI_VIDEOS, False),
22
  files_create_ui(),
@@ -40,4 +46,30 @@ def event_handler_clear_blocks():
40
  False,
41
  "csv-container",
42
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  )
 
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.practical_tasks import supported_practical_tasks
13
  from app.components import (
14
  html_message,
15
  files_create_ui,
16
  video_create_ui,
17
  button,
18
  dataframe,
19
+ radio_create_ui,
20
  )
21
 
22
 
23
  def event_handler_clear_blocks():
24
+ first_practical_task = next(iter(supported_practical_tasks))
25
+
26
  return (
27
  html_message(config_data.InformationMessages_NOTI_VIDEOS, False),
28
  files_create_ui(),
 
46
  False,
47
  "csv-container",
48
  ),
49
+ gr.Column(visible=False),
50
+ radio_create_ui(
51
+ first_practical_task,
52
+ "Practical tasks",
53
+ list(map(str, supported_practical_tasks.keys())),
54
+ config_data.InformationMessages_PRACTICAL_TASKS_INFO,
55
+ True,
56
+ True,
57
+ ),
58
+ radio_create_ui(
59
+ supported_practical_tasks[first_practical_task][0],
60
+ "Practical subtasks",
61
+ supported_practical_tasks[first_practical_task],
62
+ config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO,
63
+ True,
64
+ True,
65
+ ),
66
+ gr.JSON(
67
+ value={
68
+ str(task): supported_practical_tasks.get(task, [None])[0]
69
+ for task in supported_practical_tasks.keys()
70
+ },
71
+ visible=False,
72
+ render=True,
73
+ ),
74
+ html_message(config_data.InformationMessages_NOTI_IN_DEV, False, False),
75
  )
app/event_handlers/event_handlers.py CHANGED
@@ -17,6 +17,11 @@ from app.event_handlers.clear_blocks import event_handler_clear_blocks
17
  from app.event_handlers.calculate_pt_scores_blocks import (
18
  event_handler_calculate_pt_scores_blocks,
19
  )
 
 
 
 
 
20
 
21
 
22
  def setup_app_event_handlers(
@@ -28,6 +33,12 @@ def setup_app_event_handlers(
28
  clear_app,
29
  pt_scores,
30
  csv_pt_scores,
 
 
 
 
 
 
31
  ):
32
  # Events
33
  files.change(
@@ -46,7 +57,7 @@ def setup_app_event_handlers(
46
  triggers=[calculate_pt_scores.click],
47
  fn=event_handler_calculate_pt_scores_blocks,
48
  inputs=[files],
49
- outputs=[notifications, pt_scores, csv_pt_scores],
50
  queue=True,
51
  )
52
  examples.click(
@@ -68,6 +79,31 @@ def setup_app_event_handlers(
68
  clear_app,
69
  pt_scores,
70
  csv_pt_scores,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  ],
72
  queue=True,
73
  )
 
17
  from app.event_handlers.calculate_pt_scores_blocks import (
18
  event_handler_calculate_pt_scores_blocks,
19
  )
20
+ from app.event_handlers.practical_tasks import event_handler_practical_tasks
21
+ from app.event_handlers.practical_subtasks import event_handler_practical_subtasks
22
+ from app.event_handlers.calculate_practical_tasks import (
23
+ event_handler_calculate_practical_task_blocks,
24
+ )
25
 
26
 
27
  def setup_app_event_handlers(
 
33
  clear_app,
34
  pt_scores,
35
  csv_pt_scores,
36
+ practical_tasks,
37
+ practical_subtasks,
38
+ calculate_practical_task,
39
+ practical_subtasks_selected,
40
+ practical_tasks_column,
41
+ in_development,
42
  ):
43
  # Events
44
  files.change(
 
57
  triggers=[calculate_pt_scores.click],
58
  fn=event_handler_calculate_pt_scores_blocks,
59
  inputs=[files],
60
+ outputs=[notifications, pt_scores, csv_pt_scores, practical_tasks_column],
61
  queue=True,
62
  )
63
  examples.click(
 
79
  clear_app,
80
  pt_scores,
81
  csv_pt_scores,
82
+ practical_tasks_column,
83
+ practical_tasks,
84
+ practical_subtasks,
85
+ practical_subtasks_selected,
86
+ in_development,
87
+ ],
88
+ queue=True,
89
+ )
90
+ practical_tasks.change(
91
+ event_handler_practical_tasks,
92
+ [practical_tasks, practical_subtasks_selected],
93
+ [practical_subtasks],
94
+ queue=True,
95
+ )
96
+ practical_subtasks.change(
97
+ event_handler_practical_subtasks,
98
+ [practical_tasks, practical_subtasks, practical_subtasks_selected],
99
+ [practical_subtasks_selected],
100
+ queue=True,
101
+ )
102
+ calculate_practical_task.click(
103
+ fn=event_handler_calculate_practical_task_blocks,
104
+ inputs=[],
105
+ outputs=[
106
+ in_development,
107
  ],
108
  queue=True,
109
  )
app/event_handlers/practical_subtasks.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ File: practical_subtasks.py
3
+ Author: Elena Ryumina and Dmitry Ryumin
4
+ Description: Event handler for Gradio app to filter practical subtasks based on selected practical subtasks.
5
+ License: MIT License
6
+ """
7
+
8
+ # Importing necessary components for the Gradio app
9
+
10
+
11
+ def event_handler_practical_subtasks(
12
+ practical_tasks, practical_subtasks, practical_subtasks_selected
13
+ ):
14
+ practical_subtasks_selected[practical_tasks] = practical_subtasks
15
+
16
+ return practical_subtasks_selected
app/event_handlers/practical_tasks.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ File: practical_tasks.py
3
+ Author: Elena Ryumina and Dmitry Ryumin
4
+ Description: Event handler for Gradio app to filter practical tasks based on selected practical tasks.
5
+ License: MIT License
6
+ """
7
+
8
+ # Importing necessary components for the Gradio app
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
+ )
app/practical_tasks.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ File: practical_tasks.py
3
+ Author: Dmitry Ryumin
4
+ Description: Utility functions for working with practical tasks data.
5
+ License: MIT License
6
+ """
7
+
8
+ import yaml
9
+ from typing import Dict, List
10
+
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)
app/tabs.py CHANGED
@@ -11,12 +11,14 @@ import gradio as gr
11
  from app.description import DESCRIPTION
12
  from app.authors import AUTHORS
13
  from app.config import config_data
 
14
  from app.components import (
15
  html_message,
16
  files_create_ui,
17
  video_create_ui,
18
  button,
19
  dataframe,
 
20
  )
21
 
22
 
@@ -58,6 +60,48 @@ def app_tab():
58
  "csv-container",
59
  )
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  return (
62
  notifications,
63
  files,
@@ -67,6 +111,12 @@ def app_tab():
67
  clear_app,
68
  pt_scores,
69
  csv_pt_scores,
 
 
 
 
 
 
70
  )
71
 
72
 
 
11
  from app.description import DESCRIPTION
12
  from app.authors import AUTHORS
13
  from app.config import config_data
14
+ from app.practical_tasks import supported_practical_tasks
15
  from app.components import (
16
  html_message,
17
  files_create_ui,
18
  video_create_ui,
19
  button,
20
  dataframe,
21
+ radio_create_ui,
22
  )
23
 
24
 
 
60
  "csv-container",
61
  )
62
 
63
+ first_practical_task = next(iter(supported_practical_tasks))
64
+
65
+ with gr.Column(scale=1, visible=False, render=True) as practical_tasks_column:
66
+ practical_tasks = radio_create_ui(
67
+ first_practical_task,
68
+ config_data.Labels_PRACTICAL_TASKS_LABEL,
69
+ list(map(str, supported_practical_tasks.keys())),
70
+ config_data.InformationMessages_PRACTICAL_TASKS_INFO,
71
+ True,
72
+ True,
73
+ )
74
+
75
+ practical_subtasks = radio_create_ui(
76
+ supported_practical_tasks[first_practical_task][0],
77
+ config_data.Labels_PRACTICAL_SUBTASKS_LABEL,
78
+ supported_practical_tasks[first_practical_task],
79
+ config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO,
80
+ True,
81
+ True,
82
+ )
83
+
84
+ calculate_practical_task = button(
85
+ config_data.OtherMessages_CALCULATE_PRACTICAL_TASK,
86
+ True,
87
+ 1,
88
+ True,
89
+ "calculate_practical_task",
90
+ )
91
+
92
+ practical_subtasks_selected = gr.JSON(
93
+ value={
94
+ str(task): supported_practical_tasks.get(task, [None])[0]
95
+ for task in supported_practical_tasks.keys()
96
+ },
97
+ visible=False,
98
+ render=True,
99
+ )
100
+
101
+ in_development = html_message(
102
+ config_data.InformationMessages_NOTI_IN_DEV, False, False
103
+ )
104
+
105
  return (
106
  notifications,
107
  files,
 
111
  clear_app,
112
  pt_scores,
113
  csv_pt_scores,
114
+ practical_tasks,
115
+ practical_subtasks,
116
+ calculate_practical_task,
117
+ practical_subtasks_selected,
118
+ practical_tasks_column,
119
+ in_development,
120
  )
121
 
122
 
config.toml CHANGED
@@ -1,17 +1,25 @@
1
  [AppSettings]
2
- APP_VERSION = "0.2.0"
3
  CSS_PATH = "app.css"
4
 
5
  [InformationMessages]
6
  NOTI_VIDEOS = "Select the video(s)"
 
 
 
7
 
8
  [OtherMessages]
9
  CALCULATE_PT_SCORES = "Calculation of Big Five personality traits scores"
 
10
  CLEAR_APP = "Clear"
11
  EXAMPLES_APP = "Examples"
12
  EXPORT_PT_SCORES = "Export Big Five personality traits to a CSV file"
13
  NOTI_CALCULATE = "You can calculate Big Five personality traits scores"
14
 
 
 
 
 
15
  [TabCreators]
16
  "App" = "app_tab"
17
  "About the Authors" = "about_authors_tab"
 
1
  [AppSettings]
2
+ APP_VERSION = "0.3.0"
3
  CSS_PATH = "app.css"
4
 
5
  [InformationMessages]
6
  NOTI_VIDEOS = "Select the video(s)"
7
+ PRACTICAL_TASKS_INFO = "Choose a practical task"
8
+ PRACTICAL_SUBTASKS_INFO = "Choose a practical subtask"
9
+ NOTI_IN_DEV = "In development"
10
 
11
  [OtherMessages]
12
  CALCULATE_PT_SCORES = "Calculation of Big Five personality traits scores"
13
+ CALCULATE_PRACTICAL_TASK = "Calculation of information for a practical task"
14
  CLEAR_APP = "Clear"
15
  EXAMPLES_APP = "Examples"
16
  EXPORT_PT_SCORES = "Export Big Five personality traits to a CSV file"
17
  NOTI_CALCULATE = "You can calculate Big Five personality traits scores"
18
 
19
+ [Labels]
20
+ PRACTICAL_TASKS_LABEL = "Practical tasks"
21
+ PRACTICAL_SUBTASKS_LABEL = "Practical subtasks"
22
+
23
  [TabCreators]
24
  "App" = "app_tab"
25
  "About the Authors" = "about_authors_tab"
practical_tasks.yaml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ - task: "Ranking potential candidates by professional responsibilities"
2
+ subtasks:
3
+ - "Professional groups"
4
+ - "Professional skills"
5
+ - task: "Forming effective work teams"
6
+ subtasks:
7
+ - "Finding a suitable junior colleague"
8
+ - "Finding a suitable senior colleague"
9
+ - task: "Predicting consumer preferences for industrial goods"
10
+ subtasks:
11
+ - "Car characteristics"
12
+ - "Mobile device application categories"