Skip to content

LCORE-3141: models group schema export ability - #2263

Merged
tisnik merged 2 commits into
lightspeed-core:mainfrom
tisnik:lcore-3141-models-group-schema-export
Jul 28, 2026
Merged

LCORE-3141: models group schema export ability#2263
tisnik merged 2 commits into
lightspeed-core:mainfrom
tisnik:lcore-3141-models-group-schema-export

Conversation

@tisnik

@tisnik tisnik commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Description

LCORE-3141: models group schema export ability

Type of change

  • Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up service version
  • Bump-up dependent library
  • Bump-up library or tool used for development (does not change the final image)
  • CI configuration change
  • Konflux configuration change
  • Unit tests improvement
  • Integration tests improvement
  • End to end tests improvement
  • Benchmarks improvement

Tools used to create PR

  • Assisted-by: N/A
  • Generated by: N/A

Related Tickets & Documents

  • Related Issue #LCORE-3141

Summary by CodeRabbit

  • New Features

    • Added a --dump-models-group command-line option to export OpenAPI-compatible schemas for selected model groups.
    • The command exits after successfully generating the schema file and reports errors if generation fails.
  • Documentation

    • Updated CLI usage documentation to include the new option.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Adds -gr/--dump-models-group to lightspeed_stack.py, allowing selected model group schemas to be dumped to an OpenAPI-compatible file. The command logs success and exits, or logs errors and exits with status 1.

Changes

Model group schema dumping

Layer / File(s) Summary
CLI option and usage contract
src/lightspeed_stack.py, README.md
Adds the -gr/--dump-models-group argument and documents its usage.
Dump execution and failure handling
src/lightspeed_stack.py
Calls models_dumper.dump_models_group(...), logs the result, exits early on success, and raises SystemExit(1) on failure.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant ArgumentParser
  participant lightspeed_stack.main
  participant models_dumper
  CLI->>ArgumentParser: Parse --dump-models-group
  ArgumentParser-->>lightspeed_stack.main: Provide selected model group
  lightspeed_stack.main->>models_dumper: Dump group schemas
  models_dumper-->>lightspeed_stack.main: Return result or exception
  lightspeed_stack.main-->>CLI: Log outcome and exit
Loading

Possibly related PRs

Suggested reviewers: are-ces, max-svistunov

