ZeroCommand commited on
Commit
55c122a
1 Parent(s): 0c7a648

wrap hf dataset error

Browse files
Files changed (2) hide show
  1. text_classification_ui_helpers.py +3 -0
  2. wordings.py +3 -0
text_classification_ui_helpers.py CHANGED
@@ -26,6 +26,7 @@ from wordings import (
26
  UNMATCHED_MODEL_DATASET_STYLED_ERROR,
27
  CHECK_LOG_SECTION_RAW,
28
  get_styled_input,
 
29
  )
30
  import os
31
 
@@ -70,6 +71,8 @@ def check_dataset(dataset_id):
70
  )
71
  except Exception as e:
72
  logger.warn(f"Check your dataset {dataset_id}: {e}")
 
 
73
  return (
74
  gr.update(),
75
  gr.update(),
 
26
  UNMATCHED_MODEL_DATASET_STYLED_ERROR,
27
  CHECK_LOG_SECTION_RAW,
28
  get_styled_input,
29
+ get_dataset_fetch_error_raw,
30
  )
31
  import os
32
 
 
71
  )
72
  except Exception as e:
73
  logger.warn(f"Check your dataset {dataset_id}: {e}")
74
+ if "forbidden" in str(e).lower(): # GSK-2770
75
+ gr.warning(get_dataset_fetch_error_raw(e))
76
  return (
77
  gr.update(),
78
  gr.update(),
wordings.py CHANGED
@@ -77,6 +77,9 @@ HF_TOKEN_INVALID_STYLED= """
77
  </p>
78
  """
79
 
 
 
 
80
  def get_styled_input(input):
81
  return f"""<h3 style="text-align: center;color: #4ca154; background-color: #e2fbe8; border-radius: 8px; padding: 10px; ">
82
  Your model and dataset have been validated! <br /> Sample input: {input}
 
77
  </p>
78
  """
79
 
80
+ def get_dataset_fetch_error_raw(error):
81
+ return f"""Sorry you cannot use this dataset because {error} Contact HF team to support this dataset."""
82
+
83
  def get_styled_input(input):
84
  return f"""<h3 style="text-align: center;color: #4ca154; background-color: #e2fbe8; border-radius: 8px; padding: 10px; ">
85
  Your model and dataset have been validated! <br /> Sample input: {input}