From 8c1aa2503f1f8737985ff323963c13e6355189e3 Mon Sep 17 00:00:00 2001 From: Weiqing Yang Date: Tue, 9 Jun 2026 23:52:41 -0700 Subject: [PATCH 1/2] [python] Remove dead Python-3.10-only Ollama auto-pull from integration tests After #161 moved the Ollama integration tests into the it-python CI job (which installs Ollama via tools/start_ollama_server.sh at the step level), the inline 'if "3.10" in sys.version: subprocess.run(...)' block is dead in every CI cell: ut-python excludes these via -m "not integration", and it-python runs Python 3.11/3.12 so the guard is always false. Remove the block and the now-unused subprocess/sys/Path imports and current_dir from both Ollama test files, and delete the two orphaned test-dir start_ollama_server.sh copies that only the inline block referenced. The Client() + skipif guard is kept so the tests still skip cleanly on machines without Ollama. --- .../chat_models/tests/start_ollama_server.sh | 40 ------------------- .../tests/test_ollama_chat_model.py | 11 ----- .../local/tests/start_ollama_server.sh | 39 ------------------ .../tests/test_ollama_embedding_model.py | 9 ----- 4 files changed, 99 deletions(-) delete mode 100644 python/flink_agents/integrations/chat_models/tests/start_ollama_server.sh delete mode 100755 python/flink_agents/integrations/embedding_models/local/tests/start_ollama_server.sh diff --git a/python/flink_agents/integrations/chat_models/tests/start_ollama_server.sh b/python/flink_agents/integrations/chat_models/tests/start_ollama_server.sh deleted file mode 100644 index bf7a50a0a..000000000 --- a/python/flink_agents/integrations/chat_models/tests/start_ollama_server.sh +++ /dev/null @@ -1,40 +0,0 @@ -################################################################################ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -################################################################################# - -# only works on linux -os=$(uname -s) -echo $os -if [[ $os == "Linux" ]]; then - curl -fsSL https://ollama.com/install.sh | sh - ret=$? - if [ "$ret" != "0" ] - then - exit $ret - fi - - if curl -f http://localhost:11434/api/tags >/dev/null 2>&1; then - echo "Ollama is already running" - else - echo "Starting Ollama server" - ollama serve & - sleep 10 # wait for ollama to start - fi - - echo "ollama pull $1" - ollama pull $1 -fi \ No newline at end of file diff --git a/python/flink_agents/integrations/chat_models/tests/test_ollama_chat_model.py b/python/flink_agents/integrations/chat_models/tests/test_ollama_chat_model.py index 27f07f340..4683ad9de 100644 --- a/python/flink_agents/integrations/chat_models/tests/test_ollama_chat_model.py +++ b/python/flink_agents/integrations/chat_models/tests/test_ollama_chat_model.py @@ -16,9 +16,6 @@ # limitations under the License. ################################################################################# import os -import subprocess -import sys -from pathlib import Path from unittest.mock import MagicMock import pytest @@ -37,16 +34,8 @@ pytestmark = pytest.mark.integration test_model = os.environ.get("OLLAMA_CHAT_MODEL", "qwen3:1.7b") -current_dir = Path(__file__).parent try: - # only auto setup ollama in ci with python 3.10 to reduce ci cost. - if "3.10" in sys.version: - subprocess.run( - ["bash", f"{current_dir}/start_ollama_server.sh", test_model], - timeout=300, - check=True, - ) client = Client() models = client.list() diff --git a/python/flink_agents/integrations/embedding_models/local/tests/start_ollama_server.sh b/python/flink_agents/integrations/embedding_models/local/tests/start_ollama_server.sh deleted file mode 100755 index 92da52d79..000000000 --- a/python/flink_agents/integrations/embedding_models/local/tests/start_ollama_server.sh +++ /dev/null @@ -1,39 +0,0 @@ -################################################################################ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -################################################################################ - -# only works on linux -os=$(uname -s) -echo $os -if [[ $os == "Linux" ]]; then - curl -fsSL https://ollama.com/install.sh | sh - ret=$? - if [ "$ret" != "0" ] - then - exit $ret - fi - - if curl -f http://localhost:11434/api/tags >/dev/null 2>&1; then - echo "Ollama is already running" - else - echo "Starting Ollama server" - ollama serve & - sleep 10 # wait for ollama to start - fi - - ollama pull all-minilm:22m -fi \ No newline at end of file diff --git a/python/flink_agents/integrations/embedding_models/local/tests/test_ollama_embedding_model.py b/python/flink_agents/integrations/embedding_models/local/tests/test_ollama_embedding_model.py index dd71c14ca..859e61474 100644 --- a/python/flink_agents/integrations/embedding_models/local/tests/test_ollama_embedding_model.py +++ b/python/flink_agents/integrations/embedding_models/local/tests/test_ollama_embedding_model.py @@ -16,9 +16,6 @@ # limitations under the License. ################################################################################ import os -import subprocess -import sys -from pathlib import Path from unittest.mock import MagicMock import pytest @@ -34,14 +31,8 @@ pytestmark = pytest.mark.integration test_model = os.environ.get("OLLAMA_EMBEDDING_MODEL", "all-minilm:22m") -current_dir = Path(__file__).parent try: - # only auto setup ollama in ci with python 3.10 to reduce ci cost. - if "3.10" in sys.version: - subprocess.run( - ["bash", f"{current_dir}/start_ollama_server.sh"], timeout=300, check=True - ) client = Client() models = client.list() From 3b8d9e1b84a26e8a1eb8e8b905483380dca79afe Mon Sep 17 00:00:00 2001 From: Weiqing Yang Date: Wed, 10 Jun 2026 20:56:22 -0700 Subject: [PATCH 2/2] [python] Address review: pull Ollama test models via pull_model The canonical tools/start_ollama_server.sh only installs the Ollama server; it does not pull models. After removing the inline auto-pull block, the two integration tests no longer pulled their test models (qwen3:1.7b, all-minilm:22m), so in CI they would skip on a missing model instead of running. Replace the inline Client()/model_found guard in both Ollama integration tests with pull_model(test_model) from e2e_tests/test_utils -- the shared helper already used by every e2e integration test. It pulls the model and returns the client (or None), preserving the exact skipif(client is None) semantics while restoring the model pull. --- .../chat_models/tests/test_ollama_chat_model.py | 17 ++--------------- .../local/tests/test_ollama_embedding_model.py | 17 ++--------------- 2 files changed, 4 insertions(+), 30 deletions(-) diff --git a/python/flink_agents/integrations/chat_models/tests/test_ollama_chat_model.py b/python/flink_agents/integrations/chat_models/tests/test_ollama_chat_model.py index 4683ad9de..1f3fd2614 100644 --- a/python/flink_agents/integrations/chat_models/tests/test_ollama_chat_model.py +++ b/python/flink_agents/integrations/chat_models/tests/test_ollama_chat_model.py @@ -19,11 +19,11 @@ from unittest.mock import MagicMock import pytest -from ollama import Client from flink_agents.api.chat_message import ChatMessage, MessageRole from flink_agents.api.resource import Resource, ResourceType from flink_agents.api.resource_context import ResourceContext +from flink_agents.e2e_tests.test_utils import pull_model from flink_agents.integrations.chat_models.ollama_chat_model import ( OllamaChatModelConnection, OllamaChatModelSetup, @@ -35,20 +35,7 @@ test_model = os.environ.get("OLLAMA_CHAT_MODEL", "qwen3:1.7b") -try: - client = Client() - models = client.list() - - model_found = False - for model in models["models"]: - if model.model == test_model: - model_found = True - break - - if not model_found: - client = None # type: ignore -except Exception: - client = None # type: ignore +client = pull_model(test_model) @pytest.mark.skipif( diff --git a/python/flink_agents/integrations/embedding_models/local/tests/test_ollama_embedding_model.py b/python/flink_agents/integrations/embedding_models/local/tests/test_ollama_embedding_model.py index 859e61474..bcf77f18f 100644 --- a/python/flink_agents/integrations/embedding_models/local/tests/test_ollama_embedding_model.py +++ b/python/flink_agents/integrations/embedding_models/local/tests/test_ollama_embedding_model.py @@ -19,10 +19,10 @@ from unittest.mock import MagicMock import pytest -from ollama import Client from flink_agents.api.resource import Resource, ResourceType from flink_agents.api.resource_context import ResourceContext +from flink_agents.e2e_tests.test_utils import pull_model from flink_agents.integrations.embedding_models.local.ollama_embedding_model import ( OllamaEmbeddingModelConnection, OllamaEmbeddingModelSetup, @@ -32,20 +32,7 @@ test_model = os.environ.get("OLLAMA_EMBEDDING_MODEL", "all-minilm:22m") -try: - client = Client() - models = client.list() - - model_found = False - for model in models["models"]: - if model.model == test_model: - model_found = True - break - - if not model_found: - client = None # type: ignore -except Exception: - client = None # type: ignore +client = pull_model(test_model) @pytest.mark.skipif(