From ab62944bd9a05659a7c2b92c667c01916b96f990 Mon Sep 17 00:00:00 2001 From: Weiqing Yang Date: Sat, 16 May 2026 23:04:45 -0700 Subject: [PATCH 1/3] [hotfix] Call open() in embedding setup tests before embed() `test_ollama_embedding_setup` and `test_openai_embedding_model` both construct a `BaseEmbeddingModelSetup` subclass with `connection` set to a resource-name string, then call `setup.embed(...)` directly without first invoking `setup.open()`. `BaseEmbeddingModelSetup.open()` is what resolves `self.connection` from the descriptor-supplied resource name into the actual `BaseEmbeddingModelConnection` instance. Without it, `_get_connection()` raises `TypeError("Expect BaseEmbeddingModelConnection, but is str")` and the test fails. The Ollama test exhibits this failure in CI on Python 3.10 once the ollama daemon is brought up by `start_ollama_server.sh`; the OpenAI test is masked by the `TEST_API_KEY` skipif but would fail identically if the gate were ever satisfied. `test_tongyi_embedding_model` (the third embedding test in this repo) already follows the correct pattern. Add the missing `setup.open()` call to both tests so the connection is resolved before `embed()`. --- .../embedding_models/local/tests/test_ollama_embedding_model.py | 1 + .../embedding_models/tests/test_openai_embedding_model.py | 1 + 2 files changed, 2 insertions(+) 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 ab983cfa9..b770eea3f 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 @@ -78,6 +78,7 @@ def get_resource(name: str, type: ResourceType) -> Resource: truncate=True, resource_context=mock_ctx, ) + setup.open() # Test embedding through setup embedding = setup.embed("This is a test sentence for embedding.") diff --git a/python/flink_agents/integrations/embedding_models/tests/test_openai_embedding_model.py b/python/flink_agents/integrations/embedding_models/tests/test_openai_embedding_model.py index 753820358..e76cc3faa 100644 --- a/python/flink_agents/integrations/embedding_models/tests/test_openai_embedding_model.py +++ b/python/flink_agents/integrations/embedding_models/tests/test_openai_embedding_model.py @@ -48,6 +48,7 @@ def get_resource(name: str, type: ResourceType) -> Resource: embedding_model = OpenAIEmbeddingModelSetup( name="openai", model=test_model, connection="openai", resource_context=mock_ctx ) + embedding_model.open() response = embedding_model.embed("Hello, Flink Agent!") assert response is not None From 3ade7fa78ad7dba279051f02f9f3629796cd4500 Mon Sep 17 00:00:00 2001 From: Weiqing Yang Date: Sun, 17 May 2026 10:47:58 -0700 Subject: [PATCH 2/3] [hotfix] Drop the failing 'ollama run' line from embedding server-start MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per @wenjin272's review on #686: `ollama run all-minilm:22m` cannot run non-interactively against an embedding model — `ollama` reports Error: embedding models require input text. Usage: ollama run all-minilm:22m "your text here" and exits non-zero. That bubbles up through `subprocess.run(check=True)` in `test_ollama_embedding_model.py`'s module-level setup, falls into the `except` block, and silently sets `client = None`, which makes the embedding test skip in CI on Python 3.10 — defeating the purpose of ever calling the script. `ollama pull` alone is sufficient to make the model discoverable via the daemon's `client.list()`; the chat-model sibling script (`integrations/chat_models/tests/start_ollama_server.sh`) already follows that minimal pattern. Drop the redundant `ollama run` line so the gate succeeds and the test actually executes in CI. --- .../embedding_models/local/tests/start_ollama_server.sh | 1 - 1 file changed, 1 deletion(-) 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 index 674ef6e70..92da52d79 100755 --- 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 @@ -36,5 +36,4 @@ if [[ $os == "Linux" ]]; then fi ollama pull all-minilm:22m - ollama run all-minilm:22m fi \ No newline at end of file From acfd146257280521475a3c2d315d3ef2986fbcf8 Mon Sep 17 00:00:00 2001 From: Weiqing Yang Date: Mon, 18 May 2026 22:06:19 -0700 Subject: [PATCH 3/3] [hotfix] Move OLLAMA_EMBEDDING_MODEL out of module scope in e2e tests The e2e modules in e2e_tests_resource_cross_language assigned os.environ["OLLAMA_EMBEDDING_MODEL"] = OLLAMA_MODEL at module scope. Because pytest -k "not e2e_tests" only filters which tests run (not which files are collected/imported), pytest collection imported these modules and executed the assignment as a side effect, polluting OLLAMA_EMBEDDING_MODEL for the later-collected integrations/embedding_models/local/tests/test_ollama_embedding_model.py. Net effect: test_ollama_embedding_setup read the polluted "nomic-embed-text:latest" value instead of falling back to the hard-coded "all-minilm:22m" default, so the model_found gate failed and the test was silently skipped in the ut-python CI job. Removed the module-scope assignment and moved it into the test functions via monkeypatch.setenv, which preserves the runtime propagation behavior (Flink subprocess still sees the env var) and auto-restores after the test. Reported and root-caused by @wenjin272 in https://github.com/apache/flink-agents/pull/686#issuecomment-4474060000. --- .../embedding_model_cross_language_test.py | 6 ++++-- .../vector_store_cross_language_test.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/python/flink_agents/e2e_tests/e2e_tests_resource_cross_language/embedding_model_cross_language_test.py b/python/flink_agents/e2e_tests/e2e_tests_resource_cross_language/embedding_model_cross_language_test.py index a0afc56f2..1e5de5268 100644 --- a/python/flink_agents/e2e_tests/e2e_tests_resource_cross_language/embedding_model_cross_language_test.py +++ b/python/flink_agents/e2e_tests/e2e_tests_resource_cross_language/embedding_model_cross_language_test.py @@ -41,7 +41,6 @@ current_dir = Path(__file__).parent OLLAMA_MODEL = os.environ.get("OLLAMA_EMBEDDING_MODEL", "nomic-embed-text:latest") -os.environ["OLLAMA_EMBEDDING_MODEL"] = OLLAMA_MODEL client = pull_model(OLLAMA_MODEL) @@ -51,7 +50,10 @@ @pytest.mark.skipif( client is None, reason="Ollama client is not available or test model is missing." ) -def test_java_embedding_model_integration(tmp_path: Path) -> None: +def test_java_embedding_model_integration( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch +) -> None: + monkeypatch.setenv("OLLAMA_EMBEDDING_MODEL", OLLAMA_MODEL) env = StreamExecutionEnvironment.get_execution_environment() env.set_runtime_mode(RuntimeExecutionMode.STREAMING) env.set_parallelism(1) diff --git a/python/flink_agents/e2e_tests/e2e_tests_resource_cross_language/vector_store_cross_language_test.py b/python/flink_agents/e2e_tests/e2e_tests_resource_cross_language/vector_store_cross_language_test.py index 36825a779..156d6c94f 100644 --- a/python/flink_agents/e2e_tests/e2e_tests_resource_cross_language/vector_store_cross_language_test.py +++ b/python/flink_agents/e2e_tests/e2e_tests_resource_cross_language/vector_store_cross_language_test.py @@ -41,7 +41,6 @@ current_dir = Path(__file__).parent OLLAMA_MODEL = os.environ.get("OLLAMA_EMBEDDING_MODEL", "nomic-embed-text:latest") -os.environ["OLLAMA_EMBEDDING_MODEL"] = OLLAMA_MODEL ES_HOST = os.environ.get("ES_HOST") @@ -55,7 +54,10 @@ reason="Ollama client or Elasticsearch host is missing.", ) @pytest.mark.parametrize("embedding_type", ["JAVA", "PYTHON"]) -def test_java_vector_store_integration(tmp_path: Path, embedding_type: str) -> None: +def test_java_vector_store_integration( + tmp_path: Path, embedding_type: str, monkeypatch: pytest.MonkeyPatch +) -> None: + monkeypatch.setenv("OLLAMA_EMBEDDING_MODEL", OLLAMA_MODEL) os.environ["EMBEDDING_TYPE"] = embedding_type env = StreamExecutionEnvironment.get_execution_environment()