Skip to content

feat(testgen): support pip install#87

Merged
aarthy-dk merged 6 commits intomainfrom
tg-pip
May 5, 2026
Merged

feat(testgen): support pip install#87
aarthy-dk merged 6 commits intomainfrom
tg-pip

Conversation

@aarthy-dk
Copy link
Copy Markdown
Contributor

@aarthy-dk aarthy-dk commented May 5, 2026

Summary

Adds a pip-via-uv install path for TestGen alongside the existing Docker Compose path, driven by Windows Docker abandonment data. End users now have a one-command experience: tg install resolves the right mode, runs the install steps, and leaves the app running.

Motivation

Telemetry shows a meaningful share of Windows users abandon installs at the Docker prerequisite step. The pip path uses an embedded Postgres and a uv-managed venv, removing Docker as a hard requirement for evaluation/light use. Docker remains the recommended path for persistent installs.

What's new

  • tg install --pip / tg install --docker — explicit mode selection. With no flag, the installer auto-detects: if Docker prerequisites pass it prompts the user for a mode; if Docker can't even be reached (engine missing, registry blocked) it asks Install with pip instead? [Y/n] rather than silently routing.
  • tg start — new command that runs the app. Pip mode runs testgen run-app in the foreground until Ctrl+C; Docker mode runs docker compose up --wait.
  • Auto-start at the end of tg install (pip mode) — "one command, app running" requirement. The installer keeps the foreground subprocess alive until the user interrupts, then prints a tg start hint for next time.
  • All TestGen sub-commands handle both modestg upgrade, tg delete, tg run-demo, tg delete-demo read an install marker (dk-tg-install.json) and dispatch accordingly. Legacy Docker installs without a marker are still recognized via the compose-file + credentials fallback.
  • Telemetryinstall_mode, actual installed testgen_version, actual installed uv_version (parsed from uv --version), and uv_source (existing-on-PATH vs downloaded) on every relevant event.

Architecture notes for reviewers

  • Single Testgen*Action per CLI command, replacing an earlier dispatcher pattern (separate *PipInstall, *DockerInstall, etc. classes). Each unified class resolves mode once in check_requirements, persists self._resolved_mode, and switches self.steps / branches in execute accordingly. See "TestGen install modes" in CLAUDE.md for the pattern.
  • Per-invocation reset (Action._per_invocation_attrs + _reset_per_invocation_state) clears _cmd_idx, ctx, _resolved_mode, etc. at the top of execute_with_log so repeated invocations from the Windows menu start fresh.
  • uv bootstrap pins UV_VERSION = 0.11.7 and SHA256-pins each platform asset. Three retries with exponential backoff for transient network errors; deterministic failures (SHA256 mismatch, malformed archive) fail fast. Bump procedure documented in CLAUDE.md.
  • start_testgen_app uses Popen directly with DEVNULL for stdout/stderr (TestGen writes its own logs via TESTGEN_LOG_FILE_PATH; capturing the pipes would deadlock on the indefinite-running subprocess once the OS pipe buffer fills). Port readiness is detected via socket.create_connection polling.
  • Config-driven port/SSL for start_testgen_app — reads ~/.testgen/config.env rather than args so tg start works without re-passing --port / --ssl-* flags.

Test plan

  • Linux/macOS pip install: python3 dk-installer.py tg install --pip → app reachable at http://localhost:8501. Ctrl+C → tg start brings it back up at the same URL.
  • Linux/macOS Docker install: python3 dk-installer.py tg install --docker → containers running, URLs in dk-tg-credentials.txt. tg start after docker compose down brings them back.
  • Auto-detect with Docker missing: uninstall Docker, run tg install (no flag) → "Docker is not fully available... Install TestGen with pip? [Y/n]" prompt. Y → pip install; n → abort with hints.
  • Auto-detect with Docker present: run tg install (no flag) → [d] Docker / [p] Pip prompt. Both choices route correctly.
  • Custom port: tg install --pip --port 9000 → app at :9000. Ctrl+C, tg start → still :9000 (read from ~/.testgen/config.env, no flag re-pass needed).
  • Mode-aware upgrade/delete/run-demo/delete-demo: install one mode, run each sub-command, verify the right path is taken (e.g., pip delete removes ~/.testgen and dataops-testgen from uv's tool list; docker delete removes containers and volumes).
  • Existing-install detection: install once, run tg install again → "Found an existing TestGen … installation" abort with tg upgrade / tg delete hints.
  • Legacy Docker install detection: with no dk-tg-install.json but docker-compose.yml + dk-tg-credentials.txt present, tg upgrade / tg delete should still resolve to Docker mode.
  • Windows .exe via menu: install → run via menu, then run another menu action, then run install again — confirm no state leaks across invocations (e.g., correct mode resolution each time).
  • Support zip on failure: trigger an install failure (e.g., set up a port collision, or block docker.io), confirm the .dk-installer/<action>-<timestamp>.zip contains the expected per-command output and that the autogenerated password is not in any file.
  • Existing obs install / obs upgrade / obs delete flows — regression check, no behavior changes intended.

Files

  • dk-installer.py (~+930 lines) — the installer.
  • tests/ — 174 tests passing; new files for pip install/upgrade/delete/demo, the tg start command, install-mode marker, and uv bootstrap.
  • CLAUDE.md, README.md, .gitignore updated.

@aarthy-dk aarthy-dk requested review from diogodk, luis-dk and rboni-dk May 5, 2026 07:42
Comment thread dk-installer.py Outdated
Comment thread dk-installer.py Outdated
Comment thread dk-installer.py
Comment thread dk-installer.py Outdated
aarthy-dk and others added 2 commits May 5, 2026 16:45
Pip mode opens the browser via Streamlit. Docker mode now matches: install
opens to the configured port, start reads TG_UI_BASE_URL from the compose
file. Both fall back silently when no browser is available. Tests patch
webbrowser.open globally so local pytest runs don't spawn tabs.

Also: only print the log path on tg start (it's already in the credentials
file at install time), tighten the UvBootstrapStep label, and reword a
delete-demo console message.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Recommend Docker when available; document the [d/p] auto-detect prompt
  and the failed-prereq fallback path
- Mention --no-demo, --api-port, tg start, and the auto-browser-open
- Drop the TG_STANDALONE_MODE=yes uv tool run … references
- Bump pip-install time estimate to 4-8 minutes (matching the intro_text)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@aarthy-dk aarthy-dk merged commit e8aec12 into main May 5, 2026
3 checks passed
@aarthy-dk aarthy-dk deleted the tg-pip branch May 5, 2026 21:45
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