-
Notifications
You must be signed in to change notification settings - Fork 115
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 ramalama run --keepalive option #789
Conversation
Reviewer's Guide by SourceryThis pull request introduces a new '--keepalive' option to allow models to remain loaded for a specified duration. The changes include updates to documentation, CLI parsing, model execution logic, and system tests, along with some code style improvements in related modules. Sequence diagram for the new '--keepalive' command executionsequenceDiagram
actor U as User
participant CLI as CLI Parser
participant M as Model.run
participant EM as execute_model
U->>CLI: Execute command "ramalama run --keepalive 10m file:///tmp/mymodel"
CLI-->>M: Parse args (including --keepalive)
M->>M: Build prompt and determine model_path
M->>M: Build exec_args via build_exec_args_run()
alt If --keepalive is present
M->>M: Prepend ["timeout", args.keepalive] to exec_args
end
M->>EM: Call execute_model(model_path, exec_args, args)
EM-->>U: Run model with timeout enforced
Updated class diagram for Model with '--keepalive' supportclassDiagram
class Model {
+run(args)
+build_prompt(args)
+get_model_path(args)
+build_exec_args_run(args, model_path, prompt)
+execute_model(model_path, exec_args, args)
}
note for Model "Updated run method: if args.keepalive is provided, prepend 'timeout' command to exec_args"
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this 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 - here's some feedback:
Overall Comments:
- Consider adding a default value for the --keepalive option to improve user experience and prevent potential errors if the user forgets to specify a duration.
- Ensure that the new --keepalive option is clearly explained in the documentation, including examples of valid input formats and any constraints or limitations.
Here's what I looked at during the review
- 🟡 General issues: 2 issues found
- 🟢 Security: all looks good
- 🟡 Testing: 1 issue found
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
ramalama/cli.py
Outdated
@@ -820,6 +820,7 @@ def run_parser(subparsers): | |||
default="none", | |||
help="set the network mode for the container", | |||
) | |||
parser.add_argument("--keepalive", help="Duration to keep a model loaded (e.g. 5m)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Consider specifying a type for the '--keepalive' argument.
Explicitly assigning a type (e.g., string or a duration type) could help ensure consistent input formats and improve clarity for users of the CLI.
parser.add_argument("--keepalive", help="Duration to keep a model loaded (e.g. 5m)") | |
parser.add_argument("--keepalive", type=str, help="Duration to keep a model loaded (e.g. 5m)") |
test/system/030-run.bats
Outdated
@test "ramalama run --keepalive" { | ||
run_ramalama 124 run --keepalive 1s tiny "Write a 1 line poem" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (testing): Consider adding more test cases for the --keepalive option.
The current test only checks if the command runs with the --keepalive option. It would be beneficial to add more test cases to verify different durations and edge cases, such as very short durations, invalid duration formats, and ensuring the process terminates as expected after the specified duration.
@test "ramalama run --keepalive" { | |
run_ramalama 124 run --keepalive 1s tiny "Write a 1 line poem" | |
} | |
@test "ramalama run --keepalive" { | |
run_ramalama 124 run --keepalive 1s tiny "Write a 1 line poem" | |
} | |
@test "ramalama run --keepalive with 2s duration" { | |
run_ramalama 124 run --keepalive 2s tiny "Write a 1 line poem" | |
[ "$status" -eq 0 ] | |
} | |
@test "ramalama run --keepalive with very short duration (0.5s)" { | |
run_ramalama 124 run --keepalive 0.5s tiny "Write a 1 line poem" | |
[ "$status" -eq 0 ] | |
} | |
@test "ramalama run --keepalive with invalid duration format" { | |
run_ramalama 124 run --keepalive invalid tiny "Write a 1 line poem" | |
[ "$status" -ne 0 ] | |
} |
docs/ramalama-run.1.md
Outdated
@@ -70,9 +73,9 @@ ramalama run granite | |||
> | |||
``` | |||
|
|||
Run command with local downloaoded model | |||
Run command with local downloaoded model for 10 minutes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (typo): Typo in 'downloaoded', should be 'downloaded'.
Run command with local downloaoded model for 10 minutes | |
Run command with local downloaded model for 10 minutes |
ec8d360
to
544bd85
Compare
Signed-off-by: Daniel J Walsh <[email protected]>
Summary by Sourcery
Add a '--keepalive' option to the 'ramalama run' command to specify the duration for keeping a model loaded, update documentation and tests accordingly, and introduce an exit code for timeout scenarios.
New Features:
Enhancements:
Documentation:
Tests: