Spaces:
Running
Running
Commit
β’
aa2aec1
1
Parent(s):
a3f6e4c
v0.5.0 (#5)
Browse files- Summary (4aa0743266f192e4551d911ad5dea17ebd1c6b25)
Co-authored-by: Dmitry Ryumin <[email protected]>
- app.css +16 -0
- app/components.py +54 -0
- app/event_handlers/calculate_practical_tasks.py +45 -7
- app/event_handlers/calculate_pt_scores_blocks.py +9 -0
- app/event_handlers/clear_blocks.py +8 -0
- app/event_handlers/event_handlers.py +41 -2
- app/event_handlers/practical_subtasks.py +37 -1
- app/event_handlers/practical_task_sorted.py +38 -0
- app/tabs.py +58 -13
- config.toml +7 -1
app.css
CHANGED
@@ -76,4 +76,20 @@ div.files-container label[data-testid="block-label"] {
|
|
76 |
.examples_oceanai:active:not([disabled]),
|
77 |
.clear_oceanai:active:not([disabled]) {
|
78 |
transform: scale(0.98);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
}
|
|
|
76 |
.examples_oceanai:active:not([disabled]),
|
77 |
.clear_oceanai:active:not([disabled]) {
|
78 |
transform: scale(0.98);
|
79 |
+
}
|
80 |
+
|
81 |
+
.settings-container {
|
82 |
+
max-width: fit-content;
|
83 |
+
}
|
84 |
+
|
85 |
+
.number-container {
|
86 |
+
max-width: fit-content;
|
87 |
+
}
|
88 |
+
|
89 |
+
.dropdown-container {
|
90 |
+
max-width: fit-content;
|
91 |
+
}
|
92 |
+
|
93 |
+
.dropdown-container > div > span[data-testid="block-info"] + div {
|
94 |
+
min-width: max-content;
|
95 |
}
|
app/components.py
CHANGED
@@ -121,3 +121,57 @@ def radio_create_ui(
|
|
121 |
interactive=interactive,
|
122 |
visible=visible,
|
123 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
interactive=interactive,
|
122 |
visible=visible,
|
123 |
)
|
124 |
+
|
125 |
+
|
126 |
+
def threshold_create_ui(
|
127 |
+
value: float = 0.5,
|
128 |
+
minimum: float = 0.0,
|
129 |
+
maximum: float = 1.0,
|
130 |
+
step: float = 0.01,
|
131 |
+
label: Optional[str] = None,
|
132 |
+
info: Optional[str] = None,
|
133 |
+
show_label: bool = True,
|
134 |
+
interactive: bool = True,
|
135 |
+
visible: bool = False,
|
136 |
+
render: bool = True,
|
137 |
+
elem_classes: Optional[str] = "number-container",
|
138 |
+
):
|
139 |
+
return gr.Number(
|
140 |
+
value=value,
|
141 |
+
minimum=minimum,
|
142 |
+
maximum=maximum,
|
143 |
+
step=step,
|
144 |
+
label=label,
|
145 |
+
info=info,
|
146 |
+
show_label=show_label,
|
147 |
+
interactive=interactive,
|
148 |
+
visible=visible,
|
149 |
+
render=render,
|
150 |
+
elem_classes=elem_classes,
|
151 |
+
)
|
152 |
+
|
153 |
+
|
154 |
+
def dropdown_create_ui(
|
155 |
+
label: Optional[str] = None,
|
156 |
+
info: Optional[str] = None,
|
157 |
+
choices: List = [],
|
158 |
+
value: List = [],
|
159 |
+
multiselect: bool = False,
|
160 |
+
show_label: bool = True,
|
161 |
+
interactive: bool = True,
|
162 |
+
visible: bool = True,
|
163 |
+
render: bool = True,
|
164 |
+
elem_classes: Optional[str] = None,
|
165 |
+
) -> gr.Dropdown:
|
166 |
+
return gr.Dropdown(
|
167 |
+
choices=choices,
|
168 |
+
value=value,
|
169 |
+
multiselect=multiselect,
|
170 |
+
label=label,
|
171 |
+
info=info,
|
172 |
+
show_label=show_label,
|
173 |
+
interactive=interactive,
|
174 |
+
visible=visible,
|
175 |
+
render=render,
|
176 |
+
elem_classes=elem_classes,
|
177 |
+
)
|
app/event_handlers/calculate_practical_tasks.py
CHANGED
@@ -8,14 +8,19 @@ License: MIT License
|
|
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 |
-
|
|
|
|
|
|
|
|
|
19 |
):
|
20 |
if practical_subtasks.lower() == "professional skills":
|
21 |
df_professional_skills = pd.read_csv(config_data.Links_PROFESSIONAL_SKILLS)
|
@@ -27,7 +32,7 @@ def event_handler_calculate_practical_task_blocks(
|
|
27 |
b5._priority_skill_calculation(
|
28 |
df_files=pt_scores.iloc[:, 1:],
|
29 |
correlation_coefficients=df_professional_skills,
|
30 |
-
threshold=
|
31 |
out=True,
|
32 |
)
|
33 |
|
@@ -46,14 +51,38 @@ def event_handler_calculate_practical_task_blocks(
|
|
46 |
lambda x: [round(i, 3) for i in x]
|
47 |
)
|
48 |
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
return (
|
|
|
|
|
54 |
dataframe(
|
55 |
-
headers=
|
56 |
-
values=
|
57 |
visible=True,
|
58 |
),
|
59 |
files_create_ui(
|
@@ -66,12 +95,20 @@ def event_handler_calculate_practical_task_blocks(
|
|
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,
|
@@ -83,5 +120,6 @@ def event_handler_calculate_practical_task_blocks(
|
|
83 |
False,
|
84 |
"csv-container",
|
85 |
),
|
|
|
86 |
html_message(config_data.InformationMessages_NOTI_IN_DEV, False, True),
|
87 |
)
|
|
|
8 |
from app.oceanai_init import b5
|
9 |
import gradio as gr
|
10 |
import pandas as pd
|
11 |
+
from pathlib import Path
|
12 |
|
13 |
# Importing necessary components for the Gradio app
|
14 |
from app.config import config_data
|
15 |
+
from app.components import html_message, dataframe, files_create_ui, video_create_ui
|
16 |
|
17 |
|
18 |
def event_handler_calculate_practical_task_blocks(
|
19 |
+
files,
|
20 |
+
practical_subtasks,
|
21 |
+
pt_scores,
|
22 |
+
threshold_professional_skills,
|
23 |
+
dropdown_professional_skills,
|
24 |
):
|
25 |
if practical_subtasks.lower() == "professional skills":
|
26 |
df_professional_skills = pd.read_csv(config_data.Links_PROFESSIONAL_SKILLS)
|
|
|
32 |
b5._priority_skill_calculation(
|
33 |
df_files=pt_scores.iloc[:, 1:],
|
34 |
correlation_coefficients=df_professional_skills,
|
35 |
+
threshold=threshold_professional_skills,
|
36 |
out=True,
|
37 |
)
|
38 |
|
|
|
51 |
lambda x: [round(i, 3) for i in x]
|
52 |
)
|
53 |
|
54 |
+
professional_skills_list = (
|
55 |
+
config_data.Settings_DROPDOWN_PROFESSIONAL_SKILLS.copy()
|
56 |
+
)
|
57 |
+
|
58 |
+
professional_skills_list.remove(dropdown_professional_skills)
|
59 |
+
|
60 |
+
professional_skills_list = [
|
61 |
+
"OPE",
|
62 |
+
"CON",
|
63 |
+
"EXT",
|
64 |
+
"AGR",
|
65 |
+
"NNEU",
|
66 |
+
] + professional_skills_list
|
67 |
+
|
68 |
+
df_hidden = df.drop(columns=professional_skills_list)
|
69 |
+
|
70 |
+
df_hidden.to_csv(config_data.Filenames_PT_SKILLS_SCORES)
|
71 |
|
72 |
+
df_hidden.reset_index(inplace=True)
|
73 |
+
|
74 |
+
df_hidden = df_hidden.sort_values(
|
75 |
+
by=[dropdown_professional_skills], ascending=False
|
76 |
+
)
|
77 |
+
|
78 |
+
person_id = int(df_hidden.iloc[0]["Person ID"]) - 1
|
79 |
|
80 |
return (
|
81 |
+
gr.Row(visible=True),
|
82 |
+
gr.Column(visible=True),
|
83 |
dataframe(
|
84 |
+
headers=df_hidden.columns.tolist(),
|
85 |
+
values=df_hidden.values.tolist(),
|
86 |
visible=True,
|
87 |
),
|
88 |
files_create_ui(
|
|
|
95 |
True,
|
96 |
"csv-container",
|
97 |
),
|
98 |
+
video_create_ui(
|
99 |
+
value=files[person_id],
|
100 |
+
file_name=Path(files[person_id]).name,
|
101 |
+
label="Best Person ID - " + str(person_id + 1),
|
102 |
+
visible=True,
|
103 |
+
),
|
104 |
html_message(config_data.InformationMessages_NOTI_IN_DEV, False, False),
|
105 |
)
|
106 |
else:
|
107 |
gr.Info(config_data.InformationMessages_NOTI_IN_DEV)
|
108 |
|
109 |
return (
|
110 |
+
gr.Row(visible=False),
|
111 |
+
gr.Column(visible=False),
|
112 |
dataframe(visible=False),
|
113 |
files_create_ui(
|
114 |
None,
|
|
|
120 |
False,
|
121 |
"csv-container",
|
122 |
),
|
123 |
+
video_create_ui(visible=False),
|
124 |
html_message(config_data.InformationMessages_NOTI_IN_DEV, False, True),
|
125 |
)
|
app/event_handlers/calculate_pt_scores_blocks.py
CHANGED
@@ -17,6 +17,9 @@ from app.components import (
|
|
17 |
dataframe,
|
18 |
files_create_ui,
|
19 |
radio_create_ui,
|
|
|
|
|
|
|
20 |
)
|
21 |
|
22 |
|
@@ -77,6 +80,9 @@ def event_handler_calculate_pt_scores_blocks(files, evt_data: gr.EventData):
|
|
77 |
visible=False,
|
78 |
render=True,
|
79 |
),
|
|
|
|
|
|
|
80 |
button(
|
81 |
config_data.OtherMessages_CALCULATE_PRACTICAL_TASK,
|
82 |
True,
|
@@ -84,6 +90,8 @@ def event_handler_calculate_pt_scores_blocks(files, evt_data: gr.EventData):
|
|
84 |
True,
|
85 |
"calculate_practical_task",
|
86 |
),
|
|
|
|
|
87 |
dataframe(visible=False),
|
88 |
files_create_ui(
|
89 |
None,
|
@@ -95,5 +103,6 @@ def event_handler_calculate_pt_scores_blocks(files, evt_data: gr.EventData):
|
|
95 |
False,
|
96 |
"csv-container",
|
97 |
),
|
|
|
98 |
html_message(config_data.InformationMessages_NOTI_IN_DEV, False, False),
|
99 |
)
|
|
|
17 |
dataframe,
|
18 |
files_create_ui,
|
19 |
radio_create_ui,
|
20 |
+
threshold_create_ui,
|
21 |
+
dropdown_create_ui,
|
22 |
+
video_create_ui,
|
23 |
)
|
24 |
|
25 |
|
|
|
80 |
visible=False,
|
81 |
render=True,
|
82 |
),
|
83 |
+
gr.Column(visible=False),
|
84 |
+
threshold_create_ui(visible=False),
|
85 |
+
dropdown_create_ui(visible=False),
|
86 |
button(
|
87 |
config_data.OtherMessages_CALCULATE_PRACTICAL_TASK,
|
88 |
True,
|
|
|
90 |
True,
|
91 |
"calculate_practical_task",
|
92 |
),
|
93 |
+
gr.Row(visible=False),
|
94 |
+
gr.Column(visible=False),
|
95 |
dataframe(visible=False),
|
96 |
files_create_ui(
|
97 |
None,
|
|
|
103 |
False,
|
104 |
"csv-container",
|
105 |
),
|
106 |
+
video_create_ui(visible=False),
|
107 |
html_message(config_data.InformationMessages_NOTI_IN_DEV, False, False),
|
108 |
)
|
app/event_handlers/clear_blocks.py
CHANGED
@@ -17,6 +17,8 @@ from app.components import (
|
|
17 |
button,
|
18 |
dataframe,
|
19 |
radio_create_ui,
|
|
|
|
|
20 |
)
|
21 |
|
22 |
|
@@ -71,6 +73,11 @@ def event_handler_clear_blocks():
|
|
71 |
visible=False,
|
72 |
render=True,
|
73 |
),
|
|
|
|
|
|
|
|
|
|
|
74 |
dataframe(visible=False),
|
75 |
files_create_ui(
|
76 |
None,
|
@@ -82,5 +89,6 @@ def event_handler_clear_blocks():
|
|
82 |
False,
|
83 |
"csv-container",
|
84 |
),
|
|
|
85 |
html_message(config_data.InformationMessages_NOTI_IN_DEV, False, False),
|
86 |
)
|
|
|
17 |
button,
|
18 |
dataframe,
|
19 |
radio_create_ui,
|
20 |
+
threshold_create_ui,
|
21 |
+
dropdown_create_ui,
|
22 |
)
|
23 |
|
24 |
|
|
|
73 |
visible=False,
|
74 |
render=True,
|
75 |
),
|
76 |
+
gr.Column(visible=False),
|
77 |
+
threshold_create_ui(visible=False),
|
78 |
+
dropdown_create_ui(visible=False),
|
79 |
+
gr.Row(visible=False),
|
80 |
+
gr.Column(visible=False),
|
81 |
dataframe(visible=False),
|
82 |
files_create_ui(
|
83 |
None,
|
|
|
89 |
False,
|
90 |
"csv-container",
|
91 |
),
|
92 |
+
video_create_ui(visible=False),
|
93 |
html_message(config_data.InformationMessages_NOTI_IN_DEV, False, False),
|
94 |
)
|
app/event_handlers/event_handlers.py
CHANGED
@@ -22,6 +22,7 @@ from app.event_handlers.practical_subtasks import event_handler_practical_subtas
|
|
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(
|
@@ -35,11 +36,17 @@ def setup_app_event_handlers(
|
|
35 |
csv_pt_scores,
|
36 |
practical_tasks,
|
37 |
practical_subtasks,
|
|
|
|
|
|
|
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
|
@@ -69,9 +76,15 @@ def setup_app_event_handlers(
|
|
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,
|
@@ -99,8 +112,14 @@ def setup_app_event_handlers(
|
|
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,
|
@@ -114,16 +133,36 @@ def setup_app_event_handlers(
|
|
114 |
practical_subtasks.change(
|
115 |
event_handler_practical_subtasks,
|
116 |
[practical_tasks, practical_subtasks, practical_subtasks_selected],
|
117 |
-
[
|
|
|
|
|
|
|
|
|
|
|
118 |
queue=True,
|
119 |
)
|
120 |
calculate_practical_task.click(
|
121 |
fn=event_handler_calculate_practical_task_blocks,
|
122 |
-
inputs=[
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
outputs=[
|
|
|
|
|
124 |
practical_task_sorted,
|
125 |
csv_practical_task_sorted,
|
|
|
126 |
in_development,
|
127 |
],
|
128 |
queue=True,
|
129 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
from app.event_handlers.calculate_practical_tasks import (
|
23 |
event_handler_calculate_practical_task_blocks,
|
24 |
)
|
25 |
+
from app.event_handlers.practical_task_sorted import event_handler_practical_task_sorted
|
26 |
|
27 |
|
28 |
def setup_app_event_handlers(
|
|
|
36 |
csv_pt_scores,
|
37 |
practical_tasks,
|
38 |
practical_subtasks,
|
39 |
+
settings_practical_tasks,
|
40 |
+
threshold_professional_skills,
|
41 |
+
dropdown_professional_skills,
|
42 |
calculate_practical_task,
|
43 |
practical_subtasks_selected,
|
44 |
practical_tasks_column,
|
45 |
+
sorted_videos,
|
46 |
+
sorted_videos_column,
|
47 |
practical_task_sorted,
|
48 |
csv_practical_task_sorted,
|
49 |
+
video_sorted,
|
50 |
in_development,
|
51 |
):
|
52 |
# Events
|
|
|
76 |
practical_tasks,
|
77 |
practical_subtasks,
|
78 |
practical_subtasks_selected,
|
79 |
+
settings_practical_tasks,
|
80 |
+
threshold_professional_skills,
|
81 |
+
dropdown_professional_skills,
|
82 |
calculate_practical_task,
|
83 |
+
sorted_videos,
|
84 |
+
sorted_videos_column,
|
85 |
practical_task_sorted,
|
86 |
csv_practical_task_sorted,
|
87 |
+
video_sorted,
|
88 |
in_development,
|
89 |
],
|
90 |
queue=True,
|
|
|
112 |
practical_tasks,
|
113 |
practical_subtasks,
|
114 |
practical_subtasks_selected,
|
115 |
+
settings_practical_tasks,
|
116 |
+
threshold_professional_skills,
|
117 |
+
dropdown_professional_skills,
|
118 |
+
sorted_videos,
|
119 |
+
sorted_videos_column,
|
120 |
practical_task_sorted,
|
121 |
csv_practical_task_sorted,
|
122 |
+
video_sorted,
|
123 |
in_development,
|
124 |
],
|
125 |
queue=True,
|
|
|
133 |
practical_subtasks.change(
|
134 |
event_handler_practical_subtasks,
|
135 |
[practical_tasks, practical_subtasks, practical_subtasks_selected],
|
136 |
+
[
|
137 |
+
practical_subtasks_selected,
|
138 |
+
settings_practical_tasks,
|
139 |
+
threshold_professional_skills,
|
140 |
+
dropdown_professional_skills,
|
141 |
+
],
|
142 |
queue=True,
|
143 |
)
|
144 |
calculate_practical_task.click(
|
145 |
fn=event_handler_calculate_practical_task_blocks,
|
146 |
+
inputs=[
|
147 |
+
files,
|
148 |
+
practical_subtasks,
|
149 |
+
pt_scores,
|
150 |
+
threshold_professional_skills,
|
151 |
+
dropdown_professional_skills,
|
152 |
+
],
|
153 |
outputs=[
|
154 |
+
sorted_videos,
|
155 |
+
sorted_videos_column,
|
156 |
practical_task_sorted,
|
157 |
csv_practical_task_sorted,
|
158 |
+
video_sorted,
|
159 |
in_development,
|
160 |
],
|
161 |
queue=True,
|
162 |
)
|
163 |
+
practical_task_sorted.select(
|
164 |
+
event_handler_practical_task_sorted,
|
165 |
+
[files, practical_task_sorted],
|
166 |
+
[video_sorted],
|
167 |
+
queue=True,
|
168 |
+
)
|
app/event_handlers/practical_subtasks.py
CHANGED
@@ -5,7 +5,11 @@ Description: Event handler for Gradio app to filter practical subtasks based on
|
|
5 |
License: MIT License
|
6 |
"""
|
7 |
|
|
|
|
|
8 |
# Importing necessary components for the Gradio app
|
|
|
|
|
9 |
|
10 |
|
11 |
def event_handler_practical_subtasks(
|
@@ -13,4 +17,36 @@ def event_handler_practical_subtasks(
|
|
13 |
):
|
14 |
practical_subtasks_selected[practical_tasks] = practical_subtasks
|
15 |
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 threshold_create_ui, dropdown_create_ui
|
13 |
|
14 |
|
15 |
def event_handler_practical_subtasks(
|
|
|
17 |
):
|
18 |
practical_subtasks_selected[practical_tasks] = practical_subtasks
|
19 |
|
20 |
+
if practical_subtasks.lower() == "professional skills":
|
21 |
+
return (
|
22 |
+
practical_subtasks_selected,
|
23 |
+
gr.Column(visible=True),
|
24 |
+
threshold_create_ui(
|
25 |
+
value=0.5,
|
26 |
+
minimum=0.0,
|
27 |
+
maximum=1.0,
|
28 |
+
step=0.01,
|
29 |
+
label=config_data.Labels_THRESHOLD_PROFESSIONAL_SKILLS_LABEL,
|
30 |
+
info=config_data.InformationMessages_THRESHOLD_PROFESSIONAL_SKILLS_INFO,
|
31 |
+
show_label=True,
|
32 |
+
interactive=True,
|
33 |
+
visible=True,
|
34 |
+
render=True,
|
35 |
+
elem_classes="number-container",
|
36 |
+
),
|
37 |
+
dropdown_create_ui(
|
38 |
+
label=f"Professional skills ({len(config_data.Settings_DROPDOWN_PROFESSIONAL_SKILLS)})",
|
39 |
+
info=config_data.InformationMessages_DROPDOWN_PROFESSIONAL_SKILLS_INFO,
|
40 |
+
choices=config_data.Settings_DROPDOWN_PROFESSIONAL_SKILLS,
|
41 |
+
value=config_data.Settings_DROPDOWN_PROFESSIONAL_SKILLS[0],
|
42 |
+
visible=True,
|
43 |
+
elem_classes="dropdown-container",
|
44 |
+
),
|
45 |
+
)
|
46 |
+
else:
|
47 |
+
return (
|
48 |
+
practical_subtasks_selected,
|
49 |
+
gr.Column(visible=False),
|
50 |
+
threshold_create_ui(visible=False),
|
51 |
+
dropdown_create_ui(visible=False),
|
52 |
+
)
|
app/event_handlers/practical_task_sorted.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
File: practical_task_sorted.py
|
3 |
+
Author: Elena Ryumina and Dmitry Ryumin
|
4 |
+
Description: Event handler for the practical task sorted to the Gradio app.
|
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.components import video_create_ui
|
13 |
+
|
14 |
+
|
15 |
+
def event_handler_practical_task_sorted(
|
16 |
+
files, practical_task_sorted, evt_data: gr.SelectData
|
17 |
+
):
|
18 |
+
# print(
|
19 |
+
# f"{evt_data.value}, {evt_data.index}, {evt_data.target}, {evt_data.selected}, {evt_data._data}"
|
20 |
+
# )
|
21 |
+
# print(practical_task_sorted)
|
22 |
+
|
23 |
+
# print(evt_data, evt_data.index[0], practical_task_sorted.iloc[evt_data.index[0]])
|
24 |
+
|
25 |
+
person_id = int(practical_task_sorted.iloc[evt_data.index[0]]["Person ID"]) - 1
|
26 |
+
|
27 |
+
if evt_data.index[0] == 0:
|
28 |
+
label = "Best"
|
29 |
+
else:
|
30 |
+
label = ""
|
31 |
+
label += " Person ID"
|
32 |
+
|
33 |
+
return video_create_ui(
|
34 |
+
value=files[person_id],
|
35 |
+
file_name=Path(files[person_id]).name,
|
36 |
+
label=f"{label} - " + str(person_id + 1),
|
37 |
+
visible=True,
|
38 |
+
)
|
app/tabs.py
CHANGED
@@ -19,6 +19,8 @@ from app.components import (
|
|
19 |
button,
|
20 |
dataframe,
|
21 |
radio_create_ui,
|
|
|
|
|
22 |
)
|
23 |
|
24 |
|
@@ -81,26 +83,63 @@ def app_tab():
|
|
81 |
True,
|
82 |
)
|
83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
calculate_practical_task = button(
|
85 |
config_data.OtherMessages_CALCULATE_PRACTICAL_TASK,
|
86 |
True,
|
87 |
1,
|
88 |
-
|
89 |
"calculate_practical_task",
|
90 |
)
|
91 |
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
|
105 |
practical_subtasks_selected = gr.JSON(
|
106 |
value={
|
@@ -126,11 +165,17 @@ def app_tab():
|
|
126 |
csv_pt_scores,
|
127 |
practical_tasks,
|
128 |
practical_subtasks,
|
|
|
|
|
|
|
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 |
|
|
|
19 |
button,
|
20 |
dataframe,
|
21 |
radio_create_ui,
|
22 |
+
threshold_create_ui,
|
23 |
+
dropdown_create_ui,
|
24 |
)
|
25 |
|
26 |
|
|
|
83 |
True,
|
84 |
)
|
85 |
|
86 |
+
with gr.Row(
|
87 |
+
visible=False,
|
88 |
+
render=True,
|
89 |
+
variant="default",
|
90 |
+
elem_classes="settings-container",
|
91 |
+
) as settings_practical_tasks:
|
92 |
+
threshold_professional_skills = threshold_create_ui(
|
93 |
+
value=0.5,
|
94 |
+
minimum=0.0,
|
95 |
+
maximum=1.0,
|
96 |
+
step=0.01,
|
97 |
+
label=config_data.Labels_THRESHOLD_PROFESSIONAL_SKILLS_LABEL,
|
98 |
+
info=config_data.InformationMessages_THRESHOLD_PROFESSIONAL_SKILLS_INFO,
|
99 |
+
show_label=True,
|
100 |
+
interactive=True,
|
101 |
+
visible=False,
|
102 |
+
render=True,
|
103 |
+
elem_classes="number-container",
|
104 |
+
)
|
105 |
+
|
106 |
+
dropdown_professional_skills = dropdown_create_ui(
|
107 |
+
label=f"Professional skills ({len(config_data.Settings_DROPDOWN_PROFESSIONAL_SKILLS)})",
|
108 |
+
info=config_data.InformationMessages_DROPDOWN_PROFESSIONAL_SKILLS_INFO,
|
109 |
+
choices=config_data.Settings_DROPDOWN_PROFESSIONAL_SKILLS,
|
110 |
+
value=config_data.Settings_DROPDOWN_PROFESSIONAL_SKILLS[0],
|
111 |
+
visible=False,
|
112 |
+
elem_classes="dropdown-container",
|
113 |
+
)
|
114 |
+
|
115 |
calculate_practical_task = button(
|
116 |
config_data.OtherMessages_CALCULATE_PRACTICAL_TASK,
|
117 |
True,
|
118 |
1,
|
119 |
+
False,
|
120 |
"calculate_practical_task",
|
121 |
)
|
122 |
|
123 |
+
with gr.Row(
|
124 |
+
visible=False,
|
125 |
+
render=True,
|
126 |
+
variant="default",
|
127 |
+
) as sorted_videos:
|
128 |
+
with gr.Column(scale=1, visible=False, render=True) as sorted_videos_column:
|
129 |
+
practical_task_sorted = dataframe(visible=False)
|
130 |
+
|
131 |
+
csv_practical_task_sorted = files_create_ui(
|
132 |
+
None,
|
133 |
+
"single",
|
134 |
+
[".csv"],
|
135 |
+
config_data.OtherMessages_EXPORT_PS,
|
136 |
+
True,
|
137 |
+
False,
|
138 |
+
False,
|
139 |
+
"csv-container",
|
140 |
+
)
|
141 |
+
|
142 |
+
video_sorted = video_create_ui(visible=False)
|
143 |
|
144 |
practical_subtasks_selected = gr.JSON(
|
145 |
value={
|
|
|
165 |
csv_pt_scores,
|
166 |
practical_tasks,
|
167 |
practical_subtasks,
|
168 |
+
settings_practical_tasks,
|
169 |
+
threshold_professional_skills,
|
170 |
+
dropdown_professional_skills,
|
171 |
calculate_practical_task,
|
172 |
practical_subtasks_selected,
|
173 |
practical_tasks_column,
|
174 |
+
sorted_videos,
|
175 |
+
sorted_videos_column,
|
176 |
practical_task_sorted,
|
177 |
csv_practical_task_sorted,
|
178 |
+
video_sorted,
|
179 |
in_development,
|
180 |
)
|
181 |
|
config.toml
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
[AppSettings]
|
2 |
-
APP_VERSION = "0.
|
3 |
CSS_PATH = "app.css"
|
4 |
|
5 |
[InformationMessages]
|
@@ -7,6 +7,8 @@ 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"
|
@@ -20,6 +22,7 @@ NOTI_CALCULATE = "You can calculate Big Five personality traits scores"
|
|
20 |
[Labels]
|
21 |
PRACTICAL_TASKS_LABEL = "Practical tasks"
|
22 |
PRACTICAL_SUBTASKS_LABEL = "Practical subtasks"
|
|
|
23 |
|
24 |
[TabCreators]
|
25 |
"App" = "app_tab"
|
@@ -29,5 +32,8 @@ PRACTICAL_SUBTASKS_LABEL = "Practical subtasks"
|
|
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"
|
|
|
1 |
[AppSettings]
|
2 |
+
APP_VERSION = "0.5.0"
|
3 |
CSS_PATH = "app.css"
|
4 |
|
5 |
[InformationMessages]
|
|
|
7 |
PRACTICAL_TASKS_INFO = "Choose a practical task"
|
8 |
PRACTICAL_SUBTASKS_INFO = "Choose a practical subtask"
|
9 |
NOTI_IN_DEV = "In development"
|
10 |
+
THRESHOLD_PROFESSIONAL_SKILLS_INFO = "Set threshold from 0 to 1.0"
|
11 |
+
DROPDOWN_PROFESSIONAL_SKILLS_INFO = "What professional skill are you interested in?"
|
12 |
|
13 |
[OtherMessages]
|
14 |
CALCULATE_PT_SCORES = "Calculation of Big Five personality traits scores"
|
|
|
22 |
[Labels]
|
23 |
PRACTICAL_TASKS_LABEL = "Practical tasks"
|
24 |
PRACTICAL_SUBTASKS_LABEL = "Practical subtasks"
|
25 |
+
THRESHOLD_PROFESSIONAL_SKILLS_LABEL = "Threshold"
|
26 |
|
27 |
[TabCreators]
|
28 |
"App" = "app_tab"
|
|
|
32 |
PT_SCORES = "personality_traits_scores.csv"
|
33 |
PT_SKILLS_SCORES = "personality_skills_scores.csv"
|
34 |
|
35 |
+
[Settings]
|
36 |
+
DROPDOWN_PROFESSIONAL_SKILLS = ["Analytical", "Interactive", "Routine", "Non-Routine"]
|
37 |
+
|
38 |
[Links]
|
39 |
PROFESSIONAL_SKILLS = "https://download.sberdisk.ru/download/file/478678231?token=0qiZwliLtHWWYMv&filename=professional_skills.csv"
|