Skip to content

Cherry-pick run.py Docker diagnostics from PR #607#609

Open
Copilot wants to merge 7 commits intodevfrom
copilot/cherry-pick-pr-607-fix
Open

Cherry-pick run.py Docker diagnostics from PR #607#609
Copilot wants to merge 7 commits intodevfrom
copilot/cherry-pick-pr-607-fix

Conversation

Copy link
Contributor

Copilot AI commented Jan 29, 2026

Cherry-picks commit 6f3b34a from PR #607 to enable independent merging of Docker container verification improvements.

Changes

  • verify_docker_containers(): Queries docker ps to collect container status, returns structured health data
  • print_container_diagnostics(): Surfaces actionable troubleshooting commands when containers fail to start
  • wait_for_all_services(): Adds skip_docker_control parameter

Context

Original commit by @anirudTT adds runtime container health checks and diagnostic output to catch Docker startup failures earlier with better error messages.

def verify_docker_containers():
    """Verify that Docker containers started successfully."""
    result = subprocess.run(
        ["docker", "ps", "-a", "--filter", "name=tt_studio", "--format", "{{.Names}}\t{{.Status}}"],
        capture_output=True, text=True, check=False
    )
    # Returns {container_name: {status: ..., running: bool}}
Original prompt

This section details on the original issue you should resolve

<issue_title>Cherry pick commit from PR #607 (Anirud/run.py fix) into a new branch</issue_title>
<issue_description>Is your feature request related to a problem? Please describe.
I would like to cherry pick the commit from PR #607 (Anirud/run.py fix) into a new branch.

Describe the solution you'd like
Please cherry pick the commit associated with PR #607 into a newly created branch so it can be merged independently if needed.

Describe alternatives you've considered
Directly merging the PR into another branch, but a targeted cherry-pick is preferred for better traceability.

Additional context
This is to ensure that the fix from #607 is made available on a dedicated branch as required.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

- Added `verify_docker_containers` function to check the status of Docker containers and return their health information.
Copilot AI changed the title [WIP] Cherry pick commit from PR #607 into new branch Cherry-pick run.py Docker diagnostics from PR #607 Jan 29, 2026
Copilot AI requested a review from anirudTT January 29, 2026 17:22
@anirudTT anirudTT mentioned this pull request Jan 29, 2026
…on in run.py

- Introduced `run_command_with_error_reporting` to enhance command execution with detailed error messages and suggestions for common issues.
- Added `report_file_operation_error` and `safe_file_operation` for improved file operation error handling.
- Implemented `suggest_docker_fixes` and `suggest_pip_fixes` to provide users with actionable solutions for Docker and pip-related errors.
- Enhanced `parse_docker_build_failure` to identify failing containers and extract relevant error information.
- Updated `show_docker_build_progress_header` to display building status for Docker containers.
  Add comprehensive test suite for Docker build failure detection.
  Includes automated venv setup and 'python run.py tests build' command.
- Improved `parse_docker_build_failure` to provide more detailed insights into build errors.
- Updated error reporting functions to include suggestions for resolving Docker-related issues.
- Refined the overall error handling mechanism to enhance user experience during Docker operations.
@anirudTT anirudTT marked this pull request as ready for review February 9, 2026 20:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR expands run.py to provide richer Docker compose build/start diagnostics (including container-status verification, guided troubleshooting output, and a new tests build command), while also introducing a pytest-based Docker build test suite and simple CLI install/uninstall wrappers.

Changes:

  • Add Docker compose output streaming + build-failure parsing, container startup verification, and richer health-check error reporting in run.py.
  • Introduce python run.py tests build with automatic venv setup and a new pytest suite to validate Docker build failure detection.
  • Add tt-studio wrapper plus install.sh / uninstall.sh for a symlink-based CLI install.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
run.py Adds compose progress streaming, build/start diagnostics, container verification, and a new tests build command path.
tests/test_docker_builds.py Adds Docker build success/failure tests (with injected Dockerfile failures) + compose config validation for Chroma.
tests/conftest.py Adds shared pytest fixtures and helpers for docker build/compose build execution.
tests/README.md Documents how to run the new tests (but currently has broken code fences).
tests/__init__.py Initializes the new tests package.
pytest.ini Adds pytest discovery + markers + strict marker enforcement and timeout config.
dev-tools/requirements-dev.txt Adds pytest tooling deps needed for the new test suite.
tt-studio Adds a wrapper script to invoke run.py via python3.
install.sh Adds symlink-based install to ~/.local/bin/tt-studio.
uninstall.sh Adds removal of the installed symlink.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +196 to +197


Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

run_command_with_error_reporting, report_file_operation_error, and safe_file_operation are added but never used anywhere in this script. This increases maintenance surface and can confuse future edits; either remove them or refactor call sites to use them consistently (e.g., replace ad-hoc subprocess/file error handling).

Suggested change
# Keep references to helper functions to avoid them being treated as unused.
_HELPER_FUNCS = (
run_command_with_error_reporting,
report_file_operation_error,
safe_file_operation,
)

