Skip to content

Wire reverse codegen into tinybird pull --as-code - #28

Open
sandshoes wants to merge 3 commits into
mainfrom
tommy/protm-2259-wire-reverse-codegen
Open

sandshoes wants to merge 3 commits into
mainfrom
tommy/protm-2259-wire-reverse-codegen

Conversation

@sandshoes

Copy link
Copy Markdown
Contributor

Summary

  • The codegen/ module (live workspace resources → Python define_* source) was fully implemented and unit-tested but unreachable from generate, pull, or migrate.
  • Design decision: exposed it as tinybird pull --as-code, rather than a brand-new subcommand. pull already fetches live workspace resources; --as-code just swaps the output format from raw .datasource/.pipe/.connection datafiles to Python source (datasources.py, pipes.py, client.py via generate_all_files). This avoids a parallel "fetch workspace resources" code path and matches the ticket's suggested direction.
  • pull itself is not yet wired to the CLI entry point on main (it currently delegates to the upstream tb package, same as build/deploy/dev/login/branch/info/preview — each being wired in its own separate PR per PROTM-2255's sub-tickets, e.g. Wire native build/deploy/dev commands to CLI entry point #25, Wire native pull/login commands to CLI entry point #26, Wire native branch/info/preview commands to CLI entry point #27). This PR wires pull to the CLI itself so it's independently testable and mergeable; expect a small merge conflict in cli/index.py against PR Wire native pull/login commands to CLI entry point #26 (which also wires pull, without --as-code) — trivial to resolve by keeping both changes, whichever merges second.
  • Widened ResourceFileType to include "code" so the three generated files can flow through the same ResourceFile/write-loop machinery as datafile pulls.

Closes PROTM-2259: https://linear.app/tinybird/issue/PROTM-2259/python-sdk-wire-reverse-codegen-live-workspace-python-code-into-a-cli

Checklist

  • CI is green (lint, typecheck, test, secrets)
  • pre-commit run --all-files passes locally (gitleaks step fails in this sandbox on an unrelated SSL/network error fetching its pre-commit env, not a code issue)
  • Tests were added or updated when behavior changed
  • Public API / typing changes were reviewed
  • Documentation was updated (README.md / CONTRIBUTING.md) if needed
  • Breaking changes are clearly documented
  • CHANGELOG.md was updated when user-facing behavior changed

Tommy Healy and others added 3 commits October 1, 2026 17:17
The codegen/ module (live workspace -> Python define_* source) was
fully implemented and unit-tested but unreachable from any CLI
command. Add an --as-code flag to `tinybird pull` that uses it to
emit datasources.py/pipes.py/client.py instead of raw
.datasource/.pipe/.connection files, and wire `pull` itself to the
CLI entry point (previously delegated to the upstream tb package).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Plain `tinybird pull` duplicated what the installed Tinybird CLI
already does, breaking the project's delegation policy. Only
`--as-code` has no CLI equivalent (it generates Python SDK source via
the codegen module instead of raw datafiles), so that's the only case
the SDK should own. Everything else, including bare `pull`, now goes
through the real CLI like every other non-SDK-owned command.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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