Skip to content

Commit 3575036

Browse files
authored
Install dependencies with uv in CI (#6779)
* Use uv to install dependencies * Use blank pspacy models * Nit * Pin protobuf
1 parent 6f7f171 commit 3575036

File tree

4 files changed

+17
-42
lines changed

4 files changed

+17
-42
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,18 @@ jobs:
5353
- name: Pin setuptools-scm
5454
if: ${{ matrix.os == 'ubuntu-latest' }}
5555
run: echo "installing pinned version of setuptools-scm to fix seqeval installation on 3.7" && pip install "setuptools-scm==6.4.2"
56+
- name: Install uv
57+
run: pip install --upgrade uv
5658
- name: Install dependencies
5759
run: |
58-
pip install .[tests,metrics-tests]
59-
pip install -r additional-tests-requirements.txt --no-deps
60-
python -m spacy download en_core_web_sm
61-
python -m spacy download fr_core_news_sm
60+
uv pip install --system "datasets[tests,metrics-tests] @ ."
61+
uv pip install --system -r additional-tests-requirements.txt --no-deps
6262
- name: Install dependencies (latest versions)
6363
if: ${{ matrix.deps_versions == 'deps-latest' }}
64-
run: pip install --upgrade pyarrow huggingface-hub dill
64+
run: uv pip install --system --upgrade pyarrow huggingface-hub dill
6565
- name: Install dependencies (minimum versions)
6666
if: ${{ matrix.deps_versions != 'deps-latest' }}
67-
run: pip install pyarrow==12.0.0 huggingface-hub==0.21.2 transformers dill==0.3.1.1
67+
run: uv pip install --system pyarrow==12.0.0 huggingface-hub==0.21.2 transformers dill==0.3.1.1
6868
- name: Test with pytest
6969
run: |
7070
python -m pytest -rfExX -m ${{ matrix.test }} -n 2 --dist loadfile -sv ./tests/
@@ -88,8 +88,10 @@ jobs:
8888
python-version: "3.10"
8989
- name: Upgrade pip
9090
run: python -m pip install --upgrade pip
91+
- name: Install uv
92+
run: pip install --upgrade uv
9193
- name: Install dependencies
92-
run: pip install .[tests]
94+
run: uv pip install --system "datasets[tests] @ ."
9395
- name: Test with pytest
9496
run: |
9597
python -m pytest -rfExX -m ${{ matrix.test }} -n 2 --dist loadfile -sv ./tests/

setup.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@
177177
"rarfile>=4.0",
178178
"sqlalchemy",
179179
"s3fs>=2021.11.1", # aligned with fsspec[http]>=2021.11.1; test only on python 3.7 for now
180-
"tensorflow>=2.3,!=2.6.0,!=2.6.1; sys_platform != 'darwin' or platform_machine != 'arm64'",
181-
"tensorflow-macos; sys_platform == 'darwin' and platform_machine == 'arm64'",
180+
"protobuf<4.0.0", # 4.0.0 breaks compatibility with tensorflow<2.12
181+
"tensorflow>=2.6.0",
182182
"tiktoken",
183183
"torch>=2.0.0",
184184
"soundfile>=0.12.1",
@@ -227,19 +227,17 @@
227227
# Following dependencies are required for the Python reference to be built properly
228228
"transformers",
229229
"torch",
230-
"tensorflow>=2.2.0,!=2.6.0,!=2.6.1; sys_platform != 'darwin' or platform_machine != 'arm64'",
231-
"tensorflow-macos; sys_platform == 'darwin' and platform_machine == 'arm64'",
230+
"tensorflow>=2.6.0",
232231
]
233232

234233
EXTRAS_REQUIRE = {
235234
"audio": AUDIO_REQUIRE,
236235
"vision": VISION_REQUIRE,
237236
"apache-beam": ["apache-beam>=2.26.0"],
238237
"tensorflow": [
239-
"tensorflow>=2.2.0,!=2.6.0,!=2.6.1; sys_platform != 'darwin' or platform_machine != 'arm64'",
240-
"tensorflow-macos; sys_platform == 'darwin' and platform_machine == 'arm64'",
238+
"tensorflow>=2.6.0",
241239
],
242-
"tensorflow_gpu": ["tensorflow-gpu>=2.2.0,!=2.6.0,!=2.6.1"],
240+
"tensorflow_gpu": ["tensorflow>=2.6.0"],
243241
"torch": ["torch"],
244242
"jax": ["jax>=0.3.14", "jaxlib>=0.3.14"],
245243
"s3": ["s3fs"],

tests/test_fingerprint.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
require_not_windows,
2424
require_regex,
2525
require_spacy,
26-
require_spacy_model,
2726
require_tiktoken,
2827
require_torch,
2928
require_transformers,
@@ -331,17 +330,15 @@ def test_hash_torch_generator(self):
331330
self.assertNotEqual(hash1, hash2)
332331

333332
@require_spacy
334-
@require_spacy_model("en_core_web_sm")
335-
@require_spacy_model("fr_core_news_sm")
336333
@pytest.mark.integration
337334
def test_hash_spacy_model(self):
338335
import spacy
339336

340-
nlp = spacy.load("en_core_web_sm")
337+
nlp = spacy.blank("en")
341338
hash1 = Hasher.hash(nlp)
342-
nlp = spacy.load("fr_core_news_sm")
339+
nlp = spacy.blank("fr")
343340
hash2 = Hasher.hash(nlp)
344-
nlp = spacy.load("en_core_web_sm")
341+
nlp = spacy.blank("en")
345342
hash3 = Hasher.hash(nlp)
346343
self.assertEqual(hash1, hash3)
347344
self.assertNotEqual(hash1, hash2)

tests/utils.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -234,28 +234,6 @@ def require_spacy(test_case):
234234
return test_case
235235

236236

237-
def require_spacy_model(model):
238-
"""
239-
Decorator marking a test that requires a spacy model.
240-
241-
These tests are skipped when they aren't installed.
242-
"""
243-
244-
def _require_spacy_model(test_case):
245-
try:
246-
import spacy # noqa F401
247-
248-
spacy.load(model)
249-
except ImportError:
250-
return unittest.skip("test requires spacy")(test_case)
251-
except OSError:
252-
return unittest.skip("test requires spacy model '{}'".format(model))(test_case)
253-
else:
254-
return test_case
255-
256-
return _require_spacy_model
257-
258-
259237
def require_pyspark(test_case):
260238
"""
261239
Decorator marking a test that requires pyspark.

0 commit comments

Comments
 (0)