feat(python): add Python Tasks TUI quickstart - #311
feat(python): add Python Tasks TUI quickstart#311Chris Draper (draper-ditto) wants to merge 1 commit into
Conversation
Revives the python-tui app from the closed PR #303, reconciled against the shipped dittolive-ditto 5.2.0.dev0 preview API. Refs SDKS-4749. Changes from #303: - Use the repo's current .env contract (DITTO_DATABASE_ID / DITTO_DEVELOPMENT_TOKEN / DITTO_SERVER_URL) to match .env.sample and go-tui, rather than the older APP_ID/PLAYGROUND_TOKEN/AUTH_URL names. - Drop the python-dotenv dependency; the SDK is now the only dependency. - Fix DittoLogger.min_level -> DittoLogger.minimum_log_level (the real name is a metaclass property and does not appear in dir()). - Only call sync.start() when configured against a server: starting sync requires an activated instance, so a license-free local peer raises DittoError <activation>. The store, subscriptions, and observers work without activation. - Do not remove the persistence directory on exit; Ditto keeps writing to its rotating log directory under it until the process exits. - Add a --smoke self-test that runs the full CRUD path with no credentials and no network, plus `just python-tui` / `just python-tui-smoke`. Verified: --smoke passes on Python 3.10.21, 3.13.15, and 3.14.7 (macOS arm64). Cloud sync against a Portal database is not yet verified. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
There was a problem hiding this comment.
🟡 Changes recommended
The uv/pip run instructions and just recipes don’t consistently enforce the SDK version constraint declared in pyproject.toml, and the smoke-path observer timeout is likely too low for reliable CI execution.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds a new python-tui quickstart to the repo: a Python console “Tasks” app that uses the shared cross-SDK tasks schema and includes a credential-free --smoke mode intended for CI/self-test.
Changes:
- Introduces the Python Tasks TUI app (
python-tui/main.py) with offline/online configuration and a--smokeself-test path. - Adds Python TUI documentation and packaging metadata (
python-tui/README.md,python-tui/pyproject.toml) plus local env/gitignore scaffolding. - Wires the quickstart into repo entry points (
justfilerecipes, rootREADME.mdindex link).
File summaries
| File | Description |
|---|---|
| README.md | Adds an index entry linking to the Python TUI quickstart. |
| python-tui/README.md | Documents setup, running, commands, offline usage, and --smoke self-test. |
| python-tui/pyproject.toml | Declares the quickstart as a minimal Python project with Ditto SDK dependency and script entrypoint. |
| python-tui/main.py | Implements the Tasks app, Ditto configuration/auth flow, observer/subscription wiring, and smoke test. |
| python-tui/.gitignore | Ignores local env/venv and Python build artifacts for the quickstart directory. |
| python-tui/.env.sample | Provides a template for Portal-derived environment configuration. |
| justfile | Adds just python-tui and just python-tui-smoke run recipes. |
Review details
Suppressed comments (3)
python-tui/README.md:57
- Similarly,
pip install dittolive-dittomay not select the same minimum SDK version declared inpyproject.toml(and may skip pre-releases depending on index state). Pin the constraint to match the project dependency.
pip install dittolive-ditto
python-tui/README.md:94
- The
--smokeexample should also apply the same Ditto SDK version constraint aspyproject.toml, otherwise it can run against an unintended version.
uv run --with dittolive-ditto main.py --smoke
justfile:58
- Same issue for the smoke recipe: without the version constraint,
uvmay resolve a different SDK version than the project expects.
uv run --with dittolive-ditto main.py --smoke
- Files reviewed: 7/7 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| cd python-tui | ||
| if command -v uv >/dev/null 2>&1; then | ||
| uv run --with dittolive-ditto main.py |
| async def _mutate(self, coro: Any) -> None: | ||
| """Run a write, then wait for the observer to reflect it.""" | ||
|
|
||
| self._updated.clear() | ||
| await coro | ||
| await self._wait_for_update(timeout=2.0) |
| Using [uv][1] (recommended — it installs Python and dependencies for you): | ||
|
|
||
| ```bash | ||
| uv run --with dittolive-ditto main.py |
Adds
python-tui, the Ditto Python SDK quickstart app: a Tasks console app onthe canonical cross-SDK
tasksschema, so it syncs with the Swift, Kotlin, Go,Rust, and JavaScript quickstarts.
This supersedes the
python-tuihalf of the closed #303. The app was rewrittenagainst the shipped
dittolive-ditto5.2.0.dev0 preview; the ROS 2 quickstartfrom that PR is not included here.
What's here
python-tui/main.py— the app, plus a--smokemode that runs the fullinsert / update / rename / soft-delete path against a temporary local peer
with no credentials and no network. That mode is what CI can run.
python-tui/README.md,.env.sample,pyproject.toml,.gitignorejustfilerecipes:just python-tuiandjust python-tui-smokeREADME.mdindex entryTesting
Verified against
dittolive-ditto5.2.0.dev0 on macOS arm64 (Python 3.12):uv run --with dittolive-ditto main.py --smoke— all six assertions passjust python-tui-smoke— passespython3 -m venv .venv+pip install dittolive-ditto, whichresolves the pre-release) — passes
syncingmode, and add /toggle / rename / delete all round-trip through the store observer
Note on dependency pinning
pyproject.tomlrequiresdittolive-ditto>=5.2.0.dev0. Only pre-releases arepublished on PyPI today, so this is the preview version; it will want a bump
when the Python SDK reaches GA.
Unblocks
mintlify-docs #703 — the Python quickstart page walks users through cloning this
repo and running
python-tui, so it can't ship until this directory is onmain.