Explore Apache Beam for defining pipelines (POC + evaluation) - #95
Open
ekim1394 wants to merge 1 commit into
Open
Explore Apache Beam for defining pipelines (POC + evaluation)#95ekim1394 wants to merge 1 commit into
ekim1394 wants to merge 1 commit into
Conversation
Explore whether Apache Beam fits this project's pipeline model. The existing Reader -> Transform -> Writer abstractions map onto Beam almost one-to-one, so this adds a small, isolated spike that proves it on the in-process direct runner, plus a written evaluation. - New optional `beam` extra (kept out of core/dev: apache-beam pins heavy transitive deps) and a `run-beam-example` console script. - src/spicy_regs/beam/adapters.py bridges Reader/Transform/Writer to Beam (ReadWith, ApplyTransform, DedupBy via GroupByKey, WriteWith). - src/spicy_regs/beam/example_pipeline.py reuses the real Pipeline base and ExtractRecords transform, adds a whole-dataset dedup, runs on the direct runner. - Hermetic test guarded by importorskip so the default suite is unaffected. - src/spicy_regs/beam/README.md: the evaluation (mapping, trade-offs, recommendation, and when to revisit) linked from CONTRIBUTING.md. - Exclude the experimental module from ty (apache-beam ships no type stubs). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Dx9dKzCu9VNmwAzYxqGF2A
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Explores whether Apache Beam is a good fit for defining this project's pipelines. The existing
Reader → Transform → Writermodel maps onto Beam almost one-to-one, so this adds a small, isolated proof-of-concept that proves it on the in-process direct runner, plus a written evaluation with a recommendation.This is an exploration, not a migration — nothing in the production ETL path changes, and the default install/CI are untouched.
What's here:
beamextra (pyproject.toml) — kept out of core/dev on purpose; apache-beam pins heavy transitive deps (pyarrow/numpy/protobuf/dill) that can clash with the polars/duckdb/pyarrow stack. Adds arun-beam-exampleconsole script.src/spicy_regs/beam/adapters.py— the reusable bridge:ReadWith(Reader →beam.Create),ApplyTransform(Transform →ParDo/FlatMap),DedupBy(the bulk merge →GroupByKey+ pick-latest),WriteWith(Writer → sinkDoFn).src/spicy_regs/beam/example_pipeline.py— a runnable POC that reuses the realPipelinebase andExtractRecordstransform, adds a whole-dataset dedup, and runs on the in-process runner.src/spicy_regs/beam/README.md— the evaluation: how the model maps onto Beam, what Beam buys, what it costs, a recommendation (don't adopt in production at current scale), and concrete "revisit when…" triggers. Linked fromCONTRIBUTING.md.tests/test_beam_pipeline.py— hermetic test guarded byimportorskipso the default suite (nobeamextra) skips it and stays fast.ty(apache-beam ships no type stubs).Recommendation in short: the model fits and the spike proves it, but the per-agency workload is already embarrassingly parallel (ThreadPoolExecutor + cron) and runs free on GitHub Actions, so adopting Beam isn't justified yet. Keep it as an optional, experimental path.
Test plan
Verified locally:
uv run pytest— 230 passed, 1 skipped (the Beam test, since thebeamextra isn't installed by default), 3 deselected.uv run ruff check .— all checks passed.uv run ty check— all checks passed (beam module excluded).uv sync --extra beam— apache-beam 2.72.0 resolves cleanly; no downgrade of numpy/pandas/pyarrow at the runtime Python (3.12).uv run pytest tests/test_beam_pipeline.py -v— passes; asserts the transform shapes + uppercases records andDedupBycollapses the duplicate key keeping the latestmodify_date.uv run run-beam-exampleprints the transformed, deduplicated records.Checklist
🤖 Generated with Claude Code
Generated by Claude Code