Skip to content

Add workflow DSL skeleton for pipeline jobs - #311

Closed
em3s wants to merge 1 commit into
mainfrom
feat/pipeline-workflow-dsl
Closed

em3s wants to merge 1 commit into
mainfrom
feat/pipeline-workflow-dsl

Conversation

@em3s

@em3s em3s commented May 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

ADR #310 v1: declarative workflow YAML over arbitrary DAGs (multi-input join, split, multi-sink) and an in-process EmbeddedRunner. Spec keys mirror GitHub Actions where it makes sense; the rest is actionbase vocabulary.

Refs #310

YAML

name: spark-pi
env:
  SAMPLES: 1000000
jobs:
  pi:
    uses: actionbase/[email protected]       # GHA short form ≡ com.kakao.actionbase:pipeline:0.x
    with:
      class: SparkPiJob                  # reserved key — spark-submit --class
      samples: ${{ env.SAMPLES }}        # everything else flows into the Job's Cfg
    submit:                              # 1:1 spark-submit flags (kebab)
      preset: small                      # workflows/preset/small.yaml
      driver-memory: 1g                  # top-level override
      conf: { spark.sql.shuffle.partitions: 8 }   # deep-merged

StepsRunnerJob lets a workflow inline a Source → Transform* → Sink chain. Label with as:, refer with inputs:; labels become SQL view names:

with:
  class: StepsRunnerJob
  steps:
    - step: FileSource
      args: { path: u.parquet, format: parquet }
      as: users
    - step: FileSource
      args: { path: e.parquet, format: parquet }
      as: events
    - step: SqlTransform
      args: { query: "SELECT u.name, e.kind FROM users u JOIN events e ON u.id = e.user_id" }
      inputs: [users, events]
    - step: ShowSink

Step model

Step In Out
Source 0 1
Transform N (≥1) 1
Sink 1 0

Arbitrary DAGs: linear chain, fan-in (join), split (shared upstream + multiple transforms), diamond, multi-sink (shared upstream or independent sub-trees). The Executor memoizes per-AST materialization across all sinks, so a shared upstream is built once. CacheTransform pins it in-memory when Spark's lineage would otherwise re-execute. Multi-input on the Scala side: (a.as("u") + b.as("e")) ~> SqlTransform(...) — works on Source and Transform outputs alike.

Notable bits

  • uses: — GHA short form (actionbase/[email protected]) is sugar over Maven coords (com.kakao.actionbase:pipeline:0.x). Owner alias actionbase → com.kakao.actionbase.
  • with: — flat for kind=spark. class: is reserved (= spark-submit --class); every other key is bound onto the Job's Cfg.
  • submit: presets — files in <workflowDir>/preset/<name>.yaml auto-load; per-job override deep-merges.
  • env: overrides — ./gradlew :pipeline:runWorkflow --args="<yaml> SAMPLES=100". Resolution mirrors ConfigLoader / ConfigPrinter (yaml < args, per-key trace). Canonical key is lower_snake_case: SOME_SAMPLES ≡ someSamples ≡ some_samples ≡ --some-samples. Word boundaries preserved so sample_s stays distinct from samples.

How to Test

./gradlew :pipeline:test
./gradlew :pipeline:runWorkflow --args="pipeline/workflows/spark-pi.yaml"
./gradlew :pipeline:runWorkflow --args="pipeline/workflows/spark-pi-steps.yaml"

AI Assistance

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

@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. enhancement New feature or request labels May 7, 2026
@em3s
em3s marked this pull request as draft May 7, 2026 14:43
@em3s em3s mentioned this pull request May 8, 2026
1 task done
@em3s
em3s force-pushed the feat/pipeline-workflow-dsl branch 15 times, most recently from c8161b8 to 7bbfd35 Compare May 9, 2026 13:50
ADR #310 v1: workflow YAML is now a real GitHub Actions workflow that
runs on github.com (or `act` / Gitea / Forgejo) via a composite action,
and adapts to the internal model for `EmbeddedRunner` execution.

