Skip to content

Use lemonade CLI pull command for model downloads#291

Merged
kovtcharov merged 5 commits intomainfrom
kalin/model-downloads
Jan 31, 2026
Merged

Use lemonade CLI pull command for model downloads#291
kovtcharov merged 5 commits intomainfrom
kalin/model-downloads

Conversation

@kovtcharov
Copy link
Collaborator

@kovtcharov kovtcharov commented Jan 31, 2026

Summary

Replace unreliable HTTP endpoint with lemonade-server pull CLI command for model downloads in gaia init.

Changes

  • Replace HTTP with CLI: client.pull_model_stream()lemonade-server pull command
  • Remove retry logic: CLI handles all retries, timeouts, and edge cases internally
  • Add Ctrl+C handling: Graceful interruption with user prompt to skip/continue
  • Improve UX: Added tip about cancelling with Ctrl+C
  • Code cleanup:
    • Removed unused imports: requests, time
    • Added subprocess import
    • Use AgentConsole for consistent formatted output
    • ~20 lines net reduction

Benefits

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

  • Syntax validation passes
  • Tested manual download cancellation with Ctrl+C
  • Tested successful model downloads
  • Tested error handling (network issues, missing executable)

Related Issues

Fixes issues with unreliable HTTP streaming endpoint for model downloads.

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)
@kovtcharov kovtcharov self-assigned this Jan 31, 2026
@kovtcharov kovtcharov added this to the v0.15.3 milestone Jan 31, 2026
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 kovtcharov enabled auto-merge January 31, 2026 07:44
@kovtcharov kovtcharov added this pull request to the merge queue Jan 31, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 31, 2026
@kovtcharov kovtcharov added this pull request to the merge queue Jan 31, 2026
Merged via the queue into main with commit 100d2ae Jan 31, 2026
50 of 51 checks passed
@kovtcharov kovtcharov deleted the kalin/model-downloads branch January 31, 2026 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants