Skip to content

Update demos to show serving models. #1474

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 9, 2025
Merged

Conversation

rhatdan
Copy link
Member

@rhatdan rhatdan commented Jun 5, 2025

Summary by Sourcery

Enhance the serve command to safely handle generation flags and update demos and tests to showcase model serving endpoints with port and API options

Enhancements:

  • Add guard around generation logic in serve() to avoid attribute errors when no generate flag is provided

Documentation:

  • Revise demo script to include --port and --api options for ramalama serve, open service endpoints in a browser, and adjust quay.io grep pattern
  • Invoke serve steps at script end for a complete demo flow

Tests:

  • Extend system tests to exercise ramalama serve with --api llama-stack and --port options and stop commands

Copy link
Contributor

sourcery-ai bot commented Jun 5, 2025

Reviewer's Guide

This PR refactors the model-serving logic in the CLI, consolidates YAML generation under a single guard, and enhances both the demo script and system tests to showcase serving models via HTTP endpoints with customizable ports and API flags.

Sequence Diagram for Model Serving and Access

sequenceDiagram
    actor UserCLI
    participant ramalamaCLI
    participant ModelService
    actor UserBrowser

    UserCLI->>ramalamaCLI: ramalama serve --port <port> --name <name> -d <model> [--api <api_type>]
    activate ramalamaCLI
    ramalamaCLI->>ModelService: Start(model, port, api_type)
    activate ModelService
    ModelService-->>ramalamaCLI: Service Active on http://localhost:<port>
    deactivate ModelService
    ramalamaCLI-->>UserCLI: Service <name> is running
    deactivate ramalamaCLI

    UserBrowser->>ModelService: HTTP GET http://localhost:<port>/
    activate ModelService
    ModelService-->>UserBrowser: HTTP 200 OK (Model UI/Response)
    deactivate ModelService

    UserCLI->>ramalamaCLI: ramalama stop <name>
    activate ramalamaCLI
    ramalamaCLI->>ModelService: Stop()
    activate ModelService
    ModelService-->>ramalamaCLI: Service Stopped
    deactivate ModelService
    ramalamaCLI-->>UserCLI: Service <name> stopped
    deactivate ramalamaCLI
Loading

File-Level Changes

Change Details Files
Refactor 'serve' implementation to wrap generation logic under a single conditional
  • Added a top-level if self.args.generate guard
  • Nested existing kube and quadlet/kube branches under this check
  • Removed unguarded branches that ran when generate was unset
ramalama/stack.py
Update demo script to demonstrate model serving over HTTP
  • Replaced specific quay.io regex with a generic quay.io[^ ]* match
  • Added --port flags to ramalama serve commands
  • Inserted browser launch commands (firefox http://localhost:<port>)
  • Introduced a secondary serve scenario using --api llama-stack and updated stop invocations
  • Appended final serve call to script setup
docs/demo/ramalama.sh
Augment system tests with serve command scenarios
  • Added a BATS test for serve --api llama-stack --port <port> followed by stop
  • Commented out pending RESTAPI output assertions due to TTY limitations
  • Retained and later invoked generate YAML test to ensure backward compatibility
test/system/040-serve.bats

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

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 @rhatdan - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

# exec_color "firefox http://localhost:8085/v1/openai"

echo_color "Stop the ramalama container"
exec_color "ramalama stop granite-service-pod"
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (bug_risk): Mismatch between service name and stop command

The stop command targets granite-service-pod, but the service was started as granite-service. Please use the same name for both commands to ensure the correct container is stopped.

@@ -99,10 +99,27 @@ serve() {
exec_color "podman ps "
echo ""

echo_color "Use web browser to show interaction"
exec_color "firefox http://localhost:8080"
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Hardcoded browser command may not be portable

Use $BROWSER or xdg-open to ensure compatibility across different environments.

Suggested implementation:

    echo_color "Use web browser to show interaction"
    exec_color "${BROWSER:-xdg-open} http://localhost:8080"

#    echo_color "Use web browser to show interaction"
#    exec_color "${BROWSER:-xdg-open} http://localhost:8085"

@rhatdan rhatdan force-pushed the demos branch 2 times, most recently from 061e00e to 17be460 Compare June 5, 2025 09:09
@rhatdan rhatdan merged commit 3317372 into containers:main Jun 9, 2025
9 of 15 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