Skip to content

ADR-0041: pipeloom init

Architecture: Section 3, Architecture overview

Context

A new user starts from an empty folder and has to write pipeloom.yml, a target, a catalog, a state store and the model files by hand, copying from the quickstart or the TPC-H examples. dbt solves the same problem with dbt init, which asks a few questions and writes a working project. pipeloom has no such command, and the CLI list in the architecture does not include one.

Options

  • Where the templates live.
  • Inside the core package, pipeloom/scaffold/templates/, shipped in the wheel. Nothing to download, and the version of the templates always matches the installed core.
  • In each engine plugin, through a new entry-point group. Each plugin owns its template, but init would have to import a plugin before the user picked an engine, and a new group changes the plugin API.
  • A remote template repository (cookiecutter style). Flexible, but it needs network access and a new dependency.
  • How the user picks values.
  • Flags plus click prompts for what the flags leave out, prompting only when stdin is a terminal.
  • Flags only. Scriptable, but a first-time user has to read --help first.
  • What --force does with existing files.
  • Keep every existing file and report it as skipped.
  • Overwrite. Fast to retry, but it can destroy user work without a warning.

Decision

  • pipeloom init [DIRECTORY] writes a project from templates inside the core package. The templates are plain text files with {{key}} placeholders, rendered with string replacement. The core imports no engine to do it.
  • Each engine is a stack of template folders (common, local, sql, then the engine's own folder); a later folder's file replaces an earlier one with the same path. polars, spark and databricks get SQL models; pandas gets Python models, because pandas has no SQL (PLC502).
  • polars, pandas and spark read a six-row CSV written into data/, so the project runs with no download. databricks reads samples.tpch.orders, which every workspace has, and gets a unity catalog, a state table, an artifacts root on a volume and a serverless deploy block, with comments that say what must exist before the first deploy.
  • Every layer writes to its own schema (bronze, silver, gold) through the folder _defaults.yml, not its own catalog, so local Spark needs no extra catalog configuration.
  • The generated YAML is block style; only short scalar lists such as tags: [bronze] stay inline.
  • Flags --name, --engine, --catalog, --no-input and --force. Prompts run only when stdin is a terminal and --no-input is not given, and only for values the flags leave out.
  • --force allows a non-empty directory and never overwrites: an existing file is kept and listed on stdout as skipped. A directory that already holds pipeloom.yml is refused even with --force.
  • A bad name, a bad engine, --catalog with an engine other than databricks, an existing project and a non-empty directory without --force are click usage errors (exit 2). No diagnostic code is added: init reads no project.
  • init writes no event stream: there is no project, target or sink configuration to send events to.

Consequences

  • Templates ship with the core and change with it. A template that stops validating is caught by the tests, which validate and run (polars, pandas) or validate and compile (spark, databricks) every generated project.
  • The databricks template pins the deploy dependencies to the installed pipeloom version.
  • A plugin cannot add its own template yet. When one needs to, an entry-point group can be added then.

Status

Accepted. Amended in 0.8 (editor setup, pipeloom new model), in 0.9 by ADR-0050, in 1.1 (duckdb template, pipeloom demo) and in 1.2 (agent files).

Amendment (0.8): editor setup and pipeloom new model

What changed

  • Every YAML file init writes starts with a # yaml-language-server: $schema=<url> modeline: project.json for pipeloom.yml, defaults.json for _defaults.yml and models.json for model files. The _defaults.yml templates lacked it. The URLs are the published schemas under SCHEMA_BASE_URL (pipeloom.config.schema); a test checks the templates against that constant.
  • init writes .vscode/settings.json, which maps yaml.schemas to the three schemas by glob (pipeloom.yml, models/**/_defaults.yml, and models/**/*.yml minus _defaults, with .yaml variants), and .vscode/extensions.json, which recommends redhat.vscode-yaml. Completion then works with only the YAML extension. --force keeps existing files as before.
  • pipeloom new model NAME [--sql|--python] [--folder PATH] adds one model file to a project. It loads the project (load stage only), so it knows the project name, python_paths, the existing model names and the engine kind of the default target. The default kind is Python when that engine is pandas (no SQL, PLC502), SQL otherwise; a flag wins.
  • It writes <first model path>/<folder>/<name>.yml with the models.json modeline and one block-style entry. SQL gets a select 1 as id body; Python gets python: <project>_models.<name>:build and a stub <python_paths[0]>/<project>_models/<name>.py with def build(ctx: Any, **inputs: Any) -> Any, which satisfies PLK602 for any alias. Both carry a commented inputs: example. The package __init__.py is created when missing.
  • It prints the written paths on stdout and writes no events. A project that does not load exits 1 with its diagnostics. A bad name, a name or file that already exists, --sql with --python, a --folder outside the model path and a Python model without python_paths in pipeloom.yml are usage errors (exit 2). No diagnostic code is added.

Options considered

  • Append the model to an existing file: rejected. Rewriting YAML drops comments, and keeping them needs a round-trip YAML dependency. One file per model was chosen.
  • A --ref or --input flag to declare inputs: left out to keep the roadmap's interface. A commented inputs: example shows the shape.
  • A template engine or generator framework: a few inline scaffold strings are enough.

Consequences

  • Authors get completion and validation squiggles in VS Code without installing a pipeloom extension. The schemas come from the published docs site, so completion needs network access the first time.
  • The .vscode templates ship in the wheel with the other templates.
  • New files stay valid by construction: tests run validate on generated models for polars and pandas and check every generated YAML against the exported JSON Schemas.

Amendment 0.9 (ADR-0050)

With Python-first authoring (ADR-0050) pipeloom new model NAME [--sql|--python] [--folder PATH] writes one file, models/<folder>/<name>.py, with a decorated function and no YAML entry. With --sql the body returns ctx.sql("select 1 as id"); with --python it returns a frame stub. The default stays --python on pandas and --sql otherwise. The usage error for a Python model without python_paths goes away, because python_paths defaults to ["."]. init writes one .py model per layer, a models: tree in pipeloom.yml instead of _defaults.yml, and models/silver/_properties.yml; .vscode/settings.json maps project.json to pipeloom.yml and properties.json to models/**/*.yml, and the defaults.json and models.json globs go away. These templates change with the examples, after the discovery and resolve changes of ADR-0050. As built, the --python stub raises NotImplementedError, because the frame type depends on the engine; the name check also counts decorated models; and a Python keyword or ctx, model or ModelContext as NAME is a usage error, since NAME becomes the function name.

Amendment 1.1: the duckdb template and pipeloom demo

What changed

  • ENGINES gains duckdb: layers common, local, sql, duckdb. The template reads the same CSV, writes the same three SQL models, and targets the duckdb engine and catalog (target/warehouse.duckdb) with no extension. Its models/silver/_properties.yml adds one unit test for orders_clean, so pipeloom build has a unit test, three models and data tests to run. The default engine of init stays polars: only a new major version may change a default.
  • pipeloom demo [DIRECTORY] renders that template into DIRECTORY (default pipeloom_demo), then runs build and docs generate in process through the CLI commands over pipeloom.api, so events and diagnostics reach stderr as they do for those commands. It prints the project path, the site path (target/docs/index.html) and the next commands, and exits 0. A DIRECTORY that exists and is not empty is a usage error (exit 2) and nothing is written. There is no --force: a demo never mixes with user files.
  • The demo requires the duckdb engine and never falls back to another installed engine. Without it, the command stops before writing anything with PLU004 (exit 1) whose hint is pip install "pipeloom[duckdb]". The message lists the engine plugins that were found, so an environment with only polars sees why the demo did not run. The check reads entry-point metadata only (the core imports no plugin).
  • PLU004 is in the plugin layer, active since 1.1, with a case file and goldens.
  • CI installs the built core and pipeloom-duckdb wheels into a fresh venv and runs pipeloom demo on Linux, macOS and Windows, then checks target/docs/index.html.

Options considered

  • Fall back to polars or any installed engine: rejected. The output would depend on the machine, the sample would need one template per engine kept passing, and the CI check could pass on an engine nobody meant to demo.
  • Bundle DuckDB in the core dependencies: rejected. The core keeps no engine dependency; the duckdb extra and the one-line install hint carry the same ease.
  • --force on demo: left out; use a new folder.

Consequences

  • uvx --from "pipeloom[duckdb]" pipeloom demo is the whole first run. A user with only the core gets one clear error instead of a validate failure about an unknown engine kind.
  • The duckdb template is covered by the same layout and YAML-style tests as the others, plus a build test.

Amendment 1.2: agent files

What changed

  • init also writes AGENTS.md and three skills under .agents/skills/: pipeloom-fix-diagnostic, pipeloom-read-run-results and pipeloom-add-model. As with every template file, an existing file is kept and listed as skipped.
  • The text is generated from the code, not fetched and not hand-copied: the command list comes from the Click command tree, and the fix-diagnostic skill lists every code of pipeloom.diagnostics.codes.CATALOG with its severity and title. A test fails when a catalog code is missing from the skills and when a command is missing from AGENTS.md. Each file starts with a comment that names the pipeloom version that wrote it.
  • pipeloom init --update-agents [DIRECTORY] rewrites exactly those files in a project that holds pipeloom.yml (default: the current directory) and nothing else. It refuses every other option except --log-format, and a directory without pipeloom.yml is a usage error (exit 2).
  • init and explain accept --log-format, like every other command.

Options considered

  • .claude/skills/: rejected as the default. One tool reads it. AGENTS.md is a plain Markdown convention several coding agents read, and .agents/skills/<name>/SKILL.md keeps the Agent Skills layout (a folder per skill, a SKILL.md with name and description front matter) in a tool-neutral folder. A user of a tool that wants another folder can symlink or copy it.
  • Fetching the latest skills from a remote source: rejected. Content must match the installed version, and the command works offline.
  • A hand-written error list in the skills: rejected. It drifts; the catalog is the source.

Consequences

  • Agents get the commands, the layout, how to read diagnostics and run results, and the full code list for the installed version. After an upgrade, init --update-agents refreshes them.
  • The catalog table makes the fix-diagnostic skill the largest generated file (about 7 KB).

Provenance: clean room. The layout follows the public AGENTS.md and Agent Skills conventions as the author knows them; no code from other projects was used.