Skip to content

Add restart functionality #206

Merged
AnkushMalaker merged 8 commits intodevfrom
dev-2
Dec 18, 2025
Merged

Add restart functionality #206
AnkushMalaker merged 8 commits intodevfrom
dev-2

Conversation

@AnkushMalaker
Copy link
Collaborator

@AnkushMalaker AnkushMalaker commented Dec 18, 2025

  • Add restart functionality, update resp. docs
  • Fix CI env var precedence
  • Fix start workers script

Summary by CodeRabbit

Release Notes

  • New Features

    • Added restart functionality for services (restart all or specific services)
    • Introduced convenience scripts for quick service startup and restart
  • Documentation

    • Expanded service management guidance with restart commands and examples
    • Added troubleshooting sections for transcription provider configuration and Parakeet-specific issues
    • Enhanced quick-start documentation with multiple service startup options
  • Improvements

    • Enhanced environment variable handling with improved fallback logic
    • Refined provider validation with clearer error messages and configuration guidance

✏️ Tip: You can customize this high-level summary in your review settings.

@AnkushMalaker
Copy link
Collaborator Author

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 18, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 18, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This PR adds restart functionality to the service management CLI and documentation, removes support for the "offline" transcription provider in favor of explicit "parakeet" configuration, makes audio stream workers conditional based on provider environment variables, and refactors environment and provider validation in test setup.

Changes

Cohort / File(s) Summary
Service Management & Restart
services.py, quickstart.md
Introduces restart_services() function and CLI restart subcommand with --all option; updates quickstart with restart guidance and expanded troubleshooting.
Documentation Updates
docs/init-system.md, docs/ports-and-access.md
Adds restart command examples, convenience scripts section, and explicit behavior notes (no rebuild on restart); updates port-conflict guidance to recommend restart workflow.
Transcription Provider Consolidation
backends/advanced/src/advanced_omi_backend/controllers/websocket_controller.py, backends/advanced/src/advanced_omi_backend/services/transcription/__init__.py, backends/advanced/src/advanced_omi_backend/services/transcription/parakeet_stream_consumer.py, backends/advanced/src/advanced_omi_backend/workers/audio_stream_parakeet_worker.py
Removes "offline" provider support; narrows auto-detection to check PARAKEET_ASR_URL before DEEPGRAM_API_KEY; removes OFFLINE_ASR_TCP_URI fallback references across streaming and worker initialization.
Worker Configuration
backends/advanced/start-workers.sh
Replaces single unconditional AUDIO_STREAM_WORKER_PID with two conditional workers (AUDIO_STREAM_DEEPGRAM_WORKER_PID, AUDIO_STREAM_PARAKEET_WORKER_PID) that start only if respective provider credentials/URLs are set.
Test Infrastructure
backends/advanced/run-test.sh, backends/advanced/tests/test_integration.py
Expands environment loading priority (CI vars → .env.test → .env); introduces provider-driven API key validation (transcription and LLM providers with defaults); replaces TEST_AUDIO_PATH_OFFLINE constant with TEST_AUDIO_PATH_PARAKEET.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Heterogeneous changes: Different logic patterns across CLI/docs/backend/workers/tests requiring separate reasoning for each area
  • Provider removal flow: Verify that narrowing auto-detection (removing "offline" and OFFLINE_ASR_TCP_URI) does not break existing deployments relying on fallback paths
  • Worker conditionals: Ensure empty PID guards in killing/cleanup logic prevent spurious errors when workers are skipped
  • Test provider validation: Confirm provider-driven key validation and warning messages align with actual provider expectations

Possibly related PRs

  • Better init system #74: Adds/overhauls the service management CLI (services.py) and init system docs (docs/init-system.md); the current PR extends this foundation by adding restart commands and logic.

Poem

🐰 We restart the workers, old "offline" is gone,
Parakeet and Deepgram dance merrily on,
The services restart without a rebuild's delay,
Conditional workers now activate their way! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add restart functionality' accurately describes the main feature introduced across the changeset—restart commands, convenience scripts, and related service management updates.
Docstring Coverage ✅ Passed Docstring coverage is 91.67% which is sufficient. The required threshold is 80.00%.

Comment @coderabbitai help to get the list of available commands and usage tips.

…ace with PARAKEET_ASR_URL in Docker Compose and documentation.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
backends/advanced/start-workers.sh (1)

110-110: Set MIN_WORKERS=7 to account for all RQ workers.

