Skip to content

[python] Remove Python-3.10-only Ollama auto-pull block in integration tests#831

Merged
wenjin272 merged 2 commits into
apache:mainfrom
weiqingy:701-impl
Jun 11, 2026
Merged

[python] Remove Python-3.10-only Ollama auto-pull block in integration tests#831
wenjin272 merged 2 commits into
apache:mainfrom
weiqingy:701-impl

Conversation

@weiqingy

@weiqingy weiqingy commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Linked issue: #701

Purpose of change

Follow-up cleanup to #161. That PR moved the Ollama integration tests into the it-python CI job, which installs Ollama at the step level via tools/start_ollama_server.sh (ci.yml:192/229/275). That made the inline if "3.10" in sys.version: subprocess.run(...) auto-pull block at the top of the two Ollama test files dead code in every CI cell:

  • ut-python excludes these tests via -m "not integration", so the module-import side effect never fires there.
  • it-python runs Python 3.11 and 3.12 only, so the if "3.10" in sys.version guard is always false.

This PR:

  • Removes the dead auto-pull block from both Ollama test files, along with the now-unused subprocess, sys, and Path imports and the current_dir variable (each was used only inside the removed block).
  • Keeps the client = Client() + @pytest.mark.skipif(client is None, ...) guard, so the tests still skip cleanly on developer machines without Ollama running.
  • Deletes the two orphaned start_ollama_server.sh copies under the test directories (integrations/chat_models/tests/ and integrations/embedding_models/local/tests/). After removing the inline block, nothing referenced them; CI uses the canonical tools/start_ollama_server.sh.

Audit of issue item 4: grep -rln "subprocess.run" python/flink_agents/integrations/ returns only these two files — no other integration test carries the same anti-pattern.

One open question for maintainers (issue item 3): does any local-dev workflow rely on the inline auto-pull — i.e. is anyone running these tests directly on a Python 3.10 venv without first starting Ollama? If so, the new prerequisite (start Ollama first, e.g. bash tools/start_ollama_server.sh) is worth a line in CONTRIBUTING.md. The skipif guard already turns a missing Ollama into a clean skip rather than a failure, so this PR does not add a doc note; happy to follow up if preferred.

Tests

No new tests — this removes dead code. Verified locally:

  • ruff check and ruff format --check pass on both files.
  • pytest -m integration on both files: chat tests pass (Ollama running locally), embedding test skips cleanly — confirming the removed imports/symbols leave no broken references and the skipif guard still works.

API

No. Test-only change, no public API touched.

Documentation

  • doc-not-needed

…on tests

After apache#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.
@github-actions github-actions Bot added doc-not-needed Your PR changes do not impact docs fixVersion/0.3.0 The feature or bug should be implemented/fixed in the 0.3.0 version. priority/major Default priority of the PR or issue. and removed doc-not-needed Your PR changes do not impact docs labels Jun 10, 2026
["bash", f"{current_dir}/start_ollama_server.sh", test_model],
timeout=300,
check=True,
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script start_ollama_server.sh installs the Ollama server and pulls the required models. After moving the integration tests into the it-python pipeline, we no longer need to install the Ollama server separately; however, we still need to pull the test models being used. We can use the pull_model method in test_utils.py.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch -tools/start_ollama_server.sh only installs the server; it doesn't pull models, so after dropping the inline block these tests would skip on a missing model in CI rather than actually run.

Switched both files to client = pull_model(test_model) from e2e_tests/test_utils.py — the same helper the e2e integration tests already use. It pulls the model and returns the client (or None), so the existing skipif(client is None) guard is unchanged. Also dropped the now-unused from ollama import Client.

Verified locally: the embedding test now runs instead of skipping. Fixed in 3b8d9e1.

if "3.10" in sys.version:
subprocess.run(
["bash", f"{current_dir}/start_ollama_server.sh"], timeout=300, check=True
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done here too — same pull_model(test_model) switch as the chat test. 3b8d9e1

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.

@wenjin272 wenjin272 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wenjin272 wenjin272 merged commit 462dbc4 into apache:main Jun 11, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-not-needed Your PR changes do not impact docs fixVersion/0.3.0 The feature or bug should be implemented/fixed in the 0.3.0 version. priority/major Default priority of the PR or issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants