ZeroCommand
commited on
Commit
β’
6ce8c6e
1
Parent(s):
c33448f
update latest changes (#2)
Browse files- latest changes (37821c351815a5166af629bd4985671a5df4cf55)
- app_text_classification.py +7 -5
- text_classification_ui_helpers.py +18 -5
- wordings.py +9 -1
app_text_classification.py
CHANGED
@@ -2,7 +2,7 @@ import uuid
|
|
2 |
|
3 |
import gradio as gr
|
4 |
|
5 |
-
from io_utils import
|
6 |
from text_classification_ui_helpers import (
|
7 |
get_related_datasets_from_leaderboard,
|
8 |
align_columns_and_show_prediction,
|
@@ -11,7 +11,7 @@ from text_classification_ui_helpers import (
|
|
11 |
try_submit,
|
12 |
write_column_mapping_to_config,
|
13 |
)
|
14 |
-
from wordings import CONFIRM_MAPPING_DETAILS_MD, INTRODUCTION_MD, USE_INFERENCE_API_TIP
|
15 |
|
16 |
MAX_LABELS = 40
|
17 |
MAX_FEATURES = 20
|
@@ -114,8 +114,8 @@ def get_demo():
|
|
114 |
|
115 |
with gr.Row():
|
116 |
logs = gr.Textbox(
|
117 |
-
value=
|
118 |
-
label="Giskard Bot Evaluation
|
119 |
visible=False,
|
120 |
every=0.5,
|
121 |
)
|
@@ -135,7 +135,7 @@ def get_demo():
|
|
135 |
)
|
136 |
|
137 |
gr.on(
|
138 |
-
triggers=[dataset_id_input.
|
139 |
fn=check_dataset,
|
140 |
inputs=[dataset_id_input],
|
141 |
outputs=[dataset_config_input, dataset_split_input, loading_status]
|
@@ -223,6 +223,8 @@ def get_demo():
|
|
223 |
return gr.update(interactive=False)
|
224 |
if model_id == "" or dataset_id == "" or dataset_config == "" or dataset_split == "":
|
225 |
return gr.update(interactive=False)
|
|
|
|
|
226 |
return gr.update(interactive=True)
|
227 |
|
228 |
gr.on(
|
|
|
2 |
|
3 |
import gradio as gr
|
4 |
|
5 |
+
from io_utils import read_scanners, write_scanners
|
6 |
from text_classification_ui_helpers import (
|
7 |
get_related_datasets_from_leaderboard,
|
8 |
align_columns_and_show_prediction,
|
|
|
11 |
try_submit,
|
12 |
write_column_mapping_to_config,
|
13 |
)
|
14 |
+
from wordings import CONFIRM_MAPPING_DETAILS_MD, INTRODUCTION_MD, USE_INFERENCE_API_TIP, CHECK_LOG_SECTION_RAW
|
15 |
|
16 |
MAX_LABELS = 40
|
17 |
MAX_FEATURES = 20
|
|
|
114 |
|
115 |
with gr.Row():
|
116 |
logs = gr.Textbox(
|
117 |
+
value=CHECK_LOG_SECTION_RAW,
|
118 |
+
label="Giskard Bot Evaluation Guide:",
|
119 |
visible=False,
|
120 |
every=0.5,
|
121 |
)
|
|
|
135 |
)
|
136 |
|
137 |
gr.on(
|
138 |
+
triggers=[dataset_id_input.change],
|
139 |
fn=check_dataset,
|
140 |
inputs=[dataset_id_input],
|
141 |
outputs=[dataset_config_input, dataset_split_input, loading_status]
|
|
|
223 |
return gr.update(interactive=False)
|
224 |
if model_id == "" or dataset_id == "" or dataset_config == "" or dataset_split == "":
|
225 |
return gr.update(interactive=False)
|
226 |
+
if not column_mapping_accordion.visible:
|
227 |
+
return gr.update(interactive=False)
|
228 |
return gr.update(interactive=True)
|
229 |
|
230 |
gr.on(
|
text_classification_ui_helpers.py
CHANGED
@@ -23,6 +23,8 @@ from wordings import (
|
|
23 |
CONFIRM_MAPPING_DETAILS_FAIL_RAW,
|
24 |
MAPPING_STYLED_ERROR_WARNING,
|
25 |
NOT_TEXT_CLASSIFICATION_MODEL_RAW,
|
|
|
|
|
26 |
get_styled_input,
|
27 |
)
|
28 |
|
@@ -41,7 +43,7 @@ def get_related_datasets_from_leaderboard(model_id):
|
|
41 |
if len(datasets_unique) == 0:
|
42 |
return gr.update(choices=[], value="")
|
43 |
|
44 |
-
return gr.update(choices=datasets_unique, value=
|
45 |
|
46 |
|
47 |
logger = logging.getLogger(__file__)
|
@@ -185,7 +187,7 @@ def precheck_model_ds_enable_example_btn(
|
|
185 |
return (gr.update(interactive=True), gr.update(value=df, visible=True), "")
|
186 |
except Exception as e:
|
187 |
# Config or split wrong
|
188 |
-
|
189 |
return (gr.update(interactive=False), gr.update(value=pd.DataFrame(), visible=False), "")
|
190 |
|
191 |
|
@@ -255,6 +257,17 @@ def align_columns_and_show_prediction(
|
|
255 |
"",
|
256 |
*dropdown_placement,
|
257 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
258 |
|
259 |
column_mappings = list_labels_and_features_from_dataset(
|
260 |
ds_labels,
|
@@ -301,10 +314,10 @@ def check_column_mapping_keys_validity(all_mappings):
|
|
301 |
def construct_label_and_feature_mapping(all_mappings, ds_labels, ds_features):
|
302 |
label_mapping = {}
|
303 |
if len(all_mappings["labels"].keys()) != len(ds_labels):
|
304 |
-
|
305 |
|
306 |
if len(all_mappings["features"].keys()) != len(ds_features):
|
307 |
-
|
308 |
|
309 |
for i, label in zip(range(len(ds_labels)), ds_labels):
|
310 |
# align the saved labels with dataset labels order
|
@@ -346,6 +359,6 @@ def try_submit(m_id, d_id, config, split, inference, inference_token, uid):
|
|
346 |
|
347 |
return (
|
348 |
gr.update(interactive=False), # Submit button
|
349 |
-
gr.update(lines=5, visible=True, interactive=False),
|
350 |
uuid.uuid4(), # Allocate a new uuid
|
351 |
)
|
|
|
23 |
CONFIRM_MAPPING_DETAILS_FAIL_RAW,
|
24 |
MAPPING_STYLED_ERROR_WARNING,
|
25 |
NOT_TEXT_CLASSIFICATION_MODEL_RAW,
|
26 |
+
UNMATCHED_MODEL_DATASET,
|
27 |
+
CHECK_LOG_SECTION_RAW,
|
28 |
get_styled_input,
|
29 |
)
|
30 |
|
|
|
43 |
if len(datasets_unique) == 0:
|
44 |
return gr.update(choices=[], value="")
|
45 |
|
46 |
+
return gr.update(choices=datasets_unique, value="")
|
47 |
|
48 |
|
49 |
logger = logging.getLogger(__file__)
|
|
|
187 |
return (gr.update(interactive=True), gr.update(value=df, visible=True), "")
|
188 |
except Exception as e:
|
189 |
# Config or split wrong
|
190 |
+
logger.warn(f"Check your dataset {dataset_id} and config {dataset_config} on split {dataset_split}: {e}")
|
191 |
return (gr.update(interactive=False), gr.update(value=pd.DataFrame(), visible=False), "")
|
192 |
|
193 |
|
|
|
257 |
"",
|
258 |
*dropdown_placement,
|
259 |
)
|
260 |
+
|
261 |
+
if len(ds_labels) != len(model_labels):
|
262 |
+
gr.Warning(UNMATCHED_MODEL_DATASET)
|
263 |
+
return (
|
264 |
+
gr.update(visible=False),
|
265 |
+
gr.update(visible=False),
|
266 |
+
gr.update(visible=False, open=False),
|
267 |
+
gr.update(interactive=False),
|
268 |
+
"",
|
269 |
+
*dropdown_placement,
|
270 |
+
)
|
271 |
|
272 |
column_mappings = list_labels_and_features_from_dataset(
|
273 |
ds_labels,
|
|
|
314 |
def construct_label_and_feature_mapping(all_mappings, ds_labels, ds_features):
|
315 |
label_mapping = {}
|
316 |
if len(all_mappings["labels"].keys()) != len(ds_labels):
|
317 |
+
logger.warn("Label mapping corrupted: " + CONFIRM_MAPPING_DETAILS_FAIL_RAW)
|
318 |
|
319 |
if len(all_mappings["features"].keys()) != len(ds_features):
|
320 |
+
logger.warn("Feature mapping corrupted: " + CONFIRM_MAPPING_DETAILS_FAIL_RAW)
|
321 |
|
322 |
for i, label in zip(range(len(ds_labels)), ds_labels):
|
323 |
# align the saved labels with dataset labels order
|
|
|
359 |
|
360 |
return (
|
361 |
gr.update(interactive=False), # Submit button
|
362 |
+
gr.update(value=f"{CHECK_LOG_SECTION_RAW}Your job id is: {uid}. ", lines=5, visible=True, interactive=False),
|
363 |
uuid.uuid4(), # Allocate a new uuid
|
364 |
)
|
wordings.py
CHANGED
@@ -17,14 +17,22 @@ CONFIRM_MAPPING_DETAILS_FAIL_MD = """
|
|
17 |
Sorry, we cannot align the input/output of your dataset with the model. <b>Pleaser double check your model and dataset.</b>
|
18 |
"""
|
19 |
|
|
|
|
|
|
|
|
|
20 |
CONFIRM_MAPPING_DETAILS_FAIL_RAW = """
|
21 |
-
Sorry, we cannot align the input/output of your dataset with the model.
|
22 |
"""
|
23 |
|
24 |
CHECK_CONFIG_OR_SPLIT_RAW = """
|
25 |
Please check your dataset config or split.
|
26 |
"""
|
27 |
|
|
|
|
|
|
|
|
|
28 |
PREDICTION_SAMPLE_MD = """
|
29 |
<h1 style="text-align: center;">
|
30 |
Model Prediction Sample
|
|
|
17 |
Sorry, we cannot align the input/output of your dataset with the model. <b>Pleaser double check your model and dataset.</b>
|
18 |
"""
|
19 |
|
20 |
+
UNMATCHED_MODEL_DATASET = """
|
21 |
+
Model prediction labels do not align with the labels present in the dataset. Please double check your model and dataset.
|
22 |
+
"""
|
23 |
+
|
24 |
CONFIRM_MAPPING_DETAILS_FAIL_RAW = """
|
25 |
+
Sorry, we cannot auto-align the input/output of your dataset with the model.
|
26 |
"""
|
27 |
|
28 |
CHECK_CONFIG_OR_SPLIT_RAW = """
|
29 |
Please check your dataset config or split.
|
30 |
"""
|
31 |
|
32 |
+
CHECK_LOG_SECTION_RAW = """
|
33 |
+
Your have successfully submitted a Giskard evaluation. Further details are available in the Logs tab, providing information on your queue status and the current job log.
|
34 |
+
"""
|
35 |
+
|
36 |
PREDICTION_SAMPLE_MD = """
|
37 |
<h1 style="text-align: center;">
|
38 |
Model Prediction Sample
|