Skip to content

Commit ec7d940

Browse files
Merge pull request #3063 from blshkv/pr/tokenizers
tokenizers
2 parents 8dca818 + 0018993 commit ec7d940

2 files changed

Lines changed: 57 additions & 1 deletion

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
--- a/tests/utils.py
2+
+++ b/tests/utils.py
3+
@@ -3,7 +3,11 @@
4+
5+
import pytest
6+
7+
-from huggingface_hub import hf_hub_download
8+
+try:
9+
+ from huggingface_hub import hf_hub_download as _hf_hub_download
10+
+ _HF_AVAILABLE = True
11+
+except ImportError:
12+
+ _HF_AVAILABLE = False
13+
14+
15+
DATA_PATH = os.path.join("tests", "data")
16+
@@ -11,8 +15,10 @@
17+
18+
19+
def download(filename):
20+
+ if not _HF_AVAILABLE:
21+
+ pytest.skip("huggingface_hub is not installed")
22+
# huggingface_hub handles auth (HF_TOKEN), retry/backoff and ETag-based caching.
23+
- return hf_hub_download(repo_id=HF_TEST_REPO, filename=filename, repo_type="dataset")
24+
+ return _hf_hub_download(repo_id=HF_TEST_REPO, filename=filename, repo_type="dataset")
25+
26+
27+
@pytest.fixture(scope="session")
28+
--- a/tests/test_serialization.py
29+
+++ b/tests/test_serialization.py
30+
@@ -4,7 +4,10 @@
31+
import unittest
32+
33+
import tqdm
34+
-from huggingface_hub import hf_hub_download
35+
+try:
36+
+ from huggingface_hub import hf_hub_download
37+
+except ImportError:
38+
+ hf_hub_download = None
39+
from tokenizers import Tokenizer
40+
from tokenizers.models import BPE, Unigram
41+
42+
--- a/tests/documentation/test_tutorial_train_from_iterators.py
43+
+++ b/tests/documentation/test_tutorial_train_from_iterators.py
44+
@@ -2,8 +2,11 @@
45+
import gzip
46+
import os
47+
48+
-import datasets # type: ignore[import-not-found]
49+
import pytest
50+
+try:
51+
+ import datasets # type: ignore[import-not-found]
52+
+except ImportError:
53+
+ pytest.skip("datasets is not installed", allow_module_level=True)
54+
55+
from ..utils import data_dir, train_files
56+

‎sci-ml/tokenizers/tokenizers-0.23.2.ebuild‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pkg_setup() {
5959
src_prepare() {
6060
default
6161
cd bindings/python || die
62-
eapply "${FILESDIR}"/${PN}-0.21.2-test.patch
62+
eapply "${FILESDIR}"/${PN}-0.23.2-test-optional-deps.patch
6363
distutils-r1_src_prepare
6464
}
6565

0 commit comments

Comments
 (0)