Repository navigation
[ON HOLD] feat(cli): enable lineage emission by default (opt out with --no-emit-lineage) - #2367
rafal-hawrylak wants to merge 5 commits into
Conversation
…-lineage) `dataform run` now emits OpenLineage events to Knowledge Catalog Lineage by default. Precedence is unchanged: --emit-lineage / --no-emit-lineage overrides workflow_settings.yaml `lineage.enabled`, which overrides the default. When lineage is on only because of the default, expected one-time skip notices (API not enabled, missing permission, dry-run, REP fallback) are printed only with DATAFORM_LINEAGE_DEBUG=1, so output is unchanged for users who never configured lineage. Unexpected emit failures are still reported. Emission stays fail-open and never changes the run result.
|
We're going to have it OFF by default for a while still and get back to it in a month or two. |
- Print `Failed to emit` lines only with DATAFORM_LINEAGE_DEBUG=1 when lineage is on only by default, like the skip notices. - Mention `--no-emit-lineage` in the invocation_override skip message. - Explain why `--emit-lineage` has no yargs default. - Move `withDebugEnv` into `cli/api/lineage/testing/debug_env.ts` and use it in the emitter and integration tests. - Order integration Case 7 after Case 6.
|
Should I review, even if this is ON HOLD? Let me know :) |
This is going to be merged in this shape anyway. So this is matter of "when" not "if" here. |
| const location = (e as any).lineageLocation || "unknown"; | ||
| this.stderr.write( | ||
| this.writeNotice( | ||
| `[lineage] Failed to emit lineage for action ${action.target.schema}.${action.target.name}: ` + |
There was a problem hiding this comment.
The PR description says "Unexpected Failed to emit errors are still printed", but this line now goes through writeNotice(), so it is hidden when enablementSource === "default" (and the hides the Failed to emit line for unexpected errors test locks that in). Which is intended? I'd lean toward keeping this one on this.stderr.write — genuinely unexpected errors (e.g. INVALID_ARGUMENT from a payload bug) would otherwise go unnoticed for the majority of users who just rely on the default. Either way, please align the description/README with the behavior.
There was a problem hiding this comment.
Compromise: first failure per run printed, rest debug-only.
| // Catalog for actions executed from this project. | ||
| // Catalog for actions executed from this project. When the `lineage` block | ||
| // is not set, runners emit lineage by default. | ||
| bool enabled = 1; |
There was a problem hiding this comment.
enabled is a proto3 scalar without presence, and core/workflow_settings.ts copies it whenever the lineage block exists (if (workflowSettings.lineage) projectConfig.lineageEnabled = workflowSettings.lineage.enabled;). With default-on, an empty lineage: {} block (or one that later only sets other sub-fields) now resolves to enabled=false and silently opts the project out with skip_reason=workflow_opt_out. Could we make this optional bool enabled = 1; and only propagate it when explicitly set? A test for the empty-block case would be good too.
There was a problem hiding this comment.
Checked: {} compiles to unset
| * line is shown only with DATAFORM_LINEAGE_DEBUG=1 to keep their output | ||
| * unchanged (for example in air-gapped CI or behind a proxy). | ||
| */ | ||
| private writeNotice(msg: string): void { |
There was a problem hiding this comment.
nit: this.debugEnabled is captured in the constructor, which is why withDebugEnv needs the "create the emitter inside fn" caveat. Fine as is, just noting it's easy to trip over — maybe mention it on the field too.
| @@ -8,6 +9,12 @@ import { dataform } from "df/protos/ts"; | |||
|
|
|||
| export interface IEmitterOptions { | |||
| lineageEnabled?: boolean; | |||
There was a problem hiding this comment.
nit: lineageEnabled is now always true whenever an emitter is constructed, so it's redundant next to enablementSource. Consider deprecating/removing it to avoid confusion.
There was a problem hiding this comment.
Marked deprecated - removal in follow-up
|
|
||
| suite("resolveLineageEnablement", () => { | ||
| test("lineage is enabled by default", () => { | ||
| expect(LINEAGE_ENABLED_BY_DEFAULT).to.equal(true); |
There was a problem hiding this comment.
nit: this test just restates the constant; the table cases below (cli=undefined yaml=undefined → enabled=true) already pin the default behavior. Could be dropped.
| | `--job-prefix` | string | — | Adds an additional prefix to BigQuery job IDs, in the form `dataform-${jobPrefix}-`. | | ||
| | `--job-labels` | string | — | Comma-separated `key=value` labels to attach to BigQuery jobs, e.g. `'key1=val1,key2=val2'`. | | ||
| | `--emit-lineage` | boolean | — | Emits OpenLineage `RunEvent`s to Knowledge Catalog Lineage for each executed action. Overrides the `lineage.enabled` setting in `workflow_settings.yaml` when specified. | | ||
| | `--emit-lineage` | boolean | `true` | Emits OpenLineage `RunEvent`s to Knowledge Catalog Lineage for each executed action. Enabled by default; pass `--no-emit-lineage` (or set `lineage.enabled: false` in `workflow_settings.yaml`) to disable. Overrides the `lineage.enabled` setting in `workflow_settings.yaml` when specified. | |
There was a problem hiding this comment.
nit: the Default column says true, but the yargs option intentionally has no default (see comment in run_options.ts) so that workflow_settings.yaml can apply. Maybe "unset (lineage on by default)" to avoid implying the flag overrides the YAML when omitted.
|
|
||
| suite("--emit-lineage integration", { parallel: true }, () => { | ||
| test("Case 1 — CLI flag alone enables emission (2*N recorder calls, pairing invariant)", async () => { | ||
| test("CLI flag alone enables emission (2*N recorder calls, pairing invariant)", async () => { |
There was a problem hiding this comment.
nit: dropping the "Case N —" prefixes is unrelated cleanup — fine, but could live in a separate commit to keep this diff focused.
There was a problem hiding this comment.
Done after your earlier suggestion
…eage - When lineage is on only by default, print the first unexpected `Failed to emit` line of a run (with a DATAFORM_LINEAGE_DEBUG hint) instead of hiding all of them; later failures still need DATAFORM_LINEAGE_DEBUG=1. - Note on `debugEnabled` that DATAFORM_LINEAGE_DEBUG is read in the constructor. - Deprecate the unused `IEmitterOptions.lineageEnabled`. - Drop the enablement test that only restated the constant. - README: the `--emit-lineage` default is "unset (lineage on by default)".
…ult-on # Conflicts: # cli/api/lineage/emitter.ts # cli/api/lineage/lineage_integration_test.ts
Summary
dataform runnow emits OpenLineage events to Knowledge Catalog Lineage by default. Previously lineage was opt-in (--emit-lineageorlineage.enabled: trueinworkflow_settings.yaml).Precedence is unchanged:
--emit-lineage/--no-emit-lineage(per invocation)workflow_settings.yaml→lineage.enabled(per project)Changes
cli/api/lineage/enablement.ts(new):resolveLineageEnablement()returns the effective setting and which surface decided it (cli_flag/workflow_settings/default).LINEAGE_ENABLED_BY_DEFAULT = true.cli/api/lineage/emitter_factory.ts: uses the resolver instead of?? falseand passes the source to the emitter. Explicit opt-outs still printskip_reason=invocation_override/skip_reason=workflow_opt_out.cli/api/lineage/emitter.ts: when lineage is on only by default, expected one-time notices (api_disabled,unauthenticated,endpoint_region_mismatch,dry_run, REP→global fallback) are printed only withDATAFORM_LINEAGE_DEBUG=1, so output is unchanged for users who never configured lineage. UnexpectedFailed to emiterrors are still surfaced: the first one in a run is printed (with a hint to setDATAFORM_LINEAGE_DEBUG=1), later ones only in debug mode. With an explicit opt-in (flag or yaml), all notices and failures are printed as before. Emission stays fail-open.cli/commands/run_options.ts,cli/README.md,protos/configs.proto: document the new default and--no-emit-lineage.Testing
enablement_test.ts(all 9 flag × yaml combinations); new/updated cases inemitter_test.ts,emitter_factory_test.ts,lineage_integration_test.ts(default-on emits; default-on skip is silent and fail-open; only the first default-mode emit failure per run is printed)../scripts/run_tests: 65/65 pass../scripts/run_integration_tests: 19/19 pass (incl.index_run_e2e_testand JiT e2e suites)../scripts/lintclean.lineage:block, no flag (Lineage API on, permitted)--no-emit-lineageskip_reason=invocation_overridelineage.enabled: falseskip_reason=workflow_opt_outlineage.enabled: false+--emit-lineageskip_reason=api_disabled)--emit-lineage, Lineage API not enabledskip_reason=api_disabledskip_reason=api_disabled)--dry-run(default /--emit-lineage)skip_reason=dry_run