The script starts 7 RQ workers total (6 general workers + 1 audio persistence worker), but MIN_WORKERS is set to 6. This means if only the audio persistence worker dies, the health check won't trigger a restart since the count remains at 6. Additionally, the stream workers (Deepgram/Parakeet) are Redis Streams consumers, not RQ workers, and are not monitored by this health check—if they die, they won't be automatically restarted.

🧹 Nitpick comments (1)
backends/advanced/src/advanced_omi_backend/workers/audio_stream_parakeet_worker.py (1)

84-86: Consider using logging.exception() for cleaner exception logging.

The error handling correctly logs the full stack trace with exc_info=True. Per project learnings, you could simplify this slightly by using logger.exception() which automatically includes the stack trace without needing the exc_info parameter.

🔎 Apply this diff for more idiomatic exception logging:
     except Exception as e:
-        logger.error(f"Worker error: {e}", exc_info=True)
+        logger.exception(f"Worker error: {e}")
         sys.exit(1)

Based on learnings: prefer logging.exception() inside except blocks to automatically log the full stack trace.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 765373c and 7b09d02.

⛔ Files ignored due to path filters (1)
  • backends/advanced/uv.lock is excluded by !**/*.lock
📒 Files selected for processing (11)
  • Docs/init-system.md (1 hunks)
  • Docs/ports-and-access.md (2 hunks)
  • backends/advanced/run-test.sh (1 hunks)
  • backends/advanced/src/advanced_omi_backend/controllers/websocket_controller.py (1 hunks)
  • backends/advanced/src/advanced_omi_backend/services/transcription/__init__.py (0 hunks)
  • backends/advanced/src/advanced_omi_backend/services/transcription/parakeet_stream_consumer.py (1 hunks)
  • backends/advanced/src/advanced_omi_backend/workers/audio_stream_parakeet_worker.py (1 hunks)
  • backends/advanced/start-workers.sh (5 hunks)
  • backends/advanced/tests/test_integration.py (3 hunks)
  • quickstart.md (2 hunks)
  • services.py (3 hunks)
💤 Files with no reviewable changes (1)
  • backends/advanced/src/advanced_omi_backend/services/transcription/init.py
🧰 Additional context used
📓 Path-based instructions (3)
**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.py: Use Black formatter with 100-character line length for Python code
Use isort for import sorting in Python code
ALL imports must be at the top of the file after the docstring. NEVER import modules in the middle of functions or files. Use lazy imports sparingly and only when absolutely necessary for circular import issues.
Group imports in order: standard library, third-party, local imports
Always raise errors, never silently ignore. Use explicit error handling with proper exceptions rather than silent failures.
Do not add defensive hasattr() checks. Research and understand input/response or class structure instead.
Use uv run python or uv run python3 instead of direct python or python3 commands for Python execution

Files:

  • backends/advanced/src/advanced_omi_backend/services/transcription/parakeet_stream_consumer.py
  • backends/advanced/src/advanced_omi_backend/workers/audio_stream_parakeet_worker.py
  • backends/advanced/src/advanced_omi_backend/controllers/websocket_controller.py
  • backends/advanced/tests/test_integration.py
  • services.py
**/{websocket,ws,audio,streaming}*.py

📄 CodeRabbit inference engine (CLAUDE.md)

Use Wyoming protocol (JSONL + binary) for WebSocket communication with structured audio sessions

Files:

  • backends/advanced/src/advanced_omi_backend/workers/audio_stream_parakeet_worker.py
  • backends/advanced/src/advanced_omi_backend/controllers/websocket_controller.py
**/{conversation,audio,memory,processing}*.py

📄 CodeRabbit inference engine (CLAUDE.md)

Only create conversations when speech is detected, eliminating noise-only sessions. Store all audio sessions in audio_chunks collection, conversations only in conversations collection when speech is detected.

Files:

  • backends/advanced/src/advanced_omi_backend/workers/audio_stream_parakeet_worker.py
🧠 Learnings (3)
📚 Learning: 2025-12-08T23:52:34.959Z
Learnt from: AnkushMalaker
Repo: chronicler-ai/chronicle PR: 178
File: backends/advanced/src/advanced_omi_backend/services/memory/providers/mycelia.py:218-223
Timestamp: 2025-12-08T23:52:34.959Z
Learning: In Python code (chronicle project), prefer logging.exception() inside except blocks to automatically log the full stack trace. When re-raising exceptions, always chain with 'raise ... from e' to preserve the original context; use 'raise ... from None' only if you explicitly want to suppress the context. This improves debuggability across Python files.

