Skip to content

feat: analytics-agent quickstart — no-clone install via pip/uvx#27

Merged
shirshanka merged 5 commits into
mainfrom
feat/quickstart
May 5, 2026
Merged

feat: analytics-agent quickstart — no-clone install via pip/uvx#27
shirshanka merged 5 commits into
mainfrom
feat/quickstart

Conversation

@shirshanka

Copy link
Copy Markdown
Contributor

Summary

Users can now go from zero to a running analytics agent with a single copy-paste command — no git clone, no repo, no Docker required.

pip install datahub-analytics-agent && analytics-agent quickstart
# or with uv (no virtualenv needed):
uvx datahub-analytics-agent quickstart

What the wizard does

  1. Checks Python version and port availability
  2. Prompts for LLM provider (anthropic / openai / google / bedrock) and API key
  3. Optionally connects a data source (Snowflake, BigQuery, PostgreSQL, MySQL)
  4. Writes config to ~/.datahub/analytics-agent/ alongside the DataHub CLI's own config
  5. Bootstraps the database, starts the server, opens the browser

Idempotent — re-running detects existing config and offers start / reconfigure / cancel.

New CLI commands

Command Description
quickstart Interactive setup wizard
demo Full demo: DataHub quickstart + Olist MySQL sample data + metadata ingestion
start Start server from existing config (no wizard)
stop Stop the running server
status Show PID and URL
logs Tail ~/.datahub/analytics-agent/logs/agent.log
config Open config directory in $EDITOR

Config location

All user state lives under ~/.datahub/analytics-agent/:

~/.datahub/analytics-agent/
  .env            ← LLM API keys, provider
  config.yaml     ← engine connections
  data/agent.db   ← SQLite DB
  logs/agent.log  ← server log
  agent.pid       ← PID:port for lifecycle management

DATABASE_URL and ENGINES_CONFIG now default to the config dir so a pip-installed package works without any local .env file.

Demo mode

analytics-agent demo runs the full DataHub quickstart + loads the Olist e-commerce MySQL sample dataset + ingests metadata into DataHub — same experience as the existing quickstart.sh but triggered from the installed CLI.

Test plan

  • pip install datahub-analytics-agent && analytics-agent quickstart — complete wizard, verify server starts and browser opens
  • Re-run analytics-agent quickstart — detects existing config, offers start/reconfigure/cancel
  • analytics-agent stopanalytics-agent status shows not running
  • analytics-agent start → server restarts
  • analytics-agent logs tails the log file
  • uv run pytest tests/unit/ -v — 170 tests passing

🤖 Generated with Claude Code

shirshanka and others added 5 commits May 4, 2026 15:44
Users can now go from zero to a running agent with a single command:

  pip install datahub-analytics-agent && analytics-agent quickstart
  # or: uvx datahub-analytics-agent quickstart

The interactive wizard prompts for LLM provider + API key, an optional
data source connection, then bootstraps the DB, starts the server, and
opens the browser. Config lives in ~/.datahub/analytics-agent/ alongside
the DataHub CLI's own config.

New CLI commands:
  quickstart   Interactive setup wizard (idempotent — detects existing config)
  demo         Full demo: DataHub quickstart + Olist MySQL + metadata ingestion
  start        Start server from existing config (no wizard)
  stop         Stop running server
  status       Show PID and URL of running server
  logs         Tail ~/.datahub/analytics-agent/logs/agent.log
  config       Open config directory in \$EDITOR or print its path

Server lifecycle managed via PID file at ~/.datahub/analytics-agent/agent.pid.
DATABASE_URL and ENGINES_CONFIG now default to the config dir so a pip-installed
package works out of the box without any local repo or .env file.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Two bugs prevented migrations from running during `analytics-agent quickstart`:

1. `python -m analytics_agent.cli bootstrap` was a no-op because cli.py had
   no `if __name__ == "__main__"` block — Click never got invoked, subprocess
   exited 0, and no tables were created.

2. `run_migrations()` called `Config("alembic.ini")` with a relative path that
   only resolves from the repo root. For pip-installed users (no checked-out
   repo) this silently produces an empty Alembic config and skips all migrations.
   Fixed by deriving script_location from the installed package path, with
   alembic.ini-in-CWD as a fallback for the dev/Docker workflow.

Also moved the "✓ Database initialised" echo to after bootstrap succeeds so
failures are no longer masked.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add two tests that would have caught the bugs fixed in the previous commit:

- test_run_migrations_works_without_alembic_ini_in_cwd: verifies migrations
  run from a CWD with no alembic.ini (simulates pip-install environment).

- test_cli_module_invocable_via_dash_m: verifies `python -m analytics_agent.cli
  bootstrap` actually runs migrations, catching the missing __main__ entry point.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Dockerfile was missing hatch_build.py in the COPY layer, causing
  `uv sync --no-dev` to fail with "Build script does not exist: hatch_build.py"
- Remove unused `analytics_agent.config` import from test_cli.py (ruff F401)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- ingest_metadata.py: annotate payload as dict[str, object] so mypy
  accepts assigning a dict value alongside a str value (mypy was inferring
  dict[str, str] from the initial literal).

- token-counting.spec.ts: the "Working" AgentWorkBlock state is only
  visible for ~320ms (4 mock events × 80ms). On slow CI the Playwright
  poller may miss this transient. Accept either "Working" or "Worked for"
  as the presence check; the final assertions (token badge, expand) still
  fully verify the feature.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@shirshanka shirshanka merged commit 54b2394 into main May 5, 2026
7 checks passed
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.

1 participant