ZeroCommand commited on
Commit
f9983ab
1 Parent(s): 5f9a95f

remove overused warnings & fix wording & prevent un-matchable models and datasets submissions

Browse files
app_text_classification.py CHANGED
@@ -2,7 +2,7 @@ import uuid
2
 
3
  import gradio as gr
4
 
5
- from io_utils import get_logs_file, read_scanners, write_scanners
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=get_logs_file,
118
- label="Giskard Bot Evaluation Log:",
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.input],
139
  fn=check_dataset,
140
  inputs=[dataset_id_input],
141
  outputs=[dataset_config_input, dataset_split_input, loading_status]
 
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]
text_classification_ui_helpers.py CHANGED
@@ -23,6 +23,7 @@ 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 +42,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=datasets_unique[0])
45
 
46
 
47
  logger = logging.getLogger(__file__)
@@ -185,7 +186,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
- gr.Warning(f"Failed to load dataset {dataset_id} with config {dataset_config}: {e}")
189
  return (gr.update(interactive=False), gr.update(value=pd.DataFrame(), visible=False), "")
190
 
191
 
@@ -255,6 +256,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 +313,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
- gr.Warning("Label mapping corrupted: " + CONFIRM_MAPPING_DETAILS_FAIL_RAW)
305
 
306
  if len(all_mappings["features"].keys()) != len(ds_features):
307
- gr.Warning("Feature mapping corrupted: " + CONFIRM_MAPPING_DETAILS_FAIL_RAW)
308
 
309
  for i, label in zip(range(len(ds_labels)), ds_labels):
310
  # align the saved labels with dataset labels order
 
23
  CONFIRM_MAPPING_DETAILS_FAIL_RAW,
24
  MAPPING_STYLED_ERROR_WARNING,
25
  NOT_TEXT_CLASSIFICATION_MODEL_RAW,
26
+ UNMATCHED_MODEL_DATASET,
27
  get_styled_input,
28
  )
29
 
 
42
  if len(datasets_unique) == 0:
43
  return gr.update(choices=[], value="")
44
 
45
+ return gr.update(choices=datasets_unique, value="")
46
 
47
 
48
  logger = logging.getLogger(__file__)
 
186
  return (gr.update(interactive=True), gr.update(value=df, visible=True), "")
187
  except Exception as e:
188
  # Config or split wrong
189
+ logger.warn(f"Check your dataset {dataset_id} and config {dataset_config} on split {dataset_split}: {e}")
190
  return (gr.update(interactive=False), gr.update(value=pd.DataFrame(), visible=False), "")
191
 
192
 
 
256
  "",
257
  *dropdown_placement,
258
  )
259
+
260
+ if len(ds_labels) != len(model_labels):
261
+ gr.Warning(UNMATCHED_MODEL_DATASET)
262
+ return (
263
+ gr.update(visible=False),
264
+ gr.update(visible=False),
265
+ gr.update(visible=False, open=False),
266
+ gr.update(interactive=False),
267
+ "",
268
+ *dropdown_placement,
269
+ )
270
 
271
  column_mappings = list_labels_and_features_from_dataset(
272
  ds_labels,
 
313
  def construct_label_and_feature_mapping(all_mappings, ds_labels, ds_features):
314
  label_mapping = {}
315
  if len(all_mappings["labels"].keys()) != len(ds_labels):
316
+ logger.warn("Label mapping corrupted: " + CONFIRM_MAPPING_DETAILS_FAIL_RAW)
317
 
318
  if len(all_mappings["features"].keys()) != len(ds_features):
319
+ logger.warn("Feature mapping corrupted: " + CONFIRM_MAPPING_DETAILS_FAIL_RAW)
320
 
321
  for i, label in zip(range(len(ds_labels)), ds_labels):
322
  # align the saved labels with dataset labels order
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. Pleaser double check your model and dataset.
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 evaluation job has been successfully submitted. 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