Applied to files:

  • backends/advanced/src/advanced_omi_backend/services/transcription/parakeet_stream_consumer.py
  • backends/advanced/src/advanced_omi_backend/workers/audio_stream_parakeet_worker.py
  • backends/advanced/src/advanced_omi_backend/controllers/websocket_controller.py
  • backends/advanced/tests/test_integration.py
  • services.py
📚 Learning: 2025-12-16T14:24:28.301Z
Learnt from: CR
Repo: chronicler-ai/chronicle PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-16T14:24:28.301Z
Learning: Applies to **/*.py : Use `uv run python` or `uv run python3` instead of direct `python` or `python3` commands for Python execution

Applied to files:

  • Docs/ports-and-access.md
  • Docs/init-system.md
📚 Learning: 2025-12-16T14:24:28.301Z
Learnt from: CR
Repo: chronicler-ai/chronicle PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-16T14:24:28.301Z
Learning: Applies to **/{websocket,ws,audio,streaming}*.py : Use Wyoming protocol (JSONL + binary) for WebSocket communication with structured audio sessions

Applied to files:

  • backends/advanced/src/advanced_omi_backend/controllers/websocket_controller.py
🧬 Code graph analysis (1)
backends/advanced/run-test.sh (3)
backends/advanced/setup-https.sh (3)
  • print_info (15-17)
  • print_error (27-29)
  • print_warning (23-25)
run-test.sh (3)
  • print_info (17-19)
  • print_error (29-31)
  • print_warning (25-27)
extras/speaker-recognition/run-test.sh (3)
  • print_info (34-36)
  • print_error (46-48)
  • print_warning (42-44)
🪛 markdownlint-cli2 (0.18.1)
Docs/ports-and-access.md

121-121: Bare URL used

(MD034, no-bare-urls)

🪛 Ruff (0.14.8)
backends/advanced/src/advanced_omi_backend/services/transcription/parakeet_stream_consumer.py

40-40: Avoid specifying long messages outside the exception class

(TRY003)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: robot-tests
🔇 Additional comments (18)
Docs/ports-and-access.md (2)

104-121: LGTM! Clear documentation for restart functionality.

The restart command documentation is well-structured and provides helpful guidance:

  • Clear examples for restarting all services vs. specific services
  • Useful distinction between restart (for config changes) and stop + start --build (for code changes)
  • Convenience scripts align with the implementation in services.py

145-145: Good update to port conflict resolution guidance.

The updated recommendation to use restart --all or ./restart.sh provides a more streamlined workflow for resolving port conflicts after configuration changes.

backends/advanced/src/advanced_omi_backend/services/transcription/parakeet_stream_consumer.py (1)

38-40: Good simplification of provider configuration.

Removing the OFFLINE_ASR_TCP_URI fallback and requiring explicit PARAKEET_ASR_URL improves clarity and aligns with the PR's goal to streamline provider selection. The updated error message is more specific and helpful.

Note: The Ruff warning (TRY003) about message length is a minor style preference and can be safely ignored here - the message is short and clear.

backends/advanced/src/advanced_omi_backend/controllers/websocket_controller.py (1)

307-320: Excellent improvement to provider auto-detection logic.

The updated logic is clear, explicit, and follows a sensible priority order:

  1. Explicit provider configuration takes precedence
  2. Auto-detection prefers Parakeet (local) if PARAKEET_ASR_URL is set
  3. Falls back to Deepgram if DEEPGRAM_API_KEY is set
  4. Raises a clear, actionable error if no provider is configured

The removal of "offline" provider support simplifies the codebase and the error message guides users on what environment variables are required.

Docs/init-system.md (1)

151-177: Well-documented restart functionality with helpful user guidance.

The documentation additions effectively cover:

  • Restart commands for all and specific services
  • Convenience scripts for quick operations
  • Critical distinction between restart (config changes) and stop + start --build (code changes)
  • Concrete example of the rebuild workflow

This guidance will help prevent common user mistakes like using restart when they need to rebuild after code changes.

quickstart.md (2)

197-202: Good addition of convenience script option.

Providing both the quick ./start.sh script and the full uv run command gives users flexibility while maintaining transparency. The "recommended" label on Option 1 guides beginners appropriately.


291-305: Excellent troubleshooting expansion.

The enhanced troubleshooting section provides practical guidance for common issues:

  • General service management with restart commands and status checks
  • Cloud service considerations (costs, model recommendations)
  • Local service troubleshooting (startup issues, performance, resource constraints)

This comprehensive guidance will significantly improve the user experience when encountering problems.

services.py (2)

240-262: Well-implemented restart functionality.

The restart_services function correctly:

  • Validates service names against the SERVICES registry
  • Checks service configuration before attempting restart
  • Uses Docker Compose's restart command (preserves images, restarts containers)
  • Tracks and reports success/failure for each service

