Skip to content

Add Spark based pipeline module - #299

Merged
em3s merged 16 commits into
mainfrom
feature/pipeline-module
May 6, 2026
Merged

em3s merged 16 commits into
mainfrom
feature/pipeline-module

Conversation

@em3s

@em3s em3s commented May 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds a new pipeline/ Gradle module: Spark application base, cascading config loader, and a per-field debug printer. Establishes the framework foundation; concrete pipelines follow in subsequent PRs.

Builds on #300 (Spotless for Scala) so .scala sources land already on the formatting baseline. Secret masking in ConfigPrinter is intentionally deferred to a follow-up to keep this PR focused.

Closes #

Changes

  • AbstractPipelineApplication[T] — Spark app base; owns the SparkSession lifecycle. Subclasses override run and optionally configure(builder) (e.g. enableHiveSupport()).
  • ConfigSource — EnvSource (SPARK_AB_*), PropsSource (spark.ab.*), ArgsSource(args) (--key=value); composed in low → high precedence order.
  • ConfigLoader.load[T] — merges sources and parses into T with strict primitive handling (missing required primitive throws).
  • ConfigPrinter.printConfigReport — per-field source attribution + final YAML dump.
  • SparkPiDemo — framework smoke example (Pi estimation).
  • ConfigLoaderTest — defaults, source overrides, array literal parsing, strict failure cases.

How to Test

./gradlew :pipeline:test

AI Assistance

  • This PR was written largely with AI assistance.
    • Tool / model: Claude Code (Opus 4.7, 1M context)

em3s and others added 2 commits May 4, 2026 17:47
- AbstractPipelineApplication[T]: Spark app base, manages session lifecycle
- ConfigLoader: cascading config from env (SPARK_AB_*) / props (spark.ab.*) / CLI args
- ConfigPrinter: per-field debug report with source attribution + final YAML

Args > props > env > defaults precedence. Strict JSON mapper throws on
missing required primitives at parse time.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Pi estimation extending AbstractPipelineApplication[SparkPiConfig].
Replaces EdgeCodec sample as the canonical demo.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@em3s em3s changed the title Add pipeline module with Spark base and config loader Add Spark based pipeline module May 4, 2026
em3s and others added 12 commits May 5, 2026 00:18
- Switch CLI args to --key=value form; reject malformed input
  (no --, missing =) instead of silently dropping odd-parity args.
- Parse empty array literal [] as an empty array (was [""]).
- splitTopLevelCommas: preserve commas inside double quotes and
  support backslash-escaped commas (\,).
- Mask sensitive fields (password/passwd/secret/token/credential)
  in both the per-field report and the YAML dump.
- Wrap System.setProperty in tests with try/finally; add coverage
  for empty array, escaped commas, and rejected arg forms.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
- Drop empty/whitespace tokens during array literal parse so
  trailing commas (e.g. [1,2,3,]) no longer surface as empty elements.
- Document splitTopLevelCommas escape semantics (\X yields literal X).
- Document SensitivePattern policy and the per-field/YAML scope split
  in printConfigReport.
- Expose ConfigPrinter.isSensitive and maskedTree as private[util]
  so masking can be unit-tested without stdout capture.
- Add ConfigPrinterTest covering name matching, top-level masking,
  nested masking, and end-to-end stdout masking.
- Simplify testRejectArgWithoutEquals to a single-arg case and add
  testTrailingCommaIgnored.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
- Collapse testRejectArgWithoutEquals + testRejectArgWithoutDashes
  into testRejectMalformedArg, with --=value added as a third case.
- Collapse testEmptyArray + testTrailingCommaIgnored into
  testIntArrayParsing, with two more shape cases ([1,2,3] and
  [ , 1 , 2 ]) included for free. Pipe delimiter is used so commas
  inside the array literal stay intact.
- Other cases (testReplaceBoolean, testReplaceArrayInt,
  testStringArrayWithEscapedComma, testAllMissing*, testOnlyDefault)
  stay on @test — heterogeneous types or System.setProperty
  branches make CsvSource a poor fit.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Each row now states its intent (baseline, trailing comma, dropped
tokens, etc.) and a note flags the null-on-empty-cell CsvSource
behavior that the guard relies on.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
- Move log4j-no-stdout.properties from src/main/resources to conf/
  so it stops being bundled in the published jar. Pipelines that need
  it should pass it via spark-submit --files or -Dlog4j.configuration.
- ConfigLoader.load now takes printReport (default true), letting unit
  tests and batch tools opt out of the per-field stdout report.
- AbstractPipelineApplication exposes hiveSupport and configureSparkBuilder
  hooks so subclasses can opt out of Hive or attach extra Spark config
  without rebuilding main().

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
When configureSparkBuilder is overridden, hiveSupport is silently
ignored unless the override delegates to super. Make that contract
explicit in KDoc and show the canonical super-delegation pattern.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
- AbstractPipelineApplication: drop the unused hiveSupport /
  configureSparkBuilder extension points and inline enableHiveSupport().
  The indirection had no callers and obscured the simple default.
- ConfigLoader: extract ConfigSource trait with EnvSource, PropsSource,
  and ArgsSource. load() now composes them via
  Seq(env, props, args).reduce(_ ++ _) so precedence (low -> high) is
  visible at the call site and adding a new source is local.
- ConfigPrinter: take Seq[(name, map)] instead of fixed env/props/args
  arguments, so new sources flow into the per-field trace and origin
  resolution without a signature change.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Pipelines opt in to whatever they need (Hive, shuffle partitions, etc.)
by overriding `configure(builder: SparkSession.Builder)`. Default is a
no-op so applications that don't need Hive (e.g. SparkPiDemo) don't pay
for the metastore connection.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
- Move ConfigSource trait and Env/Props/Args implementations into their
  own file; ConfigLoader now only owns merge + JSON parsing.
- AbstractPipelineApplication: keep main at the top of the class, define
  the abstract `run` and overridable `configure` at the bottom, and mark
  both as `protected` so they read as subclass extension points rather
  than public API.
- SparkPiDemo: align with parent visibility via `protected override`.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
`run` and `configure` are subclass extension points but the protected
modifier added clutter without changing how callers (only `main` in the
same class) use them. Match the surrounding style and let subclasses
override without restating visibility.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Group the trait and its companion at the top of the file, leaving the
three implementations (Env, Props, Args) below. Reads in declaration
order without jumping past the implementations to find `camelize`.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Reduce the PR surface so masking can land in a focused follow-up.

- Remove SensitivePattern, Mask, isSensitive, maskValue, maskedTree
  and maskInPlace from ConfigPrinter; the per-field report and YAML
  dump now show raw values.
- Delete ConfigPrinterTest, which existed solely for masking coverage
  (name matching, top-level/nested masking, stdout masking).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@em3s
em3s force-pushed the feature/pipeline-module branch from 8fa3ff1 to c2a3790 Compare May 6, 2026 03:02
@em3s em3s mentioned this pull request May 6, 2026
1 task done
em3s and others added 2 commits May 6, 2026 13:14
Now that #300 enabled the Spotless Scala step on main, run
spotlessApply across the pipeline module so its sources land on the
shared baseline.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@em3s
em3s marked this pull request as ready for review May 6, 2026 04:15
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels May 6, 2026
@em3s
em3s merged commit da2f0a3 into main May 6, 2026
3 checks passed
@em3s
em3s deleted the feature/pipeline-module branch May 6, 2026 04:24
@em3s em3s self-assigned this May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant