Junya Morioka
commited on
Remove datasets.tasks and add trust_remote_code (#17)
Browse files* remove datasets.tasks and add trust_remote_code
* fix download marc_ja
* format and fix test
* add comment
- JGLUE.py +9 -9
- tests/JGLUE_test.py +5 -0
JGLUE.py
CHANGED
|
@@ -8,7 +8,6 @@ from typing import Dict, List, Literal, Optional
|
|
| 8 |
|
| 9 |
import datasets as ds
|
| 10 |
import pandas as pd
|
| 11 |
-
from datasets.tasks import QuestionAnsweringExtractive
|
| 12 |
|
| 13 |
logger = logging.getLogger(__name__)
|
| 14 |
|
|
@@ -201,13 +200,6 @@ def dataset_info_jsquad() -> ds.DatasetInfo:
|
|
| 201 |
license=_JGLUE_LICENSE,
|
| 202 |
features=features,
|
| 203 |
supervised_keys=None,
|
| 204 |
-
task_templates=[
|
| 205 |
-
QuestionAnsweringExtractive(
|
| 206 |
-
question_column="question",
|
| 207 |
-
context_column="context",
|
| 208 |
-
answers_column="answers",
|
| 209 |
-
)
|
| 210 |
-
],
|
| 211 |
)
|
| 212 |
|
| 213 |
|
|
@@ -592,7 +584,15 @@ class JGLUE(ds.GeneratorBasedBuilder):
|
|
| 592 |
raise ValueError(f"Invalid config name: {self.config.name}")
|
| 593 |
|
| 594 |
def __split_generators_marc_ja(self, dl_manager: ds.DownloadManager):
|
| 595 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 596 |
|
| 597 |
filter_review_id_list = file_paths["filter_review_id_list"]
|
| 598 |
label_conv_review_id_list = file_paths["label_conv_review_id_list"]
|
|
|
|
| 8 |
|
| 9 |
import datasets as ds
|
| 10 |
import pandas as pd
|
|
|
|
| 11 |
|
| 12 |
logger = logging.getLogger(__name__)
|
| 13 |
|
|
|
|
| 200 |
license=_JGLUE_LICENSE,
|
| 201 |
features=features,
|
| 202 |
supervised_keys=None,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
)
|
| 204 |
|
| 205 |
|
|
|
|
| 584 |
raise ValueError(f"Invalid config name: {self.config.name}")
|
| 585 |
|
| 586 |
def __split_generators_marc_ja(self, dl_manager: ds.DownloadManager):
|
| 587 |
+
try:
|
| 588 |
+
file_paths = dl_manager.download_and_extract(_URLS[self.config.name])
|
| 589 |
+
except FileNotFoundError as err:
|
| 590 |
+
logger.warning(err)
|
| 591 |
+
# An error occurs because the file cannot be downloaded from _URLS[MARC-ja]['data'].
|
| 592 |
+
# So, remove the 'data' key and try to download again.
|
| 593 |
+
urls = _URLS[self.config.name]
|
| 594 |
+
urls.pop("data") # type: ignore[attr-defined]
|
| 595 |
+
file_paths = dl_manager.download_and_extract(urls)
|
| 596 |
|
| 597 |
filter_review_id_list = file_paths["filter_review_id_list"]
|
| 598 |
label_conv_review_id_list = file_paths["label_conv_review_id_list"]
|
tests/JGLUE_test.py
CHANGED
|
@@ -1,6 +1,11 @@
|
|
| 1 |
import datasets as ds
|
| 2 |
import pytest
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
@pytest.fixture
|
| 6 |
def dataset_path() -> str:
|
|
|
|
| 1 |
import datasets as ds
|
| 2 |
import pytest
|
| 3 |
|
| 4 |
+
# In datasets>=3.0.0, HF_DATASETS_TRUST_REMOTE_CODE defaults to False,
|
| 5 |
+
# which triggers confirmation dialogs when loading datasets and interrupts testing.
|
| 6 |
+
# Therefore, HF_DATASETS_TRUST_REMOTE_CODE is set to True.
|
| 7 |
+
ds.config.HF_DATASETS_TRUST_REMOTE_CODE = True
|
| 8 |
+
|
| 9 |
|
| 10 |
@pytest.fixture
|
| 11 |
def dataset_path() -> str:
|