Use lemonade CLI pull command for model downloads#291
Merged
kovtcharov merged 5 commits intomainfrom Jan 31, 2026
Merged
Conversation
Replace unreliable HTTP endpoint with lemonade-server CLI pull command: - Remove client.pull_model_stream() HTTP streaming endpoint - Add subprocess call to 'lemonade-server pull' CLI command - Remove all retry logic (CLI handles it internally) - Add graceful Ctrl+C handling with user prompt to continue/skip - Add tip message about cancelling downloads with Ctrl+C - Use AgentConsole for consistent formatted output - Remove unused imports: requests, time - Add subprocess import Benefits: - More reliable (CLI handles edge cases, retries, timeouts) - Cleaner code (~20 lines reduction) - Better UX (Ctrl+C support, helpful tips)
Use Popen() instead of run() to properly handle KeyboardInterrupt: - When Ctrl+C is pressed, wait for subprocess to finish before prompting - Prevents subprocess from running in background during user interaction - Ensures graceful shutdown completes before continuing
Prevent hanging by using escalating termination strategy: - First wait 5 seconds for graceful shutdown - If timeout, send terminate signal and wait 2 more seconds - If still hanging, forcefully kill the process - Ensures the process always exits and prompt appears
Use CREATE_NEW_PROCESS_GROUP on Windows to prevent child from receiving Ctrl+C: - Child process no longer receives signal simultaneously with parent - Parent catches KeyboardInterrupt and cleanly terminates child - Avoids race condition where both try to handle signal - Child terminates cleanly without hanging
Remove all special Ctrl+C handling and return to simple approach: - Use subprocess.run() directly without special handling - Remove Ctrl+C tip message - Remove KeyboardInterrupt exception handling - Remove process group isolation - If user presses Ctrl+C, program exits (default behavior) Simpler and more maintainable.
kovtcharov-amd
approved these changes
Jan 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace unreliable HTTP endpoint with
lemonade-server pullCLI command for model downloads ingaia init.Changes
client.pull_model_stream()→lemonade-server pullcommandrequests,timesubprocessimportAgentConsolefor consistent formatted outputBenefits
✅ More reliable: CLI command handles edge cases better than HTTP endpoint
✅ Better UX: Users can cancel downloads with Ctrl+C and choose to continue
✅ Cleaner code: Simpler implementation without retry logic
✅ Consistent output: Uses AgentConsole for formatted messages
Testing
Related Issues
Fixes issues with unreliable HTTP streaming endpoint for model downloads.