Skip to content

chore(format): apply ruff format to llm_vision_* files - #900

Closed
nihalnihalani wants to merge 2 commits into
rocketride-org:developfrom
nihalnihalani:chore/ruff-format-llm-vision
Closed

nihalnihalani wants to merge 2 commits into
rocketride-org:developfrom
nihalnihalani:chore/ruff-format-llm-vision

Conversation

@nihalnihalani

@nihalnihalani nihalnihalani commented May 15, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Pure mechanical ruff format pass on three files that drifted out of format after PR #723's repo-wide cleanup (merged 2026-05-04):

  • nodes/src/nodes/llm_vision_gemini/IGlobal.py
  • nodes/src/nodes/llm_vision_gemini/gemini_vision.py
  • nodes/src/nodes/llm_vision_openai/openai_vision.py

48 insertions / 9 deletions, all line-break reformatting (long except (...) tuples and chained assignments wrapped onto multiple lines). Zero semantic changes.

Why

.github/workflows/ci.yml's ruff-check job runs ruff format --check against the full repo. These three files currently fail it, which fails the CI OK gatekeeper that depends on ruff-check. Every PR branched from develop inherits this failure — including currently open PRs #897, #898, #899 (and likely others).

Develop's own most recent CI run (sha 5362aad1) is in conclusion: failure for exactly this reason.

Pattern precedent

Follows the same pattern as merged PR #723 (chore(format): ruff python files, merged 2026-05-04 by @stepmikhaylov). This is a much smaller scoped follow-up — just the 3 files that drifted since then.

Validation

$ ruff format --check .
787 files already formatted

$ ruff check nodes/src/nodes/llm_vision_gemini/ nodes/src/nodes/llm_vision_openai/
All checks passed!

Merging this unblocks ruff-check on every currently open PR.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Improved code consistency and structure across LLM Vision modules through better organization of exception handling and error messaging. No functional changes to user-facing behavior.

Review Change Stack

Pure `ruff format` output — line-break reformatting only, no semantic
changes. These three files drifted out of format after the repo-wide
cleanup in PR rocketride-org#723 merged on 2026-05-04, causing `ruff format --check`
in the `ruff-check` CI job to fail on every PR that branches from
develop. The `CI OK` gatekeeper depends on `ruff-check`, so the drift
blocks merges.

Restores `ruff format --check` green so PRs (rocketride-org#897, rocketride-org#898, rocketride-org#899 and any
others currently open) stop inheriting this failure.

Verified locally with `ruff 0.15.0`:
- `ruff format --check .` → 787 files already formatted, 0 to reformat
- `ruff check nodes/src/nodes/llm_vision_*/` → all checks passed

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the module:nodes Python pipeline nodes label May 15, 2026
@coderabbitai

coderabbitai Bot commented May 15, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4bd5dbd5-e647-4861-a4b3-3e14e24c9049

📥 Commits

Reviewing files that changed from the base of the PR and between 07f78f3 and 6576a21.

📒 Files selected for processing (3)
  • nodes/src/nodes/llm_vision_gemini/IGlobal.py
  • nodes/src/nodes/llm_vision_gemini/gemini_vision.py
  • nodes/src/nodes/llm_vision_openai/openai_vision.py

📝 Walkthrough

Walkthrough

This PR reformats error handling and validation messages across three LLM vision modules. Exception imports, catch clauses, error messages, retry condition lists, and timeout warnings are split from single-line statements into multi-line formats. All logic and behavior remain unchanged.

Changes

Vision LLM exception handling and message formatting

Layer / File(s) Summary
Multi-line exception handling and validation reformatting
nodes/src/nodes/llm_vision_gemini/IGlobal.py, nodes/src/nodes/llm_vision_gemini/gemini_vision.py, nodes/src/nodes/llm_vision_openai/openai_vision.py
Exception import fallbacks, except clauses catching Gemini/GCP and OpenAI exceptions, API key validation error messages, retry condition keyword lists, and timeout warning calls are reformatted from single-line to multi-line syntax. The set of caught exceptions, validation conditions, retry keywords, and message text remain identical.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