The implementation follows the same pattern as start_services and stop_services, maintaining consistency across the codebase.


304-309: Clean CLI integration for restart command.

The restart subcommand implementation is well-designed:

  • Follows the same argument structure as start/stop commands (consistency)
  • --all flag correctly filters to configured services only
  • Service name validation prevents invalid inputs
  • Appropriate error messages for missing arguments

The handling in main() mirrors the start/stop logic, maintaining code consistency and making the codebase easier to understand and maintain.

Also applies to: 357-372

backends/advanced/tests/test_integration.py (2)

112-112: Good rename for clarity.

Renaming TEST_AUDIO_PATH_OFFLINE to TEST_AUDIO_PATH_PARAKEET improves code clarity and aligns with the PR's goal to use explicit provider naming instead of the ambiguous "offline" term.


428-428: Consistent naming updates throughout test file.

The updates to phase comments and audio file selection logic correctly reflect the transition from "offline" to "parakeet" naming. Test behavior remains unchanged - appropriate test files are selected based on the configured provider.

Also applies to: 719-719, 1442-1442

backends/advanced/run-test.sh (2)

42-60: Improved environment loading with clear priority.

The updated environment loading logic is much better:

  • Clear priority order: CI environment → .env.test → .env
  • Informative messages for each source
  • Helpful error guidance for both local development and CI setup

The CI detection (checking for DEEPGRAM_API_KEY) works well for typical CI scenarios where cloud services are used.


62-109: Excellent provider-based API key validation.

The new validation logic is a significant improvement:

  • Only validates keys actually required for the configured providers
  • Supports multiple provider combinations (e.g., Parakeet + OpenAI, Deepgram + Ollama)
  • Clear reporting of configured providers and key status
  • Graceful handling of unknown providers with warnings instead of hard failures

This makes the test script much more flexible and user-friendly for different deployment scenarios.

Minor observation: Mistral is included as a transcription provider option (lines 79-85), but I don't see Mistral transcription support in the codebase changes. This might be future-proofing, which is fine.

backends/advanced/start-workers.sh (4)

54-73: LGTM! Conditional worker startup is well-implemented.

The conditional logic correctly starts stream workers only when their respective environment variables are set. Setting PID variables to empty strings when workers are skipped enables safe conditional checks throughout the rest of the script.


83-84: LGTM! Conditional logging is correct.

The conditional echo statements properly display worker PIDs only when the workers were actually started.


124-126: LGTM! Health monitoring kill logic handles conditional workers correctly.

The conditional kill statements for stream workers are properly implemented and won't cause errors when those workers weren't started.


151-152: LGTM! Shutdown and cleanup logic is consistent.

The conditional termination logic for stream workers is correctly implemented in both the shutdown handler and final cleanup section, maintaining consistency with the health monitoring approach.

Also applies to: 185-186

backends/advanced/src/advanced_omi_backend/workers/audio_stream_parakeet_worker.py (1)

31-35: LGTM! Configuration correctly uses explicit PARAKEET_ASR_URL.

The removal of the OFFLINE_ASR_TCP_URI fallback aligns with the PR's goal of removing implicit "offline" provider support in favor of explicit Parakeet configuration. The early return when the URL is not set is appropriate, especially since the worker startup script now conditionally launches this worker based on the environment variable.

@AnkushMalaker
Copy link
Collaborator Author

Actually maybe instead of a separate restart.sh, it would be easier to just have a param in start.sh --restart which just restarts?

@thestumonkey
Copy link
Contributor

is merge-dev the same as merging main now?

@thestumonkey
Copy link
Contributor

as long as robot tests run with this config lgtm

Copy link
Contributor

@thestumonkey thestumonkey left a comment

Choose a reason for hiding this comment

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

lgtm as long as robot tests pass

@AnkushMalaker AnkushMalaker merged commit 9a2b3f9 into dev Dec 18, 2025
1 of 2 checks passed
@github-actions
Copy link

⚠️ Robot Framework Test Results

Status: ❌ Some tests failed

Metric Count
✅ Passed 90
❌ Failed 1
📊 Total 91

📊 View Reports

GitHub Pages (Live Reports):

Download Artifacts:


View full workflow run

@coderabbitai coderabbitai bot mentioned this pull request Dec 18, 2025
@AnkushMalaker AnkushMalaker deleted the dev-2 branch December 18, 2025 19:39
@coderabbitai coderabbitai bot mentioned this pull request Jan 10, 2026
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.

3 participants