diff --git a/test/components/embedders/test_hugging_face_api_document_embedder.py b/test/components/embedders/test_hugging_face_api_document_embedder.py index 1fdde5c5c..93e49a0d4 100644 --- a/test/components/embedders/test_hugging_face_api_document_embedder.py +++ b/test/components/embedders/test_hugging_face_api_document_embedder.py @@ -4,6 +4,7 @@ import os import random +import sys from unittest.mock import MagicMock, patch import pytest @@ -376,7 +377,8 @@ class TestHuggingFaceAPIDocumentEmbedder: not os.environ.get("HF_API_TOKEN", None), reason="Export an env var called HF_API_TOKEN containing the Hugging Face token to run this test.", ) - @pytest.mark.flaky(reruns=2, reruns_delay=10) + @pytest.mark.flaky(reruns=3, reruns_delay=10) + @pytest.mark.skipif(sys.platform != "linux", reason="We only test on Linux to avoid overloading the HF server") def test_live_run_serverless(self): docs = [ Document(content="I love cheese", meta={"topic": "Cuisine"}), @@ -389,6 +391,7 @@ class TestHuggingFaceAPIDocumentEmbedder: meta_fields_to_embed=["topic"], embedding_separator=" | ", ) + embedder._client.timeout = 10 # we want to fail fast if the server is not responding result = embedder.run(documents=docs) documents_with_embeddings = result["documents"] diff --git a/test/components/embedders/test_hugging_face_api_text_embedder.py b/test/components/embedders/test_hugging_face_api_text_embedder.py index 80f641c23..1ca599b15 100644 --- a/test/components/embedders/test_hugging_face_api_text_embedder.py +++ b/test/components/embedders/test_hugging_face_api_text_embedder.py @@ -4,6 +4,7 @@ import os import random +import sys from unittest.mock import MagicMock, patch import pytest @@ -216,16 +217,18 @@ class TestHuggingFaceAPITextEmbedder: @pytest.mark.integration @pytest.mark.slow - @pytest.mark.flaky(reruns=2, reruns_delay=10) + @pytest.mark.flaky(reruns=3, reruns_delay=10) @pytest.mark.skipif( not os.environ.get("HF_API_TOKEN", None), reason="Export an env var called HF_API_TOKEN containing the Hugging Face token to run this test.", ) + @pytest.mark.skipif(sys.platform != "linux", reason="We only test on Linux to avoid overloading the HF server") def test_live_run_serverless(self): embedder = HuggingFaceAPITextEmbedder( api_type=HFEmbeddingAPIType.SERVERLESS_INFERENCE_API, api_params={"model": "sentence-transformers/all-MiniLM-L6-v2"}, ) + embedder._client.timeout = 10 # we want to fail fast if the server is not responding result = embedder.run(text="The food was delicious") assert len(result["embedding"]) == 384 @@ -234,14 +237,16 @@ class TestHuggingFaceAPITextEmbedder: @pytest.mark.integration @pytest.mark.asyncio @pytest.mark.slow - @pytest.mark.flaky(reruns=2, reruns_delay=10) + @pytest.mark.flaky(reruns=3, reruns_delay=10) @pytest.mark.skipif(os.environ.get("HF_API_TOKEN", "") == "", reason="HF_API_TOKEN is not set") + @pytest.mark.skipif(sys.platform != "linux", reason="We only test on Linux to avoid overloading the HF server") async def test_live_run_async_serverless(self): model_name = "sentence-transformers/all-MiniLM-L6-v2" embedder = HuggingFaceAPITextEmbedder( api_type=HFEmbeddingAPIType.SERVERLESS_INFERENCE_API, api_params={"model": model_name} ) + embedder._client.timeout = 10 # we want to fail fast if the server is not responding text = "This is a test sentence for embedding." result = await embedder.run_async(text=text)