A rabbit formats with care, ✨
Exception handlers everywhere,
Lines split cleanly in the air,
Same logic, just more fair—
Code breathes easier there! 🐰

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: applying ruff format to llm_vision_* files. It is concise, specific, and directly related to the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown
Contributor

No description provided.

nihalnihalani added a commit to nihalnihalani/rocketride-server that referenced this pull request May 15, 2026
Mirrors rocketride-org#900. These three pre-existing files on develop drifted out of
`ruff format --check` after PR rocketride-org#723's cleanup; including the fix here so
this PR's CI `ruff-check` (and the `CI OK` gatekeeper that depends on
it) goes green without waiting for rocketride-org#900 to merge first.

Pure mechanical `ruff format` output — line-break reformatting only,
no semantic changes. If rocketride-org#900 merges first, this commit becomes a no-op
on rebase.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
nihalnihalani added a commit to nihalnihalani/rocketride-server that referenced this pull request May 15, 2026
Mirrors rocketride-org#900. These three pre-existing files on develop drifted out of
`ruff format --check` after PR rocketride-org#723's cleanup; including the fix here so
this PR's CI `ruff-check` (and the `CI OK` gatekeeper that depends on
it) goes green without waiting for rocketride-org#900 to merge first.

Pure mechanical `ruff format` output — line-break reformatting only,
no semantic changes. If rocketride-org#900 merges first, this commit becomes a no-op
on rebase.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
nihalnihalani added a commit to nihalnihalani/rocketride-server that referenced this pull request May 15, 2026
Mirrors rocketride-org#900. These three pre-existing files on develop drifted out of
`ruff format --check` after PR rocketride-org#723's cleanup; including the fix here so
this PR's CI `ruff-check` (and the `CI OK` gatekeeper that depends on
it) goes green without waiting for rocketride-org#900 to merge first.

Pure mechanical `ruff format` output — line-break reformatting only,
no semantic changes. If rocketride-org#900 merges first, this commit becomes a no-op
on rebase.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
nihalnihalani added a commit to nihalnihalani/rocketride-server that referenced this pull request May 15, 2026
Prior run failed on `from rocketlib import normalize_tool_input` —
the symbol IS exported from rocketlib/__init__.py line 63/141 on this
branch (identical to develop). Same import passes on companion PRs
rocketride-org#897/rocketride-org#898/rocketride-org#899/rocketride-org#900 with the same merge of develop, so this is a
stale build-cache flake.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@nihalnihalani

nihalnihalani commented May 16, 2026 •

Copy link
Copy Markdown
Collaborator Author

Could you please review the new commit?

@stepmikhaylov

Copy link
Copy Markdown
Collaborator

It looks not relevant, there are no changes for merge.

@nihalnihalani

Copy link
Copy Markdown
Collaborator Author

This is a low-risk formatting-only change: ran ruff format on llm_vision_gemini and llm_vision_openai with no behavior changes (whitespace/line-break adjustments only). CI is green across Ruff, gitleaks, and all platform builds. @Rod-Christensen @jmaionchi @stepmikhaylov could one of you take a quick look so we can land it? Happy to rebase if anything else needs to be folded in.

stepmikhaylov pushed a commit that referenced this pull request May 20, 2026
* feat(nodes): add Cohere Rerank pipeline node

Adds a `rerank_cohere` pipeline node that slots between vector search
and the LLM in RAG pipelines, improving answer quality by reranking
retrieved documents by relevance to the query.

Components:
- RerankClient — wraps Cohere ClientV2 with top_n/min_score validation
  and an exception hierarchy (RerankAuthenticationError, RerankRateLimitError,
  RerankBadRequestError, RerankServerError) named for circuit-breaker
  substring heuristics.
- IGlobal — standard validateConfig (no live API call) and beginGlobal
  lifecycle, with depends() for SDK auto-install.
