Skip to content
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

Add --host=0.0.0.0 if running llama.cpp serve within a container #444

Merged
merged 1 commit into from
Nov 12, 2024

Conversation

rhatdan
Copy link
Member

@rhatdan rhatdan commented Nov 12, 2024

Turn on some testing of --nocontainer serve and run, at least with dryrun.

Summary by Sourcery

Add --host=0.0.0.0 when running llama.cpp serve within a container and improve error handling for conflicting options. Enhance system tests to cover new scenarios.

New Features:

  • Add support for running llama.cpp serve with --host=0.0.0.0 when executed within a container.

Enhancements:

  • Improve the handling of --nocontainer and --name options by providing clearer error messages when they conflict.

Tests:

  • Enhance system tests to include scenarios for --nocontainer serve and run, with dryrun mode.

Copy link
Contributor

sourcery-ai bot commented Nov 12, 2024

Reviewer's Guide by Sourcery

This PR modifies the container handling logic in ramalama to improve the serve and run functionality. The main changes include adding host binding for containers and restructuring the test cases to handle both container and non-container scenarios.

Sequence diagram for container handling in serve command

sequenceDiagram
    participant User
    participant Ramalama
    participant Container

    User->>Ramalama: run_ramalama --dryrun serve ${model}
    alt is_container
        Ramalama->>Container: Add --host 0.0.0.0
        Container-->>Ramalama: Host set to 0.0.0.0
    else
        Ramalama-->>User: Host not set to 0.0.0.0
    end
    Ramalama-->>User: Output result
Loading

Updated class diagram for Ramalama model handling

classDiagram
    class Ramalama {
        +run(args)
        +serve(args)
    }

    Ramalama : +exec_model_in_container(model_path, exec_args, args)
    Ramalama : +dry_run(exec_args)
    Ramalama : +exec_cmd(exec_args, debug)

    note for Ramalama "Added host binding logic for containers in serve method"
    note for Ramalama "Added dryrun handling in run and serve methods"
Loading

File-Level Changes

Change Details Files
Added container-aware host binding for serve functionality
  • Added --host=0.0.0.0 parameter when running serve within a container
  • Modified container detection logic to check both container status and engine availability
  • Added test assertions to verify host binding behavior in container and non-container environments
ramalama/model.py
test/system/040-serve.bats
Restructured test cases to handle both container and non-container scenarios
  • Removed skip_if_nocontainer checks
  • Added conditional logic to run different tests based on container environment
  • Added non-container specific test assertions
  • Reorganized test structure with if/else blocks for different environments
test/system/030-run.bats
test/system/040-serve.bats
Improved command execution flow in model operations
  • Added explicit dryrun handling after container execution checks
  • Simplified model path handling logic
  • Removed commented out code
ramalama/model.py

Possibly linked issues


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.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a 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. You can also use
    this command to specify where the summary should be inserted.

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: 1 issue 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.

@@ -289,6 +286,9 @@ def run(self, args):
try:
if self.exec_model_in_container(model_path, exec_args, args):
return
if args.dryrun:
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Consider extracting duplicate dryrun handling logic into a helper method

The dryrun handling logic is duplicated between run() and serve(). Consider creating a helper method to reduce code duplication.

def _handle_dryrun(self, exec_args):
    dry_run(exec_args)
    return True

if args.dryrun:
    return self._handle_dryrun(exec_args)

@rhatdan
Copy link
Member Author

rhatdan commented Nov 12, 2024

Fixes: #442

Turn on some testing of --nocontainer serve and run, at least with
dryrun.

Signed-off-by: Daniel J Walsh <[email protected]>
@ericcurtin
Copy link
Collaborator

Lets not block merge here

@ericcurtin ericcurtin merged commit b4fadef into containers:main Nov 12, 2024
10 of 11 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.

2 participants