User-facing YAML shape (valid GHA workflow):

  name: spark-pi
  on:
    workflow_dispatch:
    schedule: [{ cron: '0 0 * * *' }]
  env: { SAMPLES: 1000000 }
  jobs:
    pi:
      runs-on: ubuntu-latest
      steps:
        - uses: actions/checkout@v4
        - uses: kakao/actionbase/actions/[email protected]
          with:
            class: SparkPiJob
            config: { samples: ${{ env.SAMPLES }} }
            submit:
              preset: small
              driver-memory: 1g
              conf: { spark.sql.shuffle.partitions: 8 }

`WorkflowLoader` parses GHA shape (`GhaWorkflow` / `GhaJob` / `GhaStep`)
and adapts to the internal `Workflow` / `JobSpec` model: per-job, finds
the step whose `uses:` contains `actionbase/actions/pipeline-runner`,
extracts `with.class` / `with.config` / `with.submit`. The composite
action (TBD: `kakao/actionbase/actions/[email protected]` in this
monorepo) does the same parsing and invokes spark-submit.

Same artifact-and-class encoding as before — class is the trailing
input, no separate `class:` field at JobSpec level — but now mapped
*through* the GHA action's input. `schedule:` extracted from
`on.schedule[].cron`. `needs:` / `if:` / workflow `env:` are GHA-native
and read directly. Multi-step jobs (`actions/checkout@v4` + runner)
are tolerated; only the runner step is consumed.

Internal layers unchanged:

- DSL — `dsl/{Step, Plan, Job}`: type-state Plan composed via `~>`,
  `Transform.apply` takes `Seq[(String, DataFrame)]` (multi-input
  default), `Open + Open` for joins, `.as("label")` for naming edges.
- AST — `Src`, `Tx`, `Snk`, `Fork` (fanOut), `Group` (multi-sink).
  Executor memoizes per-Ast materialization.
- Steps — `steps/{source/{FileSource, SampleSource},
  transform/{SqlTransform, CacheTransform}, sink/{FileSink, ShowSink}}`.
- Runner — `runner/{EmbeddedRunner, Expression, ClassResolver,
  UsesRef, StepsBuilder, SubmitPreset, EnvCascade}`. EnvCascade
  mirrors `ConfigLoader` / `ConfigPrinter` for `env:` resolution
  (yaml < args, canonical `lower_snake_case`).

Step arity:
  Source     0 in, 1 out
  Transform  N in, 1 out
  Sink       1 in, 0 out

Worked examples:
- workflows/spark-pi.yaml — SparkPiJob (hand-written Job class).
- workflows/spark-pi-steps.yaml — StepsRunnerJob (chain assembled
  at runtime from a YAML steps list).

Build: `:pipeline:runWorkflow` JavaExec task with `workingDir =
rootDir`. Extra `KEY=VALUE` args after the path override workflow
`env:` entries:

  ./gradlew :pipeline:runWorkflow \
      --args="pipeline/workflows/spark-pi.yaml SAMPLES=100000"

Spark stays `compileOnly` for the module.

Refs #310

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@em3s
em3s force-pushed the feat/pipeline-workflow-dsl branch from 7bbfd35 to f3a1f2f Compare May 9, 2026 14:02
@em3s

em3s commented May 10, 2026

Copy link
Copy Markdown
Contributor Author

Closing.

This PR was opened from the initial draft of ADR #310. That ADR has since been split into two:

#310 — job-to-job workflow DSL (composition, dependencies, expressions, $extends)
#313 — Step model for Spark jobs (Source / Transform / Sink, Scala DSL, StepsRunnerJob)

A new PR scoped to the job-to-job workflow will follow.

@em3s em3s closed this May 10, 2026
@em3s em3s self-assigned this Jun 15, 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:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant