improve error handling and fix gr.Warning typo

#113
Files changed (2) hide show
  1. text_classification_ui_helpers.py +7 -5
  2. wordings.py +1 -1
text_classification_ui_helpers.py CHANGED
@@ -58,8 +58,8 @@ def check_dataset(dataset_id):
58
  configs = datasets.get_dataset_config_names(dataset_id, trust_remote_code=True)
59
  if len(configs) == 0:
60
  return (
61
- gr.update(),
62
- gr.update(),
63
  ""
64
  )
65
  splits = datasets.get_dataset_split_names(
@@ -72,11 +72,13 @@ def check_dataset(dataset_id):
72
  )
73
  except Exception as e:
74
  logger.warn(f"Check your dataset {dataset_id}: {e}")
 
 
75
  if "forbidden" in str(e).lower(): # GSK-2770
76
- gr.warning(get_dataset_fetch_error_raw(e))
77
  return (
78
- gr.update(),
79
- gr.update(),
80
  ""
81
  )
82
 
 
58
  configs = datasets.get_dataset_config_names(dataset_id, trust_remote_code=True)
59
  if len(configs) == 0:
60
  return (
61
+ gr.update(visible=False),
62
+ gr.update(visible=False),
63
  ""
64
  )
65
  splits = datasets.get_dataset_split_names(
 
72
  )
73
  except Exception as e:
74
  logger.warn(f"Check your dataset {dataset_id}: {e}")
75
+ if "doesn't exist" in str(e):
76
+ gr.Warning(get_dataset_fetch_error_raw(e))
77
  if "forbidden" in str(e).lower(): # GSK-2770
78
+ gr.Warning(get_dataset_fetch_error_raw(e))
79
  return (
80
+ gr.update(visible=False),
81
+ gr.update(visible=False),
82
  ""
83
  )
84
 
wordings.py CHANGED
@@ -67,7 +67,7 @@ HF_TOKEN_INVALID_STYLED= """
67
  """
68
 
69
  def get_dataset_fetch_error_raw(error):
70
- return f"""Sorry you cannot use this dataset because {error} Contact HF team to support this dataset."""
71
 
72
  def get_styled_input(input):
73
  return f"""<h3 style="text-align: center;color: #4ca154; background-color: #e2fbe8; border-radius: 8px; padding: 10px; ">
 
67
  """
68
 
69
  def get_dataset_fetch_error_raw(error):
70
+ return f"""Sorry you cannot use this dataset because {error}. Contact HF team to support this dataset."""
71
 
72
  def get_styled_input(input):
73
  return f"""<h3 style="text-align: center;color: #4ca154; background-color: #e2fbe8; border-radius: 8px; padding: 10px; ">