ElenaRyumina DmitryRyumin commited on
Commit
b0f25b3
β€’
1 Parent(s): 3d3aa21

- Summary (0ba2e4a30caca9217f27ac36283b3e777000a303)


Co-authored-by: Dmitry Ryumin <[email protected]>

app/components.py CHANGED
@@ -67,6 +67,7 @@ def dataframe(
67
  height: int = 500,
68
  wrap: bool = True,
69
  visible: bool = True,
 
70
  elem_classes: Optional[str] = "dataframe",
71
  ) -> gr.Dataframe:
72
  if headers is None or values is None:
@@ -81,6 +82,7 @@ def dataframe(
81
  height=height,
82
  wrap=wrap,
83
  visible=visible,
 
84
  elem_classes=elem_classes,
85
  )
86
 
 
67
  height: int = 500,
68
  wrap: bool = True,
69
  visible: bool = True,
70
+ interactive: bool = False,
71
  elem_classes: Optional[str] = "dataframe",
72
  ) -> gr.Dataframe:
73
  if headers is None or values is None:
 
82
  height=height,
83
  wrap=wrap,
84
  visible=visible,
85
+ interactive=interactive,
86
  elem_classes=elem_classes,
87
  )
88
 
app/event_handlers/calculate_practical_tasks.py CHANGED
@@ -5,14 +5,83 @@ 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)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  License: MIT License
6
  """
7
 
8
+ from app.oceanai_init import b5
9
  import gradio as gr
10
+ import pandas as pd
11
 
12
  # Importing necessary components for the Gradio app
13
  from app.config import config_data
14
+ from app.components import html_message, dataframe, files_create_ui
15
 
16
 
17
+ def event_handler_calculate_practical_task_blocks(
18
+ practical_tasks, practical_subtasks, pt_scores
19
+ ):
20
+ if practical_subtasks.lower() == "professional skills":
21
+ df_professional_skills = pd.read_csv(config_data.Links_PROFESSIONAL_SKILLS)
22
 
23
+ df_professional_skills.index.name = "ID"
24
+ df_professional_skills.index += 1
25
+ df_professional_skills.index = df_professional_skills.index.map(str)
26
+
27
+ b5._priority_skill_calculation(
28
+ df_files=pt_scores.iloc[:, 1:],
29
+ correlation_coefficients=df_professional_skills,
30
+ threshold=0.5,
31
+ out=True,
32
+ )
33
+
34
+ # Optional
35
+ df = b5.df_files_priority_skill_.rename(
36
+ columns={
37
+ "Openness": "OPE",
38
+ "Conscientiousness": "CON",
39
+ "Extraversion": "EXT",
40
+ "Agreeableness": "AGR",
41
+ "Non-Neuroticism": "NNEU",
42
+ }
43
+ )
44
+ columns_to_round = df.columns[1:]
45
+ df[columns_to_round] = df[columns_to_round].apply(
46
+ lambda x: [round(i, 3) for i in x]
47
+ )
48
+
49
+ df.to_csv(config_data.Filenames_PT_SKILLS_SCORES)
50
+
51
+ df.reset_index(inplace=True)
52
+
53
+ return (
54
+ dataframe(
55
+ headers=df.columns.tolist(),
56
+ values=df.values.tolist(),
57
+ visible=True,
58
+ ),
59
+ files_create_ui(
60
+ config_data.Filenames_PT_SKILLS_SCORES,
61
+ "single",
62
+ [".csv"],
63
+ config_data.OtherMessages_EXPORT_PS,
64
+ True,
65
+ False,
66
+ True,
67
+ "csv-container",
68
+ ),
69
+ html_message(config_data.InformationMessages_NOTI_IN_DEV, False, False),
70
+ )
71
+ else:
72
+ gr.Info(config_data.InformationMessages_NOTI_IN_DEV)
73
+
74
+ return (
75
+ dataframe(visible=False),
76
+ files_create_ui(
77
+ None,
78
+ "single",
79
+ [".csv"],
80
+ config_data.OtherMessages_EXPORT_PS,
81
+ True,
82
+ False,
83
+ False,
84
+ "csv-container",
85
+ ),
86
+ html_message(config_data.InformationMessages_NOTI_IN_DEV, False, True),
87
+ )
app/event_handlers/calculate_pt_scores_blocks.py CHANGED
@@ -10,7 +10,14 @@ import gradio as gr
10
  # Importing necessary components for the Gradio app
11
  from app.oceanai_init import b5
12
  from app.config import config_data
13
- from app.components import html_message, dataframe, files_create_ui
 
 
 
 
 
 
 
14
 
15
 
16
  def event_handler_calculate_pt_scores_blocks(files, evt_data: gr.EventData):
@@ -23,11 +30,16 @@ def event_handler_calculate_pt_scores_blocks(files, evt_data: gr.EventData):
23
 
24
  b5.df_files_.to_csv(config_data.Filenames_PT_SCORES)
25
 
 
 
 
 
 
26
  return (
27
  html_message(config_data.InformationMessages_NOTI_VIDEOS, False, False),
28
  dataframe(
29
- headers=b5.df_files_.columns.tolist(),
30
- values=b5.df_files_.values.tolist(),
31
  visible=True,
32
  ),
33
  files_create_ui(
@@ -41,4 +53,47 @@ def event_handler_calculate_pt_scores_blocks(files, evt_data: gr.EventData):
41
  "csv-container",
42
  ),
43
  gr.Column(visible=True),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  )
 
10
  # Importing necessary components for the Gradio app
11
  from app.oceanai_init import b5
12
  from app.config import config_data
13
+ from app.practical_tasks import supported_practical_tasks
14
+ from app.components import (
15
+ html_message,
16
+ button,
17
+ dataframe,
18
+ files_create_ui,
19
+ radio_create_ui,
20
+ )
21
 
22
 
23
  def event_handler_calculate_pt_scores_blocks(files, evt_data: gr.EventData):
 
30
 
31
  b5.df_files_.to_csv(config_data.Filenames_PT_SCORES)
32
 
33
+ first_practical_task = next(iter(supported_practical_tasks))
34
+
35
+ df_files = b5.df_files_.copy()
36
+ df_files.reset_index(inplace=True)
37
+
38
  return (
39
  html_message(config_data.InformationMessages_NOTI_VIDEOS, False, False),
40
  dataframe(
41
+ headers=df_files.columns.tolist(),
42
+ values=df_files.values.tolist(),
43
  visible=True,
44
  ),
45
  files_create_ui(
 
53
  "csv-container",
54
  ),
55
  gr.Column(visible=True),
56
+ radio_create_ui(
57
+ first_practical_task,
58
+ "Practical tasks",
59
+ list(map(str, supported_practical_tasks.keys())),
60
+ config_data.InformationMessages_PRACTICAL_TASKS_INFO,
61
+ True,
62
+ True,
63
+ ),
64
+ radio_create_ui(
65
+ supported_practical_tasks[first_practical_task][0],
66
+ "Practical subtasks",
67
+ supported_practical_tasks[first_practical_task],
68
+ config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO,
69
+ True,
70
+ True,
71
+ ),
72
+ gr.JSON(
73
+ value={
74
+ str(task): supported_practical_tasks.get(task, [None])[0]
75
+ for task in supported_practical_tasks.keys()
76
+ },
77
+ visible=False,
78
+ render=True,
79
+ ),
80
+ button(
81
+ config_data.OtherMessages_CALCULATE_PRACTICAL_TASK,
82
+ True,
83
+ 1,
84
+ True,
85
+ "calculate_practical_task",
86
+ ),
87
+ dataframe(visible=False),
88
+ files_create_ui(
89
+ None,
90
+ "single",
91
+ [".csv"],
92
+ config_data.OtherMessages_EXPORT_PS,
93
+ True,
94
+ False,
95
+ False,
96
+ "csv-container",
97
+ ),
98
+ html_message(config_data.InformationMessages_NOTI_IN_DEV, False, False),
99
  )
app/event_handlers/clear_blocks.py CHANGED
@@ -71,5 +71,16 @@ def event_handler_clear_blocks():
71
  visible=False,
72
  render=True,
73
  ),
 
 
 
 
 
 
 
 
 
 
 
74
  html_message(config_data.InformationMessages_NOTI_IN_DEV, False, False),
75
  )
 
71
  visible=False,
72
  render=True,
73
  ),
74
+ dataframe(visible=False),
75
+ files_create_ui(
76
+ None,
77
+ "single",
78
+ [".csv"],
79
+ config_data.OtherMessages_EXPORT_PS,
80
+ True,
81
+ False,
82
+ False,
83
+ "csv-container",
84
+ ),
85
  html_message(config_data.InformationMessages_NOTI_IN_DEV, False, False),
86
  )
app/event_handlers/event_handlers.py CHANGED
@@ -38,6 +38,8 @@ def setup_app_event_handlers(
38
  calculate_practical_task,
39
  practical_subtasks_selected,
40
  practical_tasks_column,
 
 
41
  in_development,
42
  ):
43
  # Events
@@ -56,8 +58,22 @@ def setup_app_event_handlers(
56
  gr.on(
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(
@@ -83,6 +99,8 @@ def setup_app_event_handlers(
83
  practical_tasks,
84
  practical_subtasks,
85
  practical_subtasks_selected,
 
 
86
  in_development,
87
  ],
88
  queue=True,
@@ -101,8 +119,10 @@ def setup_app_event_handlers(
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,
 
38
  calculate_practical_task,
39
  practical_subtasks_selected,
40
  practical_tasks_column,
41
+ practical_task_sorted,
42
+ csv_practical_task_sorted,
43
  in_development,
44
  ):
45
  # Events
 
58
  gr.on(
59
  triggers=[calculate_pt_scores.click],
60
  fn=event_handler_calculate_pt_scores_blocks,
61
+ inputs=[
62
+ files,
63
+ ],
64
+ outputs=[
65
+ notifications,
66
+ pt_scores,
67
+ csv_pt_scores,
68
+ practical_tasks_column,
69
+ practical_tasks,
70
+ practical_subtasks,
71
+ practical_subtasks_selected,
72
+ calculate_practical_task,
73
+ practical_task_sorted,
74
+ csv_practical_task_sorted,
75
+ in_development,
76
+ ],
77
  queue=True,
78
  )
79
  examples.click(
 
99
  practical_tasks,
100
  practical_subtasks,
101
  practical_subtasks_selected,
102
+ practical_task_sorted,
103
+ csv_practical_task_sorted,
104
  in_development,
105
  ],
106
  queue=True,
 
119
  )
120
  calculate_practical_task.click(
121
  fn=event_handler_calculate_practical_task_blocks,
122
+ inputs=[practical_tasks, practical_subtasks, pt_scores],
123
  outputs=[
124
+ practical_task_sorted,
125
+ csv_practical_task_sorted,
126
  in_development,
127
  ],
128
  queue=True,
app/tabs.py CHANGED
@@ -89,6 +89,19 @@ def app_tab():
89
  "calculate_practical_task",
90
  )
91
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  practical_subtasks_selected = gr.JSON(
93
  value={
94
  str(task): supported_practical_tasks.get(task, [None])[0]
@@ -116,6 +129,8 @@ def app_tab():
116
  calculate_practical_task,
117
  practical_subtasks_selected,
118
  practical_tasks_column,
 
 
119
  in_development,
120
  )
121
 
 
89
  "calculate_practical_task",
90
  )
91
 
92
+ practical_task_sorted = dataframe(visible=False)
93
+
94
+ csv_practical_task_sorted = files_create_ui(
95
+ None,
96
+ "single",
97
+ [".csv"],
98
+ config_data.OtherMessages_EXPORT_PS,
99
+ True,
100
+ False,
101
+ False,
102
+ "csv-container",
103
+ )
104
+
105
  practical_subtasks_selected = gr.JSON(
106
  value={
107
  str(task): supported_practical_tasks.get(task, [None])[0]
 
129
  calculate_practical_task,
130
  practical_subtasks_selected,
131
  practical_tasks_column,
132
+ practical_task_sorted,
133
+ csv_practical_task_sorted,
134
  in_development,
135
  )
136
 
config.toml CHANGED
@@ -1,5 +1,5 @@
1
  [AppSettings]
2
- APP_VERSION = "0.3.0"
3
  CSS_PATH = "app.css"
4
 
5
  [InformationMessages]
@@ -14,6 +14,7 @@ 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]
@@ -25,4 +26,8 @@ PRACTICAL_SUBTASKS_LABEL = "Practical subtasks"
25
  "About the Authors" = "about_authors_tab"
26
 
27
  [Filenames]
28
- PT_SCORES = "personality_traits_scores.csv"
 
 
 
 
 
1
  [AppSettings]
2
+ APP_VERSION = "0.4.0"
3
  CSS_PATH = "app.css"
4
 
5
  [InformationMessages]
 
14
  CLEAR_APP = "Clear"
15
  EXAMPLES_APP = "Examples"
16
  EXPORT_PT_SCORES = "Export Big Five personality traits to a CSV file"
17
+ EXPORT_PS = "Export ranking professional skill results to a CSV file"
18
  NOTI_CALCULATE = "You can calculate Big Five personality traits scores"
19
 
20
  [Labels]
 
26
  "About the Authors" = "about_authors_tab"
27
 
28
  [Filenames]
29
+ PT_SCORES = "personality_traits_scores.csv"
30
+ PT_SKILLS_SCORES = "personality_skills_scores.csv"
31
+
32
+ [Links]
33
+ PROFESSIONAL_SKILLS = "https://download.sberdisk.ru/download/file/478678231?token=0qiZwliLtHWWYMv&filename=professional_skills.csv"
requirements.txt CHANGED
@@ -1,6 +1,7 @@
1
- gradio==4.24.0
2
  requests==2.31.0
3
  PyYAML==6.0.1
4
  toml==0.10.2
5
- oceanai==1.0.0a22
6
- tf-keras==2.16.0
 
 
1
+ gradio==4.23.0
2
  requests==2.31.0
3
  PyYAML==6.0.1
4
  toml==0.10.2
5
+ oceanai==1.0.0a24
6
+ tf-keras==2.16.0
7
+ pandas==2.2.1