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
initwould 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
--helpfirst. - What
--forcedoes 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 readssamples.tpch.orders, which every workspace has, and gets aunitycatalog, a state table, an artifacts root on a volume and a serverlessdeployblock, 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-inputand--force. Prompts run only when stdin is a terminal and--no-inputis not given, and only for values the flags leave out. --forceallows a non-empty directory and never overwrites: an existing file is kept and listed on stdout as skipped. A directory that already holdspipeloom.ymlis refused even with--force.- A bad name, a bad engine,
--catalogwith an engine other than databricks, an existing project and a non-empty directory without--forceare click usage errors (exit 2). No diagnostic code is added:initreads no project. initwrites 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
deploydependencies 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
initwrites starts with a# yaml-language-server: $schema=<url>modeline:project.jsonforpipeloom.yml,defaults.jsonfor_defaults.ymlandmodels.jsonfor model files. The_defaults.ymltemplates lacked it. The URLs are the published schemas underSCHEMA_BASE_URL(pipeloom.config.schema); a test checks the templates against that constant. initwrites.vscode/settings.json, which mapsyaml.schemasto the three schemas by glob (pipeloom.yml,models/**/_defaults.yml, andmodels/**/*.ymlminus_defaults, with.yamlvariants), and.vscode/extensions.json, which recommendsredhat.vscode-yaml. Completion then works with only the YAML extension.--forcekeeps 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>.ymlwith themodels.jsonmodeline and one block-style entry. SQL gets aselect 1 as idbody; Python getspython: <project>_models.<name>:buildand a stub<python_paths[0]>/<project>_models/<name>.pywithdef build(ctx: Any, **inputs: Any) -> Any, which satisfies PLK602 for any alias. Both carry a commentedinputs:example. The package__init__.pyis 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,
--sqlwith--python, a--folderoutside the model path and a Python model withoutpython_pathsinpipeloom.ymlare 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
--refor--inputflag to declare inputs: left out to keep the roadmap's interface. A commentedinputs: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
.vscodetemplates ship in the wheel with the other templates. - New files stay valid by construction: tests run
validateon 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¶
ENGINESgainsduckdb: layerscommon,local,sql,duckdb. The template reads the same CSV, writes the same three SQL models, and targets theduckdbengine and catalog (target/warehouse.duckdb) with no extension. Itsmodels/silver/_properties.ymladds one unit test fororders_clean, sopipeloom buildhas a unit test, three models and data tests to run. The default engine ofinitstays polars: only a new major version may change a default.pipeloom demo [DIRECTORY]renders that template into DIRECTORY (defaultpipeloom_demo), then runsbuildanddocs generatein process through the CLI commands overpipeloom.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 demoon Linux, macOS and Windows, then checkstarget/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
duckdbextra and the one-line install hint carry the same ease. --forceondemo: left out; use a new folder.
Consequences¶
uvx --from "pipeloom[duckdb]" pipeloom demois 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¶
initalso writesAGENTS.mdand three skills under.agents/skills/:pipeloom-fix-diagnostic,pipeloom-read-run-resultsandpipeloom-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.CATALOGwith 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 holdspipeloom.yml(default: the current directory) and nothing else. It refuses every other option except--log-format, and a directory withoutpipeloom.ymlis a usage error (exit 2).initandexplainaccept--log-format, like every other command.
Options considered¶
.claude/skills/: rejected as the default. One tool reads it.AGENTS.mdis a plain Markdown convention several coding agents read, and.agents/skills/<name>/SKILL.mdkeeps the Agent Skills layout (a folder per skill, aSKILL.mdwithnameanddescriptionfront 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-agentsrefreshes 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.