apache / apache/beam

Python API: PTransform should be immutable and reusable

Open
#19,675 0 comments 0 reactions 0 assignees View on GitHub
bug core P3 python
Dominant language
Java
Stars
8.7k
Forks
4.7k
Avg merge
1d 20h
Merged PRs (30d)
196

Description

While the Java API seems fine the Python API is (at least) counterintuitive.

Let's see the following example:
```

p1 = beam.Pipeline()
p2 = beam.Pipeline()
node = 'ReadTrainData' >> beam.io.ReadFromText("/tmp/aaa.txt")
p1
| node
p2 | node //fails here
```

The code above will fail because the _node_ somehow remembers that it was already attached to _p1_. In fact, unlike in Java, the | (apply) method is defined on the _PTransform_.

If any, only the pipeline object should be mutable here.

Imported from Jira [BEAM-8140](https://issues.apache.org/jira/browse/BEAM-8140). Original Jira may contain additional context.
Reported by: chris_suchanek.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.