Skip to content

Commit 6892ad4

Browse files
authored
build: add pins for Optimum (#1847)
* build: add pins for Optimum * try with python 3.13 * don't call HF on unit tests
1 parent 74fe279 commit 6892ad4

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

.github/workflows/optimum.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ jobs:
3131
fail-fast: false
3232
matrix:
3333
os: [ubuntu-latest, windows-latest, macos-latest]
34-
python-version: ["3.9", "3.12"] # onnx does not support 3.13 yet
35-
34+
python-version: ["3.9", "3.13"]
35+
3636
steps:
3737
- name: Support longpaths
3838
if: matrix.os == 'windows-latest'
@@ -60,9 +60,16 @@ jobs:
6060
- name: Run tests
6161
run: hatch run cov-retry
6262

63+
- name: Run unit tests with lowest direct dependencies
64+
run: |
65+
hatch run uv pip compile pyproject.toml --resolution lowest-direct --output-file requirements_lowest_direct.txt
66+
hatch run uv pip install -r requirements_lowest_direct.txt
67+
hatch run test -m "not integration"
68+
6369
- name: Nightly - run unit tests with Haystack main branch
6470
if: github.event_name == 'schedule'
6571
run: |
72+
hatch env prune
6673
hatch run uv pip install git+https://github.com/deepset-ai/haystack.git@main
6774
hatch run cov-retry -m "not integration"
6875

integrations/optimum/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ dependencies = [
3333
# Ref: https://github.com/huggingface/optimum/blob/8651c0ca1cccf095458bc80329dec9df4601edb4/optimum/exporters/onnx/__main__.py#L164
3434
# "sentence-transformers" has been added, since most embedding models use it
3535
"sentence-transformers>=2.3",
36-
"optimum[onnxruntime]",
36+
"optimum[onnxruntime]>=1.17.0",
3737
]
3838

3939
[project.urls]

integrations/optimum/tests/test_optimum_document_embedder.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def test_initialize_with_invalid_pooling_mode(self, mock_check_valid_model): #
235235
model="sentence-transformers/all-mpnet-base-v2", pooling_mode="Invalid_pooling_mode"
236236
)
237237

238-
def test_infer_pooling_mode_from_str(self):
238+
def test_infer_pooling_mode_from_str(self, mock_check_valid_model): # noqa: ARG002
239239
"""
240240
Test that the pooling mode is correctly inferred from a string.
241241
The pooling mode is "mean" as per the model config.
@@ -311,7 +311,7 @@ def test_prepare_texts_to_embed_w_suffix(self, mock_check_valid_model): # noqa:
311311

312312
def test_run_wrong_input_format(self, mock_check_valid_model): # noqa: ARG002
313313
embedder = OptimumDocumentEmbedder(model="sentence-transformers/all-mpnet-base-v2", pooling_mode="mean")
314-
embedder.warm_up()
314+
embedder._initialized = True
315315
# wrong formats
316316
string_input = "text"
317317
list_integers_input = [1, 2, 3]
@@ -326,7 +326,7 @@ def test_run_on_empty_list(self, mock_check_valid_model): # noqa: ARG002
326326
embedder = OptimumDocumentEmbedder(
327327
model="sentence-transformers/paraphrase-albert-small-v2",
328328
)
329-
embedder.warm_up()
329+
embedder._initialized = True
330330
empty_list_input = []
331331
result = embedder.run(documents=empty_list_input)
332332

integrations/optimum/tests/test_optimum_text_embedder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def test_initialize_with_invalid_pooling_mode(self, mock_check_valid_model): #
198198
with pytest.raises(ValueError):
199199
OptimumTextEmbedder(model="sentence-transformers/all-mpnet-base-v2", pooling_mode="Invalid_pooling_mode")
200200

201-
def test_infer_pooling_mode_from_str(self):
201+
def test_infer_pooling_mode_from_str(self, mock_check_valid_model): # noqa: ARG002
202202
"""
203203
Test that the pooling mode is correctly inferred from a string.
204204
The pooling mode is "mean" as per the model config.

0 commit comments

Comments
 (0)