Skip to content

docs(sdk): document the in-process Python SDK + add a runnable demo#440

Merged
padak merged 2 commits into
mainfrom
docs/sdk-guide-and-examples
Jun 17, 2026
Merged

docs(sdk): document the in-process Python SDK + add a runnable demo#440
padak merged 2 commits into
mainfrom
docs/sdk-guide-and-examples

Conversation

@padak

@padak padak commented Jun 17, 2026

Copy link
Copy Markdown
Member

Why

The importable Client facade (lib.py) and its typed result models (result_models.py, #428) are committed public API, but had no developer-facing documentation — and a few doc surfaces had drifted (some by the recent #424 rename). This PR documents how to program against kbagent's Python SDK, ships a runnable teaching demo, and fixes the drift. No code changes.

What

New — SDK documentation

  • docs/sdk.md — the deep reference:
    • the three programmable surfaces (CLI / in-process SDK / serve REST) and when to pick each;
    • where the facade sits in the 3-layer architecture (it's a 4th caller that skips the service layer);
    • full method reference — query / query_result / run_job / config_detail / upload_table / files / raw;
    • the typed result-model contract (extra="allow" forward-compat, populate_by_name aliasing, semver via __all__), py.typed;
    • idempotent run_job (feat(sdk): idempotency keys for run_job (and push) — safe replay after interruption #427), a gotchas cheat-sheet (Snowflake string-typing, UPPERCASE columns, no auto-create, ...);
    • a contributor section on extending the SDK.
  • CONTRIBUTING.md → "Extending the importable SDK" — a checklist parallel to "Adding a New CLI Command", linking docs/sdk.md.

New — runnable demo

  • examples/storage_tui/ — a dependency-free curses Storage browser (buckets → tables → detail + data preview) driven entirely through from keboola_agent_cli import Client and client.raw. No mocks (live data, empty-states rendered honestly); fail-fast on missing KBC_URL/KBC_TOKEN; token never printed/logged/written. app.py + _render.py (pure drawing) + README.md.
  • examples/README.md — index + "which surface should I build on?" guide.

Drift fixes

File Was Now
CLAUDE.md (Versioning) "APP_NAME = "keboola-cli"" (fixed literal) APP_NAME resolved dynamically (_resolve_app_name, shipped 0.63.1)
CONTRIBUTING.md "Python 3.11+" "Python 3.12+" (matches pyproject requires-python)
CLAUDE.md (Project Structure) __init__.py # exposes __version__ documents the public SDK entrypoint; adds lib.py / result_models.py / py.typed
README.md "Use as a library" + Documentation table now link docs/sdk.md and the demo

Verification

  • Every documented method/signature was checked against the actual source (lib.py, result_models.py, client.py) — no invented API.
  • Demo: ruff check + ruff format --check clean; parses; imports with KBC_URL/KBC_TOKEN unset without any network (all config/API work is inside main()).
  • All relative doc links resolve to real files.
  • make check green — 4099 passed (no code touched in src//tests/).

Note

No version bump / changelog entry — this is docs + examples only, not a release. examples/ is outside the wheel ([tool.hatch.build.targets.wheel] packages = ["src/keboola_agent_cli"]) and outside the CI lint scope (src/ tests/), but was kept ruff-clean anyway.


Open in Devin Review

The importable `Client` facade (lib.py) and its typed result models
(result_models.py, #428) were a committed public API with no developer-facing
documentation, and a few doc surfaces had drifted. This adds the missing SDK
guide, a teaching demo, and fixes the drift.

New:
- docs/sdk.md -- deep SDK reference: what it is vs CLI vs serve REST, where the
  facade sits in the 3-layer architecture, full method reference (query/
  query_result/run_job/config_detail/upload_table/files/raw), the typed
  result-model contract (extra="allow" + populate_by_name + semver via __all__),
  py.typed, idempotent run_job, a gotchas cheat-sheet, and a contributor section
  on extending the SDK.
- examples/storage_tui/ -- a runnable, dependency-free curses Storage browser
  (buckets -> tables -> detail+preview) driven entirely through
  `from keboola_agent_cli import Client` and `client.raw`. No mocks, fail-fast on
  missing KBC_URL/KBC_TOKEN, token never printed/logged. + examples/README.md index.
- CONTRIBUTING.md "Extending the importable SDK" section (parallel to "Adding a
  New CLI Command") linking the docs/sdk.md checklist.

Drift fixes:
- CLAUDE.md: APP_NAME is now resolved dynamically (constants._resolve_app_name,
  shipped in 0.63.1) -- it is no longer the fixed literal "keboola-cli" the doc
  claimed.
- CONTRIBUTING.md: Python 3.12+ (matches pyproject requires-python), was 3.11+.
- CLAUDE.md Project Structure: __init__.py is the public SDK entrypoint; added
  lib.py / result_models.py / py.typed.
- README.md: "Use as a library" + Documentation table link docs/sdk.md and the demo.

No code changes; make check green (4099 passed).

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

Open in Devin Review

Comment thread examples/storage_tui/app.py Outdated
…tuple

Devin review on PR #440: the storage_tui demo returned
`tuple[list[str], list[list[str]]]` (two semantically distinct values), which
CONTRIBUTING.md "Code Quality Patterns" forbids -- doubly important in a PR that
documents that very rule. Introduce a frozen `PreviewData(header, rows)` and use
attribute access at the call site.
@padak padak merged commit a58a2ef into main Jun 17, 2026
4 checks passed
@padak padak deleted the docs/sdk-guide-and-examples branch June 17, 2026 20:00
padak added a commit that referenced this pull request Jun 17, 2026
Release-only bump for the SDK documentation landed in #440 (docs/sdk.md, the
examples/storage_tui demo, the CONTRIBUTING "Extending the importable SDK"
section, and the doc-drift fixes). No runtime code change: docs and examples
ship in the repo, not the wheel, so the installed package is functionally
identical to 0.63.1. The bump exists so `kbagent changelog` surfaces the new SDK
guide and the release carries the migration-bridge compat wheel for any <=0.62
client that updates to latest.
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