Skip to content

Conversation

@telemaco
Copy link
Collaborator

@telemaco telemaco commented Dec 23, 2025

  • Migrate to e2e pytest the test/system/100-inspect.bats bat test.

Summary by Sourcery

Add end-to-end pytest coverage for the ramalama inspect command across GGUF and safetensors models, including error handling and metadata queries.

Tests:

  • Introduce e2e pytest for ramalama inspect JSON output for GGUF and safetensors models with and without the --all flag.
  • Verify ramalama inspect behavior when inspecting a non-existent model, asserting the correct error code and message.
  • Add tests for ramalama inspect --get to validate retrieval of specific and all GGUF metadata fields.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Dec 23, 2025

Reviewer's Guide

Adds new end-to-end pytest coverage for the ramalama inspect command by porting the previous Bats system test into structured Python tests that validate JSON output, error handling, and metadata querying for both GGUF and safetensors models.

File-Level Changes

Change Details Files
Introduce e2e pytest suite for the ramalama inspect command covering error handling, JSON output (with and without --all), and metadata retrieval via --get.
  • Create a module-scoped RamalamaExecWorkspace fixture that pulls required GGUF and safetensors models once per test module.
  • Add a negative test ensuring inspecting a non-existent model fails with the expected exit code and error message.
  • Parameterize JSON-output tests over GGUF and safetensors models, with and without the --all flag, and validate nested JSON fields via key-path traversal and regex matching.
  • Add tests for the --get option on GGUF models that assert specific metadata values and confirm they appear in aggregated --get all output.
test/e2e/test_inspect.py

Possibly linked issues

  • #E2E Tests to Pytest: They align because this PR converts test/system/100-inspect.bats into a pytest-based e2e test as requested.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @telemaco, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on enhancing the testing infrastructure by migrating the system test for the inspect command from a bats script to a more robust and maintainable pytest framework. The newly introduced end-to-end tests ensure the inspect command functions correctly across various model types and command-line options, improving the reliability of model inspection capabilities.

Highlights

  • Test Migration: The existing test/system/100-inspect.bats system test has been migrated to a new end-to-end pytest suite.
  • New e2e Tests for inspect command: New pytest tests have been added to comprehensively validate the inspect command's functionality.
  • Comprehensive Test Coverage: The new tests cover scenarios such as inspecting non-existent models, verifying JSON output for both GGUF and Safetensors models (with and without the --all flag), and retrieving specific metadata using the --get option.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • The tests assert a large number of exact metadata values (counts, tensor sizes, model properties) for remote models, which makes them very brittle to model or metadata updates; consider either pinning specific model versions or relaxing these assertions to only check for structural properties and a few key fields.
  • Similarly, the expected metadata counts for GGUF and safetensors models (e.g., 23, 201, 288) are tightly coupled to the current artifacts; using more tolerant checks (e.g., >= or presence of representative keys) would reduce the likelihood of spurious failures when models change.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The tests assert a large number of exact metadata values (counts, tensor sizes, model properties) for remote models, which makes them very brittle to model or metadata updates; consider either pinning specific model versions or relaxing these assertions to only check for structural properties and a few key fields.
- Similarly, the expected metadata counts for GGUF and safetensors models (e.g., 23, 201, 288) are tightly coupled to the current artifacts; using more tolerant checks (e.g., `>=` or presence of representative keys) would reduce the likelihood of spurious failures when models change.

## Individual Comments

### Comment 1
<location> `test/e2e/test_inspect.py:46-52` </location>
<code_context>
+        pytest.param(GGUF_MODEL, False, ["Registry"], "ollama", id="gguf_inspect_registry"),
+        pytest.param(GGUF_MODEL, False, ["Format"], "GGUF", id="gguf_inspect_format"),
+        pytest.param(GGUF_MODEL, False, ["Version"], "3", id="gguf_inspect_version"),
+        pytest.param(
+            GGUF_MODEL, False, ["Endianness"], "0" if sys.byteorder == "little" else "1", id="gguf_inspect_endianness"
+        ),
+        pytest.param(GGUF_MODEL, False, ["Metadata"], "23", id="gguf_inspect_metadata_count"),
+        pytest.param(GGUF_MODEL, False, ["Tensors"], "201", id="gguf_inspect_tensors_count"),
+        pytest.param(
+            GGUF_MODEL,
+            False,
+            ["Path"],
+            Path(".*", "store", "ollama", "library", "tinyllama", ".*"),
+            id="gguf_inspect_path",
+        ),
</code_context>

<issue_to_address>
**suggestion (testing):** The `Path(".*", ...)` expectation is mixing regex semantics with filesystem paths and may behave unexpectedly on Windows or if separators change.

Here this value is converted to `str` and fed to `re.match`, so on Windows the pattern will contain backslashes that are treated as escapes, making the regex brittle and tied to one directory layout. Consider either using a plain regex string with explicit separators (e.g. `r".*/store/ollama/library/tinyllama/.*"`) or, alternatively, parsing the JSON value as a `Path` and asserting on its components (e.g. that `"store"`, `"ollama"`, `"library"`, `"tinyllama"` are present in `Path(value).parts`).

```suggestion
        pytest.param(
            GGUF_MODEL,
            False,
            ["Path"],
            r".*store[\\/]+ollama[\\/]+library[\\/]+tinyllama.*",
            id="gguf_inspect_path",
        ),
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds a comprehensive suite of end-to-end tests for the ramalama inspect command using pytest. The tests are well-structured, covering various model types (GGUF, safetensors), command-line flags (--all, --json), and options (--get). The use of pytest.parametrize is effective for testing multiple scenarios concisely. My review includes suggestions to improve the robustness of a test case to ensure it works across different operating systems and to enhance the efficiency of another test to speed up the test suite.

@telemaco telemaco force-pushed the e2e-pytest-inspect-cmd branch 2 times, most recently from d1b71cb to 93e09b5 Compare December 23, 2025 17:44
@telemaco telemaco linked an issue Jan 9, 2026 that may be closed by this pull request
12 tasks
- Migrate to e2e pytest the `test/system/100-inspect.bats` bat test.

Signed-off-by: Roberto Majadas <[email protected]>
@telemaco telemaco force-pushed the e2e-pytest-inspect-cmd branch from 93e09b5 to 6e0191e Compare January 9, 2026 14:03
@telemaco
Copy link
Collaborator Author

telemaco commented Jan 9, 2026

This is ready @olliewalsh @rhatdan


import pytest

GGUF_MODEL = "ollama://tinyllama"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would be best to use a specific tag, in case latest changes e.g ollama://tinyllama:1.1b

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is coming from the bats test though, so can address it in a follow-up PR.

@olliewalsh olliewalsh merged commit d4118db into containers:main Jan 9, 2026
33 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.

E2E Tests to Pytest

2 participants