Spaces:
Running
Running
ZeroCommand
commited on
Commit
•
85a8a8b
1
Parent(s):
1b20cb8
Improve-pre-submission-checking (#105)
Browse files- add get prediction sample from the hf token (73f688fa9627d0cb4d104c10061daf24b9542de1)
- app_text_classification.py +11 -7
app_text_classification.py
CHANGED
@@ -12,11 +12,8 @@ from text_classification_ui_helpers import (
|
|
12 |
try_submit,
|
13 |
write_column_mapping_to_config,
|
14 |
)
|
15 |
-
|
16 |
-
|
17 |
-
get_example_prediction,
|
18 |
-
HuggingFaceInferenceAPIResponse
|
19 |
-
)
|
20 |
from wordings import (
|
21 |
CONFIRM_MAPPING_DETAILS_MD,
|
22 |
INTRODUCTION_MD,
|
@@ -30,7 +27,7 @@ MAX_FEATURES = 20
|
|
30 |
|
31 |
EXAMPLE_MODEL_ID = "cardiffnlp/twitter-roberta-base-sentiment-latest"
|
32 |
CONFIG_PATH = "./config.yaml"
|
33 |
-
|
34 |
|
35 |
def get_demo():
|
36 |
with gr.Row():
|
@@ -239,12 +236,19 @@ def get_demo():
|
|
239 |
|
240 |
def enable_run_btn(run_inference, inference_token, model_id, dataset_id, dataset_config, dataset_split):
|
241 |
if not run_inference or inference_token == "":
|
|
|
242 |
return gr.update(interactive=False)
|
243 |
if model_id == "" or dataset_id == "" or dataset_config == "" or dataset_split == "":
|
|
|
244 |
return gr.update(interactive=False)
|
245 |
if not column_mapping_accordion.visible:
|
|
|
246 |
return gr.update(interactive=False)
|
247 |
-
|
|
|
|
|
|
|
|
|
248 |
return gr.update(interactive=False)
|
249 |
return gr.update(interactive=True)
|
250 |
|
|
|
12 |
try_submit,
|
13 |
write_column_mapping_to_config,
|
14 |
)
|
15 |
+
from text_classification import get_example_prediction, HuggingFaceInferenceAPIResponse
|
16 |
+
import logging
|
|
|
|
|
|
|
17 |
from wordings import (
|
18 |
CONFIRM_MAPPING_DETAILS_MD,
|
19 |
INTRODUCTION_MD,
|
|
|
27 |
|
28 |
EXAMPLE_MODEL_ID = "cardiffnlp/twitter-roberta-base-sentiment-latest"
|
29 |
CONFIG_PATH = "./config.yaml"
|
30 |
+
logger = logging.getLogger(__name__)
|
31 |
|
32 |
def get_demo():
|
33 |
with gr.Row():
|
|
|
236 |
|
237 |
def enable_run_btn(run_inference, inference_token, model_id, dataset_id, dataset_config, dataset_split):
|
238 |
if not run_inference or inference_token == "":
|
239 |
+
logger.warn("Inference API is not enabled")
|
240 |
return gr.update(interactive=False)
|
241 |
if model_id == "" or dataset_id == "" or dataset_config == "" or dataset_split == "":
|
242 |
+
logger.warn("Model id or dataset id is not selected")
|
243 |
return gr.update(interactive=False)
|
244 |
if not column_mapping_accordion.visible:
|
245 |
+
logger.warn("Column mapping is not confirmed")
|
246 |
return gr.update(interactive=False)
|
247 |
+
_, prediction_response = get_example_prediction(
|
248 |
+
model_id, dataset_id, dataset_config, dataset_split, inference_token
|
249 |
+
)
|
250 |
+
if not isinstance(prediction_response, HuggingFaceInferenceAPIResponse):
|
251 |
+
logger.warn("Failed to get example prediction from inference API with this token")
|
252 |
return gr.update(interactive=False)
|
253 |
return gr.update(interactive=True)
|
254 |
|