Skip to content

Commit

Permalink
skip test_load_with_hf_datasets() and test_load_with_hf_datasets_from…
Browse files Browse the repository at this point in the history
…_hub() if HF conll2003 is not reachable (#340)
  • Loading branch information
ArneBinder authored Sep 13, 2023
1 parent b78f7fc commit e070363
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
13 changes: 13 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
from pathlib import Path

from datasets import DownloadMode, load_dataset

TESTS_ROOT = Path(__file__).parent
FIXTURES_ROOT = TESTS_ROOT / "fixtures"
DATASET_BUILDERS_ROOT = Path("dataset_builders")


def _check_hf_conll2003_is_available():
try:
load_dataset("conll2003", download_mode=DownloadMode.FORCE_REDOWNLOAD)
return True
except ConnectionError:
return False


_HF_CONLL2003_IS_AVAILABLE = _check_hf_conll2003_is_available()
10 changes: 9 additions & 1 deletion tests/data/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from pytorch_ie.data.dataset import get_pie_dataset_type
from pytorch_ie.documents import TextDocument
from pytorch_ie.taskmodules import TransformerSpanClassificationTaskModule
from tests import DATASET_BUILDERS_ROOT
from tests import _HF_CONLL2003_IS_AVAILABLE, DATASET_BUILDERS_ROOT
from tests.conftest import TestDocument


Expand Down Expand Up @@ -265,6 +265,10 @@ def test_dataset_with_taskmodule(
assert not document["entities"].predictions


@pytest.mark.skipif(
not _HF_CONLL2003_IS_AVAILABLE,
reason="the Huggingface conll2003 dataset is not reachable and the local PIE-variant depends on it",
)
def test_load_with_hf_datasets():
dataset_path = DATASET_BUILDERS_ROOT / "conll2003"

Expand All @@ -279,6 +283,10 @@ def test_load_with_hf_datasets():
assert len(dataset["test"]) == 3453


@pytest.mark.skipif(
not _HF_CONLL2003_IS_AVAILABLE,
reason="the Huggingface conll2003 dataset is not reachable and the remote PIE-variant depends on it",
)
def test_load_with_hf_datasets_from_hub():
dataset = datasets.load_dataset(
path="pie/conll2003",
Expand Down

0 comments on commit e070363

Please sign in to comment.