Copilot uses AI. Check for mistakes.
Comment on lines +1520 to +1527
try:
# Run docker ps to check running containers
result = subprocess.run(
["docker", "ps", "-a", "--filter", "name=tt_studio", "--format", "{{.Names}}\t{{.Status}}"],
capture_output=True,
text=True,
check=False
)
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

verify_docker_containers() always runs docker ps without sudo. If the user lacks docker socket permissions (the code path where you run docker compose via sudo), this verification will fail and incorrectly abort startup. Consider using run_docker_command(..., use_sudo=not has_docker_access) or add a use_sudo/has_docker_access parameter.

Copilot uses AI. Check for mistakes.
Comment on lines 1261 to +1270
try:
print(f"{C_BLUE}🛑 Stopping Docker containers...{C_RESET}")
result = run_docker_command(docker_compose_cmd, use_sudo=not has_docker_access, capture_output=False)
result = run_docker_command(docker_compose_cmd, use_sudo=not has_docker_access, capture_output=True)
if result.returncode == 0:
print(f"{C_GREEN}✅ Docker containers stopped successfully.{C_RESET}")
else:
print(f"{C_GREEN}✅ Docker containers stopped successfully.{C_RESET}")
print(f"{C_YELLOW}⚠️ Warning: Docker compose down reported issues{C_RESET}")
print(f"{C_YELLOW} Exit code: {result.returncode}{C_RESET}")
if hasattr(result, 'stderr') and result.stderr:
print(f"{C_YELLOW} {result.stderr}{C_RESET}")
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

cleanup_resources() now passes capture_output=True to run_docker_command, but run_docker_command ignores capture_output when use_sudo=True (it always runs sudo with capture_output=False). As a result, the new stderr-based warnings often won’t show details in the common “needs sudo” case; consider teaching run_docker_command to capture output for sudo runs (while still allowing interactive prompts when needed).

Copilot uses AI. Check for mistakes.
Comment on lines +3176 to +3177
venv_python = os.path.join(venv_dir, "bin", "python3")
venv_pip = os.path.join(venv_dir, "bin", "pip")
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

run_build_tests() hardcodes the venv interpreter to .venv/bin/python3. Some virtualenvs only guarantee .venv/bin/python (and on non-POSIX platforms the path is different). Prefer deriving the interpreter path more robustly (e.g., .venv/bin/python on POSIX, or use sys.executable after activation logic).

Suggested change
venv_python = os.path.join(venv_dir, "bin", "python3")
venv_pip = os.path.join(venv_dir, "bin", "pip")
if os.name == "nt":
venv_bin_dir = os.path.join(venv_dir, "Scripts")
else:
venv_bin_dir = os.path.join(venv_dir, "bin")
venv_python = os.path.join(venv_bin_dir, "python")
venv_pip = os.path.join(venv_bin_dir, "pip")

Copilot uses AI. Check for mistakes.
Comment on lines +17 to +27
### Advanced Method (Direct pytest)

```bash
# Run all tests
pytest

### Run specific test files

```bash
pytest tests/test_docker_builds.py
```
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

The Markdown code fences are unbalanced: a bash block starts under “Advanced Method” but isn’t closed before the next headings, and another bash starts inside it. This breaks rendering; close the first code fence after pytest and remove the nested fence.

Copilot uses AI. Check for mistakes.
Comment on lines +1584 to +1588
print(f"\n # View all container logs:")
print(f" docker logs -f tt_studio_backend")
print(f" docker logs -f tt_studio_frontend")
print(f" docker logs -f tt_studio_chroma")

Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

The diagnostic commands omit the agent container and also always suggest docker logs ... without sudo. Add tt_studio_agent to the “all container logs” list, and consider printing sudo-prefixed commands (or conditional guidance) when the user doesn’t have docker socket access.

Copilot uses AI. Check for mistakes.
Comment on lines +3170 to +3174
def run_build_tests():
"""Run Docker build tests with automatic virtual environment setup."""
print(f"\n{C_TT_PURPLE}{C_BOLD}🧪 Docker Build Tests{C_RESET}")
print(f"{C_YELLOW}{'=' * 60}{C_RESET}\n")

Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

The PR description/title indicate a cherry-pick of Docker diagnostics from PR #607, but this PR also adds install/uninstall scripts and a full pytest suite/config. Please update the PR description/title to match the actual scope, or split unrelated changes into separate PRs for easier review and rollback.

Copilot uses AI. Check for mistakes.
print(f"📦 Installing Python requirements from requirements-api.txt...")
try:
run_command([venv_pip, "install", "-r", "requirements-api.txt"], check=True)
result = subprocess.run(
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

Variable result is not used.

Suggested change
result = subprocess.run(
subprocess.run(

Copilot uses AI. Check for mistakes.
"""

import shutil
from pathlib import Path
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

Import of 'Path' is not used.

Suggested change
from pathlib import Path

Copilot uses AI. Check for mistakes.
}

# Look for error patterns like "[tt_studio_backend 7/8] RUN ..."
import re
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

This import of module re is redundant, as it was previously imported on line 35.

Suggested change
import re

Copilot uses AI. Check for mistakes.
@anirudTT anirudTT requested a review from rfatimaTT February 11, 2026 16:43
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