Skip to content

Commit d31c441

Browse files
committed
ci: create e2e environment; stop testing spacy in unit tests
1 parent bac29d9 commit d31c441

File tree

4 files changed

+23
-16
lines changed

4 files changed

+23
-16
lines changed

.github/workflows/e2e.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
run: pip install hatch==${{ env.HATCH_VERSION }}
3737

3838
- name: Run tests
39-
run: hatch run test:e2e
39+
run: hatch run e2e:test
4040

4141
- name: Send event to Datadog
4242
if: failure() && github.event_name == 'schedule'

haystack/components/extractors/named_entity_extractor.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
from transformers import Pipeline as HfPipeline
2020

2121
with LazyImport(message="Run 'pip install spacy'") as spacy_import:
22-
import spacy
23-
from spacy import Language as SpacyPipeline
22+
import spacy # pylint: disable=import-error
23+
from spacy import Language as SpacyPipeline # pylint: disable=import-error
2424

2525

2626
class NamedEntityExtractorBackend(Enum):

pyproject.toml

+15-9
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ format = "ruff format {args}"
8181
format-check = "ruff format --check {args}"
8282

8383
[tool.hatch.envs.test]
84-
extra-dependencies = [
84+
dependencies = [
8585
"numpy>=2", # Haystack is compatible both with numpy 1.x and 2.x, but we test with 2.x
8686
"numba>=0.54.0", # This pin helps uv resolve the dependency tree. See https://github.com/astral-sh/uv/issues/7881
8787

@@ -95,13 +95,6 @@ extra-dependencies = [
9595
"openai-whisper>=20231106", # LocalWhisperTranscriber
9696
"arrow>=1.3.0", # Jinja2TimeExtension
9797

98-
# NamedEntityExtractor
99-
"spacy>=3.8,<3.9",
100-
"spacy-curated-transformers>=0.2,<=0.3",
101-
"en-core-web-trf @ https://github.com/explosion/spacy-models/releases/download/en_core_web_trf-3.8.0/en_core_web_trf-3.8.0-py3-none-any.whl",
102-
# spacy requires thinc, which depends on blis. We pin blis because version 1.2.1 does not have wheels for python 3.9
103-
# and compiling it from source takes much time.
104-
"blis<1.2.1; python_version < '3.10'",
10598

10699
# Converters
107100
"pypdf", # PyPDFToDocument
@@ -161,14 +154,27 @@ extra-dependencies = [
161154
]
162155

163156
[tool.hatch.envs.test.scripts]
164-
e2e = "pytest e2e"
165157
unit = 'pytest --cov-report xml:coverage.xml --cov="haystack" -m "not integration" {args:test}'
166158
integration = 'pytest --maxfail=5 -m "integration" {args:test}'
167159
integration-mac = 'pytest --maxfail=5 -m "integration" -k "not tika" {args:test}'
168160
integration-windows = 'pytest --maxfail=5 -m "integration" -k "not tika" {args:test}'
169161
types = "mypy --install-types --non-interactive --cache-dir=.mypy_cache/ {args:haystack}"
170162
lint = "pylint -ry -j 0 {args:haystack}"
171163

164+
[tool.hatch.envs.e2e]
165+
template = "test"
166+
extra-dependencies = [
167+
# NamedEntityExtractor
168+
"spacy>=3.8,<3.9",
169+
"en-core-web-trf @ https://github.com/explosion/spacy-models/releases/download/en_core_web_trf-3.8.0/en_core_web_trf-3.8.0-py3-none-any.whl",
170+
# spacy requires thinc, which depends on blis. We pin blis because version 1.2.1 does not have wheels for python 3.9
171+
# and compiling it from source takes much time.
172+
"blis<1.2.1; python_version < '3.10'",
173+
]
174+
175+
[tool.hatch.envs.e2e.scripts]
176+
test = "pytest e2e"
177+
172178
[tool.hatch.envs.readme]
173179
installer = "uv"
174180
detached = true # To avoid installing the dependencies from the default environment

test/components/extractors/test_named_entity_extractor.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# SPDX-FileCopyrightText: 2022-present deepset GmbH <info@deepset.ai>
22
#
33
# SPDX-License-Identifier: Apache-2.0
4+
5+
# Note: We do not test the Spacy backend in this module.
6+
# Spacy is not installed in the test environment to keep the CI fast.
7+
# We test the Spacy backend in e2e/pipelines/test_named_entity_extractor.py.
8+
49
from haystack.utils.auth import Secret
510
import pytest
611

@@ -17,10 +22,6 @@ def test_named_entity_extractor_backend():
1722

1823
_ = NamedEntityExtractor(backend="hugging_face", model="dslim/bert-base-NER")
1924

20-
_ = NamedEntityExtractor(backend=NamedEntityExtractorBackend.SPACY, model="en_core_web_sm")
21-
22-
_ = NamedEntityExtractor(backend="spacy", model="en_core_web_sm")
23-
2425
with pytest.raises(ComponentError, match=r"Invalid backend"):
2526
NamedEntityExtractor(backend="random_backend", model="dslim/bert-base-NER")
2627

0 commit comments

Comments
 (0)