From 91bcfb5908e3439fef551eb3b3792f2d79ed1d03 Mon Sep 17 00:00:00 2001 From: anakin87 Date: Wed, 28 May 2025 10:35:39 +0200 Subject: [PATCH 1/3] build: add pins for Optimum --- .github/workflows/optimum.yml | 7 +++++++ integrations/optimum/pyproject.toml | 2 +- .../optimum/tests/test_optimum_document_embedder.py | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/optimum.yml b/.github/workflows/optimum.yml index 10569a312b..f5fbd757d6 100644 --- a/.github/workflows/optimum.yml +++ b/.github/workflows/optimum.yml @@ -60,9 +60,16 @@ jobs: - name: Run tests run: hatch run cov-retry + - name: Run unit tests with lowest direct dependencies + run: | + hatch run uv pip compile pyproject.toml --resolution lowest-direct --output-file requirements_lowest_direct.txt + hatch run uv pip install -r requirements_lowest_direct.txt + hatch run test -m "not integration" + - name: Nightly - run unit tests with Haystack main branch if: github.event_name == 'schedule' run: | + hatch env prune hatch run uv pip install git+https://github.com/deepset-ai/haystack.git@main hatch run cov-retry -m "not integration" diff --git a/integrations/optimum/pyproject.toml b/integrations/optimum/pyproject.toml index bd8322701d..a6eca7a964 100644 --- a/integrations/optimum/pyproject.toml +++ b/integrations/optimum/pyproject.toml @@ -33,7 +33,7 @@ dependencies = [ # Ref: https://github.com/huggingface/optimum/blob/8651c0ca1cccf095458bc80329dec9df4601edb4/optimum/exporters/onnx/__main__.py#L164 # "sentence-transformers" has been added, since most embedding models use it "sentence-transformers>=2.3", - "optimum[onnxruntime]", + "optimum[onnxruntime]>=1.17.0", ] [project.urls] diff --git a/integrations/optimum/tests/test_optimum_document_embedder.py b/integrations/optimum/tests/test_optimum_document_embedder.py index 32db9258fc..e74bbb119d 100644 --- a/integrations/optimum/tests/test_optimum_document_embedder.py +++ b/integrations/optimum/tests/test_optimum_document_embedder.py @@ -311,7 +311,7 @@ def test_prepare_texts_to_embed_w_suffix(self, mock_check_valid_model): # noqa: def test_run_wrong_input_format(self, mock_check_valid_model): # noqa: ARG002 embedder = OptimumDocumentEmbedder(model="sentence-transformers/all-mpnet-base-v2", pooling_mode="mean") - embedder.warm_up() + embedder._initialized = True # wrong formats string_input = "text" list_integers_input = [1, 2, 3] @@ -326,7 +326,7 @@ def test_run_on_empty_list(self, mock_check_valid_model): # noqa: ARG002 embedder = OptimumDocumentEmbedder( model="sentence-transformers/paraphrase-albert-small-v2", ) - embedder.warm_up() + embedder._initialized = True empty_list_input = [] result = embedder.run(documents=empty_list_input) From 1fc82f3e3cf60c4450fd9af8fe2c53de28a45c03 Mon Sep 17 00:00:00 2001 From: anakin87 Date: Wed, 28 May 2025 10:38:34 +0200 Subject: [PATCH 2/3] try with python 3.13 --- .github/workflows/optimum.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/optimum.yml b/.github/workflows/optimum.yml index f5fbd757d6..8692888e9c 100644 --- a/.github/workflows/optimum.yml +++ b/.github/workflows/optimum.yml @@ -31,8 +31,8 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-latest] - python-version: ["3.9", "3.12"] # onnx does not support 3.13 yet - + python-version: ["3.9", "3.13"] + steps: - name: Support longpaths if: matrix.os == 'windows-latest' From baddcc1431213eec561b24576af99bd75d319bc9 Mon Sep 17 00:00:00 2001 From: anakin87 Date: Wed, 28 May 2025 10:43:52 +0200 Subject: [PATCH 3/3] don't call HF on unit tests --- integrations/optimum/tests/test_optimum_document_embedder.py | 2 +- integrations/optimum/tests/test_optimum_text_embedder.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/integrations/optimum/tests/test_optimum_document_embedder.py b/integrations/optimum/tests/test_optimum_document_embedder.py index e74bbb119d..d8133167c6 100644 --- a/integrations/optimum/tests/test_optimum_document_embedder.py +++ b/integrations/optimum/tests/test_optimum_document_embedder.py @@ -235,7 +235,7 @@ def test_initialize_with_invalid_pooling_mode(self, mock_check_valid_model): # model="sentence-transformers/all-mpnet-base-v2", pooling_mode="Invalid_pooling_mode" ) - def test_infer_pooling_mode_from_str(self): + def test_infer_pooling_mode_from_str(self, mock_check_valid_model): # noqa: ARG002 """ Test that the pooling mode is correctly inferred from a string. The pooling mode is "mean" as per the model config. diff --git a/integrations/optimum/tests/test_optimum_text_embedder.py b/integrations/optimum/tests/test_optimum_text_embedder.py index ba52942526..1b4cb1aeb0 100644 --- a/integrations/optimum/tests/test_optimum_text_embedder.py +++ b/integrations/optimum/tests/test_optimum_text_embedder.py @@ -198,7 +198,7 @@ def test_initialize_with_invalid_pooling_mode(self, mock_check_valid_model): # with pytest.raises(ValueError): OptimumTextEmbedder(model="sentence-transformers/all-mpnet-base-v2", pooling_mode="Invalid_pooling_mode") - def test_infer_pooling_mode_from_str(self): + def test_infer_pooling_mode_from_str(self, mock_check_valid_model): # noqa: ARG002 """ Test that the pooling mode is correctly inferred from a string. The pooling mode is "mean" as per the model config.