Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions sci-ml/tokenizers/files/tokenizers-0.23.2-test-optional-deps.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -3,7 +3,11 @@

import pytest

-from huggingface_hub import hf_hub_download
+try:
+ from huggingface_hub import hf_hub_download as _hf_hub_download
+ _HF_AVAILABLE = True
+except ImportError:
+ _HF_AVAILABLE = False


DATA_PATH = os.path.join("tests", "data")
@@ -11,8 +15,10 @@


def download(filename):
+ if not _HF_AVAILABLE:
+ pytest.skip("huggingface_hub is not installed")
# huggingface_hub handles auth (HF_TOKEN), retry/backoff and ETag-based caching.
- return hf_hub_download(repo_id=HF_TEST_REPO, filename=filename, repo_type="dataset")
+ return _hf_hub_download(repo_id=HF_TEST_REPO, filename=filename, repo_type="dataset")


@pytest.fixture(scope="session")
--- a/tests/test_serialization.py
+++ b/tests/test_serialization.py
@@ -4,7 +4,10 @@
import unittest

import tqdm
-from huggingface_hub import hf_hub_download
+try:
+ from huggingface_hub import hf_hub_download
+except ImportError:
+ hf_hub_download = None
from tokenizers import Tokenizer
from tokenizers.models import BPE, Unigram

--- a/tests/documentation/test_tutorial_train_from_iterators.py
+++ b/tests/documentation/test_tutorial_train_from_iterators.py
@@ -2,8 +2,11 @@
import gzip
import os

-import datasets # type: ignore[import-not-found]
import pytest
+try:
+ import datasets # type: ignore[import-not-found]
+except ImportError:
+ pytest.skip("datasets is not installed", allow_module_level=True)

from ..utils import data_dir, train_files

2 changes: 1 addition & 1 deletion sci-ml/tokenizers/tokenizers-0.23.2.ebuild
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pkg_setup() {
src_prepare() {
default
cd bindings/python || die
eapply "${FILESDIR}"/${PN}-0.21.2-test.patch
eapply "${FILESDIR}"/${PN}-0.23.2-test-optional-deps.patch
distutils-r1_src_prepare
}

Expand Down
Loading