Spaces:
Running
Running
ZeroCommand
commited on
Commit
•
52ba351
1
Parent(s):
1ead652
add trust remote code param for dataset with scripts
Browse files- app_leaderboard.py +1 -1
- fetch_utils.py +1 -1
- text_classification.py +2 -2
- text_classification_ui_helpers.py +6 -8
app_leaderboard.py
CHANGED
@@ -21,7 +21,7 @@ def get_records_from_dataset_repo(dataset_id):
|
|
21 |
logger.info(f"Dataset {dataset_id} has splits {dataset_split}")
|
22 |
|
23 |
try:
|
24 |
-
ds = datasets.load_dataset(dataset_id, dataset_config[0]
|
25 |
df = ds.to_pandas()
|
26 |
return df
|
27 |
except Exception as e:
|
|
|
21 |
logger.info(f"Dataset {dataset_id} has splits {dataset_split}")
|
22 |
|
23 |
try:
|
24 |
+
ds = datasets.load_dataset(dataset_id, dataset_config[0], split=dataset_split[0])
|
25 |
df = ds.to_pandas()
|
26 |
return df
|
27 |
except Exception as e:
|
fetch_utils.py
CHANGED
@@ -14,7 +14,7 @@ def check_dataset_and_get_config(dataset_id):
|
|
14 |
|
15 |
def check_dataset_and_get_split(dataset_id, dataset_config):
|
16 |
try:
|
17 |
-
ds = datasets.load_dataset(dataset_id, dataset_config)
|
18 |
except Exception as e:
|
19 |
# Dataset may not exist
|
20 |
logging.warning(
|
|
|
14 |
|
15 |
def check_dataset_and_get_split(dataset_id, dataset_config):
|
16 |
try:
|
17 |
+
ds = datasets.load_dataset(dataset_id, dataset_config, trust_remote_code=True)
|
18 |
except Exception as e:
|
19 |
# Dataset may not exist
|
20 |
logging.warning(
|
text_classification.py
CHANGED
@@ -254,7 +254,7 @@ def infer_output_label_column(
|
|
254 |
|
255 |
def check_dataset_features_validity(d_id, config, split):
|
256 |
# We assume dataset is ok here
|
257 |
-
ds = datasets.load_dataset(d_id, config)
|
258 |
try:
|
259 |
dataset_features = ds.features
|
260 |
except AttributeError:
|
@@ -278,7 +278,7 @@ def get_example_prediction(model_id, dataset_id, dataset_config, dataset_split):
|
|
278 |
prediction_result = None
|
279 |
try:
|
280 |
# Use the first item to test prediction
|
281 |
-
ds = datasets.load_dataset(dataset_id, dataset_config)
|
282 |
if "text" not in ds.features.keys():
|
283 |
# Dataset does not have text column
|
284 |
prediction_input = ds[0][select_the_first_string_column(ds)]
|
|
|
254 |
|
255 |
def check_dataset_features_validity(d_id, config, split):
|
256 |
# We assume dataset is ok here
|
257 |
+
ds = datasets.load_dataset(d_id, config, split=split, trust_remote_code=True)
|
258 |
try:
|
259 |
dataset_features = ds.features
|
260 |
except AttributeError:
|
|
|
278 |
prediction_result = None
|
279 |
try:
|
280 |
# Use the first item to test prediction
|
281 |
+
ds = datasets.load_dataset(dataset_id, dataset_config, split=dataset_split, trust_remote_code=True)
|
282 |
if "text" not in ds.features.keys():
|
283 |
# Dataset does not have text column
|
284 |
prediction_input = ds[0][select_the_first_string_column(ds)]
|
text_classification_ui_helpers.py
CHANGED
@@ -59,11 +59,9 @@ def check_dataset(dataset_id):
|
|
59 |
gr.update(),
|
60 |
""
|
61 |
)
|
62 |
-
splits =
|
63 |
-
|
64 |
-
|
65 |
-
).keys()
|
66 |
-
)
|
67 |
return (
|
68 |
gr.update(choices=configs, value=configs[0], visible=True),
|
69 |
gr.update(choices=splits, value=splits[0], visible=True),
|
@@ -176,7 +174,7 @@ def precheck_model_ds_enable_example_btn(
|
|
176 |
return (gr.update(), gr.update(), "")
|
177 |
|
178 |
try:
|
179 |
-
ds = datasets.load_dataset(dataset_id, dataset_config)
|
180 |
df: pd.DataFrame = ds[dataset_split].to_pandas().head(5)
|
181 |
ds_labels, ds_features = get_labels_and_features_from_dataset(ds[dataset_split])
|
182 |
|
@@ -243,7 +241,7 @@ def align_columns_and_show_prediction(
|
|
243 |
|
244 |
model_labels = list(prediction_response.keys())
|
245 |
|
246 |
-
ds = datasets.load_dataset(dataset_id, dataset_config)
|
247 |
ds_labels, ds_features = get_labels_and_features_from_dataset(ds)
|
248 |
|
249 |
# when dataset does not have labels or features
|
@@ -334,7 +332,7 @@ def try_submit(m_id, d_id, config, split, inference, inference_token, uid):
|
|
334 |
check_column_mapping_keys_validity(all_mappings)
|
335 |
|
336 |
# get ds labels and features again for alignment
|
337 |
-
ds = datasets.load_dataset(d_id, config)
|
338 |
ds_labels, ds_features = get_labels_and_features_from_dataset(ds)
|
339 |
label_mapping, feature_mapping = construct_label_and_feature_mapping(all_mappings, ds_labels, ds_features)
|
340 |
|
|
|
59 |
gr.update(),
|
60 |
""
|
61 |
)
|
62 |
+
splits = datasets.get_dataset_split_names(
|
63 |
+
dataset_id, configs[0], trust_remote_code=True
|
64 |
+
)
|
|
|
|
|
65 |
return (
|
66 |
gr.update(choices=configs, value=configs[0], visible=True),
|
67 |
gr.update(choices=splits, value=splits[0], visible=True),
|
|
|
174 |
return (gr.update(), gr.update(), "")
|
175 |
|
176 |
try:
|
177 |
+
ds = datasets.load_dataset(dataset_id, dataset_config, trust_remote_code=True)
|
178 |
df: pd.DataFrame = ds[dataset_split].to_pandas().head(5)
|
179 |
ds_labels, ds_features = get_labels_and_features_from_dataset(ds[dataset_split])
|
180 |
|
|
|
241 |
|
242 |
model_labels = list(prediction_response.keys())
|
243 |
|
244 |
+
ds = datasets.load_dataset(dataset_id, dataset_config, split=dataset_split, trust_remote_code=True)
|
245 |
ds_labels, ds_features = get_labels_and_features_from_dataset(ds)
|
246 |
|
247 |
# when dataset does not have labels or features
|
|
|
332 |
check_column_mapping_keys_validity(all_mappings)
|
333 |
|
334 |
# get ds labels and features again for alignment
|
335 |
+
ds = datasets.load_dataset(d_id, config, split=split, trust_remote_code=True)
|
336 |
ds_labels, ds_features = get_labels_and_features_from_dataset(ds)
|
337 |
label_mapping, feature_mapping = construct_label_and_feature_mapping(all_mappings, ds_labels, ds_features)
|
338 |
|