Skip to content

Wire up SDK-owned init command with --folder support#12

Merged
rmorehig merged 7 commits intomainfrom
wire-sdk-init-command
Mar 26, 2026
Merged

Wire up SDK-owned init command with --folder support#12
rmorehig merged 7 commits intomainfrom
wire-sdk-init-command

Conversation

@gnzjgo
Copy link
Copy Markdown
Member

@gnzjgo gnzjgo commented Mar 25, 2026

Summary

tinybird init was delegating to the tinybird CLI package, which only creates config/CI files but no Python SDK template files. The src/tinybird/ folder was left empty.

This PR wires up the SDK's own run_init (which already had templates) in the CLI dispatcher, so tinybird init now scaffolds a working Python project.

Usage

# With custom folder
tinybird init --folder src/tinybird --skip-login

# Default (lib/ or src/lib/ depending on project structure)
tinybird init --skip-login

Files created

File Content
tinybird.config.json Config with include paths, token, base_url
<folder>/datasources.py Sample page_views datasource
<folder>/pipes.py Sample top_pages endpoint
<folder>/client.py Tinybird client wiring

Changes

  • Add init to SDK-owned commands (no longer delegated to tinybird CLI)
  • Add --folder flag to customize template output directory
  • Support --force, --skip-login, --dev-mode flags
  • Bump version to 0.1.5

Testing

All 100 existing tests pass. Manually verified:

  • tinybird init --folder src/tinybird --skip-login creates all 4 files
  • tinybird init --skip-login (no folder) uses default lib/ path
  • tinybird init --help shows correct usage

gnzjgo and others added 5 commits March 25, 2026 23:09
Instead of delegating 'tinybird init' to the tinybird CLI (which only
creates config/CI files), the SDK now handles it directly and scaffolds
Python template files (datasources.py, pipes.py, client.py).

- Add 'init' to SDK-owned commands in CLI dispatcher
- Support --folder to customize where templates are created
- Support --force, --skip-login, --dev-mode flags
- Bump version to 0.1.5

Amp-Thread-ID: https://ampcode.com/threads/T-019d1a2d-e5a7-77fb-b97e-e855f84a34a4
Co-authored-by: Amp <amp@ampcode.com>
- Run tinybird CLI init for the full interactive flow (dev mode,
  CI/CD templates, skills install, login)
- Then create a single tinybird_resources.py template with datasources,
  endpoints, and client all in one file
- Update tinybird.config.json include list with the resources file
- Update workflow test to mock the CLI delegation

Amp-Thread-ID: https://ampcode.com/threads/T-019d1a2d-e5a7-77fb-b97e-e855f84a34a4
Co-authored-by: Amp <amp@ampcode.com>
- Split tinybird_resources.py (definitions only) from client.py (Tinybird client)
- Generate main.py with dotenv loading, ingest, and query examples
- Import paths computed dynamically from --folder argument
- Existing files are not overwritten unless --force is used

Amp-Thread-ID: https://ampcode.com/threads/T-019d1a2d-e5a7-77fb-b97e-e855f84a34a4
Co-authored-by: Amp <amp@ampcode.com>
When the user doesn't pass --folder but types a folder name in the
tinybird CLI interactive prompt, read the include path from the
generated tinybird.config.json to place SDK files in the right folder.

Amp-Thread-ID: https://ampcode.com/threads/T-019d1a2d-e5a7-77fb-b97e-e855f84a34a4
Co-authored-by: Amp <amp@ampcode.com>
@gnzjgo gnzjgo requested review from juliavallina and rmorehig March 25, 2026 23:03
@gnzjgo
Copy link
Copy Markdown
Member Author

gnzjgo commented Mar 25, 2026

how to test:

mkdir pyinit && cd pyinit && git init && git checkout -b tinybird_intro && uv init --name tinybird-sdk-python-samplee --python 3.13 && uv add git+https://github.com/tinybirdco/tinybird-sdk-python.git@wire-sdk-init-command && uv run tinybird init && uv run tinybird build && uv run tinybird --cloud open

@rmorehig rmorehig merged commit ede2035 into main Mar 26, 2026
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