Repository navigation
feat: leave example queries and test out with skipExamples (LA-2388) - #734
atilafassina wants to merge 4 commits into
Conversation
The smoke test stripped `{{if .plugins.X}}` blocks with a regex, which
cannot follow `and`/`not`, `else` branches or nesting, ignored trim
markers and skipped `.sql` files. Add a small renderer for `if` chains
on `.plugins`, `.appEnv` and `.skipExamples` that leaves every other
action verbatim, and use it in the smoke test, with a `--skip-examples`
flag to scaffold the way the Builder will.
Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Atila Fassina <atila@fassina.eu>
The Builder deletes `config/queries/hello_world.sql`, `config/queries/mocked_sales.sql` and `server/example.test.ts` in nearly every run, and the test failed the template's own lint config first (LA-2388). Gate them on a new `.skipExamples` template variable, set by `databricks apps init --skip-examples` (CLI change pending). The check is `not .skipExamples`, so CLIs without the flag and every other user keep the files. With the flag, the Analytics page renders a query-free placeholder instead of reading the example queries. - Fix the example test's `require-await` errors so it passes the template lint config - Document queries and the testing kit in the template README - Render the example test before CI runs the raw template's tests - Add template tests for both modes Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Atila Fassina <atila@fassina.eu>
🤖 AppKit PR bot🔬 Run evalsStart an eval for this PR from the evals-monitor app: Go to Evals Monitor → 📦 Try this PR's app templateScaffolds a new app from this PR's SDK build. Run it in any folder (requires the GitHub CLI — gh run download 43318825916 -R databricks/appkit -n appkit-template-0.94.1-pr.45f1c6d-work-16-drop-placeholder-queries-and-t-734 -D appkit-pr-734 \
&& unzip -o "appkit-pr-734/appkit-template-0.94.1-pr.45f1c6d-work-16-drop-placeholder-queries-and-t-734.zip" -d "appkit-pr-734" \
&& databricks apps init --template "appkit-pr-734"The template pins |
…pegen The analytics `should` rule asked agents to make sure config/queries/ has a .sql file before typegen. With `apps init --skip-examples` the folder is gone on purpose, and typegen, build and the server all work without it, so the rule would send the Builder back to create a placeholder. Say to add queries only for what the app runs. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Atila Fassina <atila@fassina.eu>
📦 Bundle size reportCompared against
|
| dist | raw | gzip |
|---|---|---|
| JS (runtime) | 1.3 MB (-168 B) | 479 KB (-1 B) |
| Type declarations | 470 KB | 169 KB |
| Source maps | 2.6 MB (-47 B) | 889 KB (-29 B) |
| Other | 11 KB | 3.7 KB |
| Total | 4.4 MB (-215 B) | 1.5 MB (-30 B) |
Per-entry composition (own code — deps external (as shipped))
| Entry | Initial (gz) | Lazy (gz) | Total (gz) | node_modules (min) | Own code (min) |
|---|---|---|---|---|---|
. |
108 KB (+15 B) | 2.5 KB (+1 B) | 110 KB (+16 B) | external | 348 KB (+14 B) |
./beta |
113 KB | 486 B | 114 KB | external | 339 KB |
./testing |
46 KB | 33 KB (-3 B) | 79 KB (-3 B) | external | 229 KB |
./tsdown |
520 B | 0 B | 520 B | external | 813 B |
./type-generator |
26 KB | 0 B | 26 KB | external | 74 KB |
Chunks:
| Entry | Chunk | Load | Size (gz) |
|---|---|---|---|
. |
index.js |
initial | 103 KB |
. |
utils.js |
initial | 4.6 KB |
. |
remote-tunnel-manager.js |
lazy | 2.5 KB |
./beta |
beta.js |
initial | 93 KB |
./beta |
modular.js |
initial | 6.0 KB |
./beta |
stream-manager.js |
initial | 5.9 KB |
./beta |
service-context.js |
initial | 4.3 KB |
./beta |
databricks.js |
initial | 3.3 KB |
./beta |
client.js |
initial | 648 B |
./beta |
index.js |
initial | 20 B |
./beta |
supervisor-api.js |
lazy | 192 B |
./beta |
databricks.js |
lazy | 179 B |
./beta |
index.js |
lazy | 115 B |
./testing |
manifest.js |
initial | 33 KB |
./testing |
index.js |
initial | 10 KB |
./testing |
wide-event-emitter.js |
initial | 2.9 KB |
./testing |
index.js |
lazy | 29 KB |
./testing |
remote-tunnel-manager.js |
lazy | 2.5 KB |
./testing |
utils.js |
lazy | 1.8 KB |
./tsdown |
index.js |
initial | 520 B |
./type-generator |
index.js |
initial | 26 KB |
@databricks/appkit-ui
npm tarball (packed): 406 KB — gzipped download (dist + bin; excludes release-only docs/NOTICE).
| dist | raw | gzip |
|---|---|---|
| JS (runtime) | 436 KB | 150 KB |
| Type declarations | 271 KB | 100 KB |
| Source maps | 862 KB | 291 KB |
| CSS | 16 KB | 3.2 KB |
| Total | 1.5 MB | 544 KB |
Per-entry composition (consumer bundle — deps bundled, peerDeps external)
| Entry | Initial (gz) | Lazy (gz) | Total (gz) | node_modules (min) | Own code (min) |
|---|---|---|---|---|---|
./js |
5.3 KB | 49 KB | 55 KB | 208 KB | 14 KB |
./js/beta |
2.1 KB | 0 B | 2.1 KB | 0 B | 5.0 KB |
./react |
440 KB | 49 KB | 489 KB | 1.4 MB | 178 KB |
./react/beta |
14 KB | 0 B | 14 KB | 25 KB | 16 KB |
Chunks:
| Entry | Chunk | Load | Size (gz) |
|---|---|---|---|
./js |
index.js |
initial | 5.2 KB |
./js |
chunk |
initial | 120 B |
./js |
apache-arrow |
lazy | 49 KB |
./js/beta |
beta.js |
initial | 2.1 KB |
./react |
index.js |
initial | 438 KB |
./react |
tslib |
initial | 2.1 KB |
./react |
apache-arrow |
lazy | 49 KB |
./react/beta |
beta.js |
initial | 14 KB |
No released Databricks CLI has `apps init --skip-examples` yet. Describe `.skipExamples` by what it does, note that the CLI flag is planned and that the variable is unset until then, and drop the flag from the comment in the scaffolded example test and from internal comments. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Atila Fassina <atila@fassina.eu>
calvarjorge
left a comment
There was a problem hiding this comment.
LGTM. A missing skipExamples is falsy in the CLI (missingkey=zero), so older CLIs keep the examples. template-render.ts output matches Go's text/template byte for byte on every template file, in default, skip and no-plugins mode.
| } as PluginManifest<'greeter'>; | ||
|
|
||
| async setup() { | ||
| setup() { |
There was a problem hiding this comment.
#733 makes the same require-await fix here. Keep it in one of the two PRs, or whichever lands second conflicts on this file.
| export function AnalyticsPage() { | ||
| return ( | ||
| <div className="w-full max-w-7xl mx-auto"> | ||
| <Card className="shadow-lg"> |
There was a problem hiding this comment.
#653 removes shadow-lg from the other Analytics cards. Whichever of the two lands second should drop it here too, so the placeholder matches.
|
Review 6 · Pass Does the change do what the task asked? Yes. Gate: major and worse must be fixed. The AppKit template change meets the requested opt-in behavior: Builder mode omits the placeholder queries and test, while the default mode keeps the demo. The rendered empty Analytics page, template tests, lint, typecheck, and a Builder-style client build passed; the PR documents the required CLI and Builder follow-up. No findings. |
What
Lets the Builder scaffold without the starter files it deletes on nearly every run (LA-2388):
config/queries/hello_world.sqlconfig/queries/mocked_sales.sqlserver/example.test.tsIn the NFL-Scout evals (51 trajectories), both queries were deleted in virtually every run.
example.test.tswas deleted in 22 runs and caused lint errors in 8.Approach: an opt-in template variable, default unchanged
The files are gated on a new
.skipExamplestemplate variable, whichdatabricks apps init --skip-examplessets (CLI change below). I picked an opt-in flag over removing the files for everyone:apps init --features analyticsby hand still get a working Analytics page with charts. That demo needs both queries.not .skipExamples. A CLI without the flag leaves the key out, which Go reads as false, so older CLIs and every other user keep exactly what they get today.With
skipExamples:config/queries/once that folder is empty.AnalyticsPage.tsxbecomes a page that reads no queries and says to add one underconfig/queries/. The app builds and runs with no queries dir. Analytics and typegen both already handle a missing folder..obo.sql,-- @param,useAnalyticsQuery/charts, typegen) and a Testing section (createTestApp,createTestPluginContext,expectStream). These sections render in both modes.Other changes
typescript/require-awaiterrors:async setup(),async *greetand the route handler. I couldn't reproduceno-empty-object-typeon HEAD.tools/template-render.tsis a small renderer for Go-templateif/else if/elsechains on.plugins,.appEnvand.skipExamples, with trim markers. Every other action is left as-is. It replaces the smoke test's regex stripper, which couldn't handleand/not,elseor nesting. The smoke test gets a--skip-examplesflag.npm teststep now rendersexample.test.tsfirst, since the file now starts with{{if not .skipExamples -}}. The step moved to after the zip (the artifact has to keep the conditional) and before the upload (a broken example still fails the job).shouldrule used to tell agents to make sureconfig/queries/has a.sqlfile before typegen. It now says to add queries only for what the app runs, because typegen and build work without the folder (packages/appkit/src/plugins/analytics/manifest.json, synced totemplate/appkit.plugins.json)..skipExamplesadded to the template-variables table indocs/development/templates.md.Outside this repo
Databricks CLI (
cmd/apps/init.go)Add a
--skip-examplesbool flag and pass it to the template asskipExamples. This is the whole change. I built it and tested it against this template:Suggested CLI test: an
executeTemplatecase showing that{{if not .skipExamples}}x{{end}}rendersxwithout the flag and nothing with it.Builder (universe)
--skip-examplesto the Builder'sdatabricks apps initcall. On a CLI without the flag, init fails with "unknown flag", so put this behind the CLI version floor.--skip-examplestoscaffolding.flagsin the template manifest so scaffolding agents find it. I left it out on purpose, because agents on older CLIs would pass a flag those CLIs reject. That can wait untilcli-compat.jsonpins this template to CLIs that have the flag.Testing
tools/template-render.test.tshas 11 tests: renderer semantics (trim markers,not/and/or, else-if chains, unsupported actions kept as-is, unbalanced blocks), plus template-level checks. Every template file is rendered with all plugins, with and withoutskipExamples. The checks: the gated files are present or absent as expected, no rendered file mentionshello_world/mocked_salesin builder mode, and the gated files have no leftover template syntax.--skip-examples: install, build, lint fixtures, HTTP start. With no plugins, the renderer's output matches the old regex stripper except for trim-marker whitespace, and the analytics-gated.sqlfiles are now dropped, as the CLI already did.databricks apps init --template ./template --features analytics,serverwith and without--skip-examples:config/queries/and noserver/example.test.ts.oxlint,tsc -b,build:serverandbuild:clientall pass./,/analyticsand/healthagainst a fake workspace. An unknown query gets a clean 404.App.tsx,tools/template-render.tsproduces byte-identical output to the real CLI in both modes.pnpm check, thetoolstest project,pnpm buildandpnpm docs:buildall pass.Also noticed (not changed here)
AnalyticsPage.tsxonly typechecks and lints once typegen has run against a warehouse. Without generated types,data[0].valueisunknown. This was already the case before this PR. Builder mode avoids it.This pull request and its description were written by Isaac.