🚥 Pre-merge checks | ✅ 7
✅ Passed checks (7 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the new model group schema export feature and matches the PR scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Performance And Algorithmic Complexity ✅ Passed No meaningful perf regression: the new flag only does O(1) model-group selection then a single schema dump; no loops, N+1s, or unbounded growth added.
Security And Secret Handling ✅ Passed No secrets, auth, injection, or sensitive-data exposure found; the new CLI flag only dispatches to existing schema dumping with fixed safe filenames.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

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.

@tisnik
tisnik force-pushed the lcore-3141-models-group-schema-export branch from a277fb4 to 86783a5 Compare July 27, 2026 15:09
@tisnik
tisnik force-pushed the lcore-3141-models-group-schema-export branch from 86783a5 to 516dfb9 Compare July 27, 2026 20:32

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lightspeed_stack.py`:
- Around line 227-237: Update the main() documentation in
src/lightspeed_stack.py to describe --dump-models-group and state that dump
failures exit with status 1. Update the README.md usage synopsis at lines
853-855 to include [-gr DUMP_MODELS_GROUP].
- Around line 75-82: Make the argument parser reject simultaneous use of
dump_models and dump_models_group instead of allowing main() to silently
prioritize dump_models. Place both options in a mutually exclusive argument
group, or add equivalent validation before main() dispatch, while preserving
each mode’s existing standalone behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: de0f36b0-18e1-4ae4-b109-972239d00887

📥 Commits

Reviewing files that changed from the base of the PR and between 07be965 and 516dfb9.

📒 Files selected for processing (2)
  • README.md
  • src/lightspeed_stack.py
📜 Review details
⏰ Context from checks skipped due to timeout. (9)
  • GitHub Check: integration_tests (3.12)
  • GitHub Check: ruff
  • GitHub Check: unit_tests (3.13)
  • GitHub Check: Pylinter
  • GitHub Check: radon
  • GitHub Check: Konflux kflux-prd-rh02 / lightspeed-stack-0-7-on-pull-request
  • GitHub Check: E2E: library mode / ci / group 1
  • GitHub Check: E2E: library mode / ci / group 3
  • GitHub Check: E2E Tests for Lightspeed Evaluation job
🧰 Additional context used
📓 Path-based instructions (2)
**/*

📄 CodeRabbit inference engine (Custom checks)

**/*: Flag meaningful O(n^2)+ algorithms on non-trivial inputs, including handlers and Kubernetes list operations.
Flag N+1 patterns that list items and then query once per item, including Kubernetes API and database access.
Flag expensive work inside loops, including API calls, JSON parsing, and regex compilation.
Flag unbounded growth in caches, watchers, or buffers when eviction or limits are missing.
Flag missing pagination or limits on list operations and API endpoints.
Flag secrets or tokens logged in plaintext or hardcoded in source.
Flag API endpoints missing authentication or authorization.
Flag injection vulnerabilities, including SQL injection, command injection, and path traversal.
Flag sensitive data leaked in API responses, WebSocket messages, or logs.
Flag Kubernetes Secrets and Red Hat secrets missing OwnerReferences.

Files:

  • README.md
  • src/lightspeed_stack.py
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Use absolute imports for internal Python modules.
All modules must begin with descriptive docstrings explaining their purpose.
Use logger = get_logger(__name__) from log.py for module logging.
Use complete type annotations for function parameters and return types.
Use modern union syntax such as str | int; use Optional[Type] for optional values.
Use typing_extensions.Self for model validators.
Functions must use descriptive, action-oriented snake_case names such as get_, validate_, and check_.
Avoid modifying mutable parameters in place; return a new data structure instead.
Use async def for I/O operations and external API calls.
Handle APIConnectionError from Llama Stack.
All classes must have descriptive docstrings and complete type annotations for class attributes; use specific types instead of Any.
Use PascalCase for classes and descriptive standard suffixes such as Configuration, Error/Exception, Resolver, and Interface.
Use ABC and @abstractmethod for abstract interfaces.
Follow Google Python docstring conventions; document all modules, classes, and functions, including Parameters, Returns, Raises, and Attributes sections as applicable.
Never commit secrets or keys; use environment variables for sensitive data.

Files:

  • src/lightspeed_stack.py
🧠 Learnings (3)
📚 Learning: 2026-06-24T13:45:37.249Z
Learnt from: Jdubrick
Repo: lightspeed-core/lightspeed-stack PR: 1971
File: src/utils/markdown_repair.py:31-36
Timestamp: 2026-06-24T13:45:37.249Z
Learning: In the lightspeed-stack repository, docstrings must use the section header name "Parameters:" (not "Args:") for function arguments, even if the project references Google Python docstring conventions. Ensure docstrings follow the project’s established "Parameters:" header format for any documented function parameters.

Applied to files:

  • src/lightspeed_stack.py
📚 Learning: 2026-07-06T15:26:18.398Z
Learnt from: Jdubrick
Repo: lightspeed-core/lightspeed-stack PR: 2071
File: src/models/config.py:2416-2422
Timestamp: 2026-07-06T15:26:18.398Z
Learning: In this repo’s Python code under src/**, don’t treat differences in string concatenation style as a style inconsistency when Black has effectively forced (or made clearer) use of explicit `+` string concatenation in multi-line logger/string expressions. If adjacent-literal implicit concatenation is avoided/changed specifically to accommodate Black’s formatting in these call sites, accept the `+` usage and don’t recommend converting it solely for consistency with nearby blocks that use implicit concatenation.

Applied to files:

  • src/lightspeed_stack.py
📚 Learning: 2026-07-17T19:25:05.325Z
Learnt from: Jdubrick
Repo: lightspeed-core/lightspeed-stack PR: 2166
File: src/utils/saved_prompts.py:129-157
Timestamp: 2026-07-17T19:25:05.325Z
Learning: For any endpoint that handles saved prompts and calls `src/utils/saved_prompts.py::create_saved_prompt`, treat the endpoint as the validation boundary. Before calling `create_saved_prompt`, validate the incoming saved-prompt name and content, specifically using `validate_saved_prompt_name` and then persist (store) the normalized value it returns. Do not call `create_saved_prompt` with unvalidated/raw name/content.

Applied to files:

  • src/lightspeed_stack.py
🔇 Additional comments (1)
src/lightspeed_stack.py (1)

30-32: LGTM!

Comment thread src/lightspeed_stack.py
Comment on lines +75 to +82
parser.add_argument(
"-gr",
"--dump-models-group",
dest="dump_models_group",
help="dump schemas for selected models group into OpenAPI-compatible file and quit",
action="store",
default=None,
)

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Reject conflicting dump modes instead of silently ignoring the group selector.

The parser accepts -m -gr foo, but main() handles args.dump_models first at Line 218, dumps all models, and returns without honoring --dump-models-group. Put the dump modes in one mutually exclusive group or reject conflicting flags before dispatch.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lightspeed_stack.py` around lines 75 - 82, Make the argument parser
reject simultaneous use of dump_models and dump_models_group instead of allowing
main() to silently prioritize dump_models. Place both options in a mutually
exclusive argument group, or add equivalent validation before main() dispatch,
while preserving each mode’s existing standalone behavior.

Comment thread src/lightspeed_stack.py
Comment on lines +227 to +237
# -gr or --dump-models-group CLI parameter is used to dump schema for
# selected models into a JSON file that is compatible with OpenAPI schema
# specification
if args.dump_models_group is not None:
try:
models_dumper.dump_models_group(args.dump_models_group)
logger.info("Schema for group %s of models dumped", args.dump_models_group)
except Exception as e:
logger.error("Failed to dump schema for models: %s", e)
raise SystemExit(1) from e
return

@coderabbitai coderabbitai Bot Jul 27, 2026

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Keep the model-group dump documentation consistent.

The new option is implemented, but the function docstring and README usage synopsis do not fully expose the CLI contract.

  • src/lightspeed_stack.py#L227-L237: document --dump-models-group and its status-1 failure behavior in main().
  • README.md#L863-L864: add [-gr DUMP_MODELS_GROUP] to the usage synopsis at README.md Lines 853-855.
📍 Affects 2 files
  • src/lightspeed_stack.py#L227-L237 (this comment)
  • README.md#L863-L864
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lightspeed_stack.py` around lines 227 - 237, Update the main()
documentation in src/lightspeed_stack.py to describe --dump-models-group and
state that dump failures exit with status 1. Update the README.md usage synopsis
at lines 853-855 to include [-gr DUMP_MODELS_GROUP].

Source: Coding guidelines

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@coderabbitai create issue

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.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="lightspeed-core/lightspeed-stack"
body=$(cat <<'EOF'
## Summary
Keep the `--dump-models-group` CLI documentation aligned with its implementation.

## Required changes
- Update `src/lightspeed_stack.py`'s `main()` docstring to describe `--dump-models-group` and state that failures while dumping exit with status 1.
- Update the `README.md` CLI usage synopsis to include `[-gr DUMP_MODELS_GROUP]`.

## Rationale
The option is implemented, but its public usage and failure contract are not fully documented.

## Affected areas
- `src/lightspeed_stack.py`
- `README.md`

## Acceptance criteria
- `main()` documentation lists the `--dump-models-group` behavior.
- The documented `Raises`/failure behavior covers model-group dump failures and status 1.
- The README usage synopsis contains `[-gr DUMP_MODELS_GROUP]`.

## Backlinks
- Source pull request: https://github.com/lightspeed-core/lightspeed-stack/pull/2263
- Source review comment: https://github.com/lightspeed-core/lightspeed-stack/pull/2263#discussion_r3660714065

Requested by: `@tisnik`
EOF
)

gh issue create \
  --repo "$repo" \
  --title "Document --dump-models-group CLI contract" \
  --body "$body" \
  --assignee tisnik

Length of output: 1422


@tisnik, created and assigned the follow-up issue: #2265Document --dump-models-group CLI contract.


🧠 Learnings used
Learnt from: Jdubrick
Repo: lightspeed-core/lightspeed-stack PR: 1971
File: src/utils/markdown_repair.py:31-36
Timestamp: 2026-06-24T13:45:37.249Z
Learning: In the lightspeed-stack repository, docstrings must use the section header name "Parameters:" (not "Args:") for function arguments, even if the project references Google Python docstring conventions. Ensure docstrings follow the project’s established "Parameters:" header format for any documented function parameters.

@tisnik
tisnik merged commit b6c0b73 into lightspeed-core:main Jul 28, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant