beam icon indicating copy to clipboard operation
beam copied to clipboard

[Feature Request] : Add an experimental beam command to the Python SDK

Open jk-shah opened this issue 1 month ago • 3 comments

What would you like to happen?

Running a Beam YAML pipeline today means typing python -m apache_beam.yaml.main --yaml_pipeline_file=pipeline.yaml, which is long and gives little help when something goes wrong:

user mistakes such as a missing file or an unknown transform end in a Python traceback; the exit code doesn't tell a script whether the pipeline failed or could not be built; Ctrl-C leaves a traceback and can leave local workers running; when the SDK falls back from Prism to another local runner, nothing says which runner ran. I'd like to add an experimental beam console script to the Python SDK, starting with one subcommand:

beam run pipeline.yaml [pipeline options]

It would build and run the pipeline with apache_beam.yaml.main's own functions, so it behaves the same, and pass every other flag through as a pipeline option. On top of that it would:

print a short error instead of a traceback for user errors, with --verbose to show the traceback; use documented exit codes: 0 finished, 1 the pipeline failed, 2 usage error or the pipeline could not be built, 4 a required package is missing, 130 interrupted; cancel the pipeline on Ctrl-C; end with a line naming the runner that actually ran. The code would live in a new apache_beam/cli package, with --help and CHANGES.md marking it experimental, so flags can still change.

Later, separate PRs could add more subcommands. The first proposed is beam pipe --from SOURCE --to SINK, which builds a two-step YAML pipeline to convert files between CSV, JSON, Parquet and Avro, with --dry-run to print the YAML instead of running it. Each would be discussed in its own PR.

Design doc: <Apache Beam CLI Design Proposal, comments enabled>

Milestone Roadmap & Upstream Task List

To provide a single pane of glass for reviewers and community contributors, this task list tracks the modular PR rollout for the beam CLI and its associated core capabilities. Each PR is strictly scoped (<=450 lines) with isolated unit tests.

Preview Demo to try all of them together: Beam CLI Demo branch


Phase 1: Core CLI Foundation & Declarative Execution

  • [x] PR 1: Core CLI Entrypoint & beam run — #40968 (Merged)
    Adds beam console script and beam run FILE.yaml wrapping apache_beam.yaml.main with clean exit codes and Ctrl-C cancellation.
  • [x] PR 2: beam pipe v1 (File-to-File Ingestion) — #41040 (Approved / In Review)
    Declarative format conversion across CSV, JSON, Parquet, and Avro on local and cloud filesystems (gs://, s3://, hdfs://, azfs://), with --dry-run YAML export.
  • [ ] PR 3: beam sql Interactive Calcite SQL Shell — Staged (beam-sql-pr3, commit d5ad23f4cbb)
    Interactive and batch (-e, -f) SQL shell (BeamSqlLine), sharing JAR cache in ~/.beam/cache with pre-flight JDK 11–25 validation. (Ready to open immediately upon PR 2 merge)
  • [ ] PR 4: beam config Named Profile Management — Staged (beam-config-pr4, commit 391461463ad)
    Persistent default PipelineOptions profiles in ~/.beam/config.yaml with disk caching and code-injection defenses. (Ready to open after PR 3)
  • [ ] PR 5: Fast <90 ms Zero-SDK CLI Dispatcher — Staged (beam-fast-pr5)
    Top-level fast dispatcher bypassing cold SDK import latency on --help/config paths and static option-arity splitter.

Phase 2: Agent Protocols, Shorthand Transforms & Universal URIs

  • [ ] PR 6: Agent JSON Output Contract & beam run -
    Deterministic --json output envelope with 4-channel untrusted_data isolation and stdin pipeline execution (beam run -).
  • [ ] PR 7: beam pipe v2: In-Flight Transforms & Quality DLQ
    AST-verified callable: expressions for --where and --select, flat --dlq routing (ReadCsvWithDlq), and fusion-safe --assert-counts.
  • [ ] PR 8: Universal URI Scheme Registry
    Direct URI routing for bigquery://, postgres://, pubsub://, kafka://, and iceberg:// onto standard_io.yaml with zero Docker loopback XLang.

Phase 3: Data Quality, Equivalence Verification & Pipeline Lifecycle

  • [ ] PR 9: beam diff Cross-Store Equivalence Verifier
    Keyed dataset equivalence engine (--key, --rtol, --atol, --max-bytes) exiting 0 on match or 6 on mismatch using $O(1)$ memory.
  • [ ] PR 10: beam inspect Schema & Stats Inspector
    <200 ms metadata and column inspector with --search filter across files, BigQuery tables, and Lakehouse snapshots.
  • [ ] PR 11: Pre-Flight Static Validation (beam check, beam io, beam doctor)
    Offline YAML/AST schema validation, ~200-token connector cards, and environment diagnostics (JDK, credentials, cache).
  • [ ] PR 12: Remote Timeout Continuity & Cost Guardrails
    Wall-clock --wait-timeout with detached job state tracking (beam wait, beam cancel) and --max-bytes scan budget enforcement.
  • [ ] PR 13: beam tail [-f] Stream Peek & Live Follow
    Bounded stream preview and Linux-style live follow across Pub/Sub, Kafka, and storage shard partitions.
  • [ ] PR 14: Agent Skill Specification & beam --llms-txt
    Self-documenting agent interfaces and plugin hooks (apache_beam.cli.commands).

Phase 4: Lakehouse, Cross-Engine CDC & Serverless Packaging

  • [ ] PR 15: beam package Zero-Docker YAML Flex Templates
    <2s packager generating regional Flex Template specifications without requiring local Docker daemon or Cloud Build.
  • [ ] PR 16: Cross-Engine CDC & Zero-Copy Lakehouse Bridges
    Turnkey --cdc --primary-key replication (Debezium/Spanner/Delta/Iceberg -> BigQuery Storage Write API & Iceberg v2 MoR) and <100 ms --zero-copy manifest registration.

Supporting Upstream Bug Fixes & Feature Requests

  • Merged Supporting Fixes:
    • #41044 — Generic Filter comparison operators in Beam YAML (yaml_mapping.py).
    • #41045 — PyarrowBatchConverter CSV-to-Parquet batch conversion fix.
  • Filed Core Bug Reports:
    • #41076 — DataflowMetrics._populate_metrics KeyError on tentative/committed metrics.
    • #41077 — yaml_mapping SyntaxError on Python keyword column names (in, from, is).
    • #41078 — DirectRunner Prism fallback NotImplementedError on batched DoFns.
    • #41079 — Java SDK harness Row resolution in generic filter.
    • #41080 — Python --spark_submit_uber_jar storage level flag requirement.
  • Filed Core Feature Requests:
    • #41081 — Dead-letter error handling on ReadFromCsv and ReadFromJson.
    • #41223 — Native Expect / data quality PTransform with tagged DLQ outputs.
    • #41224 — Declarative IntervalJoin composite transform with watermark skew circuit breaker.
    • #41225 — Turnkey Confluent Schema Registry Wire Format deserializer in ReadFromKafka.
    • #41226 — Continuous streaming snapshot commit watermarking in beam.managed.Write(ICEBERG).
    • #41227 — Partition-aware zero-copy metadata translation from Delta Lake to Apache Iceberg.

Issue Priority

Priority: 2 (default / most feature requests should be filed as P2)

Issue Components

  • [x] Component: Python SDK
  • [ ] Component: Java SDK
  • [ ] Component: Go SDK
  • [ ] Component: Typescript SDK
  • [ ] Component: IO connector
  • [x] Component: Beam YAML
  • [ ] Component: Beam examples
  • [ ] Component: Beam playground
  • [ ] Component: Beam katas
  • [ ] Component: Website
  • [ ] Component: Infrastructure
  • [ ] Component: Spark Runner
  • [ ] Component: Flink Runner
  • [ ] Component: Prism Runner
  • [ ] Component: Hazelcast Jet Runner
  • [ ] Component: Google Cloud Dataflow Runner

jk-shah avatar Oct 29 '26 22:10 jk-shah

Hi, I’d like to help implement this. I’d start with a minimal beam run command that reuses the YAML runner, then cover option forwarding, user errors, exit codes and interruption cleanup. Before starting, is the proposed console entrypoint approved, or should the first contribution be CLI tests and a small prototype for review?

darshpatel1052 avatar Nov 03 '26 05:11 darshpatel1052

Hi, I’d like to help implement this. I’d start with a minimal beam run command that reuses the YAML runner, then cover option forwarding, user errors, exit codes and interruption cleanup. Before starting, is the proposed console entrypoint approved, or should the first contribution be CLI tests and a small prototype for review?

Darsh, Lets connect offline to see where we can use your help for this project!

jk-shah avatar Nov 06 '26 17:11 jk-shah

Planning to .take-issue to project manage/develop large pieces but could use help where possible. Updated description for the plan of work to be done.

jk-shah avatar Nov 12 '26 15:11 jk-shah