- IInstance — deep-copies question (fan-out safe), maps rerank result
  indices back through original document positions so metadata stays
  aligned when min_score filters blank docs, always emits an answer.
- services.json — rerank-v3.5 (default), rerank-english-v3.0, custom
  profiles; top_n and min_score exposed in all preset shapes.

Resubmission of the rerank portion of closed PR #499 per maintainer
feedback: one PR per node, clean branch from develop, no unrelated
file changes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* chore(format): apply ruff format to llm_vision_* files

Mirrors #900. These three pre-existing files on develop drifted out of
`ruff format --check` after PR #723's cleanup; including the fix here so
this PR's CI `ruff-check` (and the `CI OK` gatekeeper that depends on
it) goes green without waiting for #900 to merge first.

Pure mechanical `ruff format` output — line-break reformatting only,
no semantic changes. If #900 merges first, this commit becomes a no-op
on rebase.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(rerank_cohere): harden validation, mark experimental, default to v3.0

- services.json: mark capabilities=["experimental"] (stepmikhaylov CR-1)
- services.json: default preset rerank-english-v3.0 (CodeRabbit nit)
- services.json: add requires=["ROCKETRIDE_RERANK_COHERE_KEY"] on test
  block so missing keys skip dynamic tests cleanly (stepmikhaylov CR-6)
- rerank_client.py: accept int|float for top_n (excluding bool) and
  coerce JSON 5.0 -> 5; same bool-exclusion for min_score; centralized
  in _coerce_top_n / _validate_min_score helpers (stepmikhaylov CR-7 +
  CodeRabbit non-bool int check)
- IGlobal.py: validateConfig rejects non-str/whitespace-only apikey and
  model before .strip() (CodeRabbit)
- IInstance.py: trim query/document strings before emptiness checks so
  whitespace-only payloads are rejected (CodeRabbit)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* test(rerank_cohere): relocate to nodes/test/rerank_cohere/test_all.py

Per repo convention for node-specific unit tests. Stops mocking
engine-level modules (rocketlib, ai.*, depends) and drops the
sys.path.insert hack — IGlobal/IInstance are imported through the
build interpreter that already provides them, matching guardrails
and astra_db.

The external cohere SDK is the only dependency mocked, sourced from
the canonical nodes/test/mocks/cohere/ package. The mock is loaded
via a scoped sys.path so other tests are not contaminated.

Additional coverage:
- top_n: accepts JSON float 5.0 (coerced to int), rejects 2.5 and bool
- min_score: rejects bool (subclass of int) at init and override
- validateConfig: rejects non-string apikey/model before .strip()
- IInstance: whitespace-only query and whitespace-only page_content
  raise ValueError

Addresses stepmikhaylov CR-2..CR-5 and CodeRabbit nit re patch.dict.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* test(rerank_cohere): supply required DocMetadata fields in IInstance tests

Three IInstance tests (test_write_questions_preserves_metadata,
test_write_questions_metadata_alignment_after_filter,
test_write_questions_does_not_mutate_original) constructed Doc objects
with metadata dicts missing the required chunkId (and in one case
objectId) fields. The build interpreter's real pydantic DocMetadata
schema requires both, so the tests failed with ValidationError under
builder nodes:test even though they passed locally with the cohere mock.

Also tighten the dict-equality assertion to attribute-level since
DocMetadata is a pydantic model, not a dict.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(rerank_cohere): harden runtime input validation in RerankClient.rerank

Reject non-string and whitespace-only query/documents/model values before
calling the Cohere SDK, so callers get a deterministic local ValueError
instead of RerankBadRequestError/RerankServerError from the network. This
keeps the wrapper's stable validation contract aligned with the existing
validateConfig hardening.

Addresses CodeRabbit review on PR #898.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@stepmikhaylov

Copy link
Copy Markdown
Collaborator

Closed

No changes for merge
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:nodes Python pipeline nodes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants