You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "prodriguezdefino (via GitHub)" <gi...@apache.org> on 2026/10/16 21:32:05 UTC
[PR] [Prism] Finalize bundles of DoFns fused after another transform [beam]
prodriguezdefino opened a new pull request, #40640:
URL: https://github.com/apache/beam/pull/40640
Problem:
In finalizeStage (sdks/go/pkg/beam/runners/prism/internal/preprocess.go), Prism sets `stage.finalize` only while it inspects the consumers of the stage's input PCollections. The loop skips every PCollection that a transform of the same stage produces:
```go
for pid, plinks := range stageFacts.PcolConsumers {
if _, ok := stageFacts.PcolProducers[pid]; ok {
continue
}
...
if pardo.GetRequestsFinalization() {
stg.finalize = true
}
```
So a `ParDo` that sets `requests_finalization` but is fused after another transform (a `Map` after `Create`, the expand step of a `Reshuffle`, any element-wise chain) never marks its stage. The SDK harness registers the callbacks and returns `requires_finalization`, but Prism never sends `FinalizeBundleRequest`, and the callbacks never run. This affects every SDK. The existing `TestParDoBundleFinalizer` cases apply the finalizing `DoFn` directly to Impulse, so the `DoFn` always consumes the stage input and the tests pass.
Fix:
Set `stage.finalize` from every ParDo-like transform of the stage (`ParDo` and the splittable `DoFn` stage URNs), not only from the consumers of the stage inputs. Statefulness, the on-window-expiration timer and side inputs still come from the input consumers. Add a `TestParDoBundleFinalizer` case with the finalizing `DoFn` fused after another `ParDo`.
Reproduction (Python SDK on PrismRunner):
```python
import os
import tempfile
import apache_beam as beam
from apache_beam.options.pipeline_options import PipelineOptions
class MarkFinalization(beam.DoFn):
"""Registers a bundle finalization callback that creates the file `path`."""
def __init__(self, path):
self._path = path
def process(self, element, bundle_finalizer=beam.DoFn.BundleFinalizerParam):
path = self._path
bundle_finalizer.register(lambda: open(path, "w").close())
yield element
if __name__ == "__main__":
markers = tempfile.mkdtemp()
at_input = os.path.join(markers, "at_stage_input")
fused = os.path.join(markers, "after_fused_map")
options = PipelineOptions(["--runner=PrismRunner", "--environment_type=LOOPBACK"])
with beam.Pipeline(options=options) as p:
impulse = p | beam.Impulse()
# Consumes the input of its stage: Prism finalizes the bundle.
_ = impulse | "AtStageInput" >> beam.ParDo(MarkFinalization(at_input))
# Fused after a Map in the same stage: Prism never finalizes the bundle.
_ = (
impulse
| "Map" >> beam.Map(lambda x: x)
| "AfterFusedMap" >> beam.ParDo(MarkFinalization(fused))
)
print("finalized:", sorted(os.listdir(markers)))
assert os.path.exists(at_input), "the DoFn at the stage input was not finalized"
assert os.path.exists(fused), "the DoFn fused after Map was not finalized"
```
Before the fix: `finalized: ['at_stage_input']`, and the second assertion fails.
After the fix: `finalized: ['after_fused_map', 'at_stage_input']`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Prism] Finalize bundles of DoFns fused after another transform [beam]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #40640:
URL: https://github.com/apache/beam/pull/40640#issuecomment-6226694195
Assigning reviewers:
R: @lostluck for label go.
Backup reviewer: shunping (if the main reviewer is unresponsive, you can escalate to them by tagging their username)
Note: If you would like to opt out of this review, comment `assign to next reviewer`.
Available commands:
- `stop reviewer notifications` - opt out of the automated review tooling
- `remind me after tests pass` - tag the comment author after tests pass
- `waiting on author` - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)
The PR bot will only process comments in the main thread (not review comments).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Prism] Finalize bundles of DoFns fused after another transform [beam]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #40640:
URL: https://github.com/apache/beam/pull/40640#issuecomment-6225207431
## [Codecov](https://app.codecov.io/gh/apache/beam/pull/40640?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `77.77778%` with `2 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 28.62%. Comparing base ([`76f6e6d`](https://app.codecov.io/gh/apache/beam/commit/76f6e6d7c0c1b2ce582c73d068ad9260cf15c5f3?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`a778336`](https://app.codecov.io/gh/apache/beam/commit/a778336059c315c2fc0bdf70a56fd8f795b15ea4?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 215 commits behind head on master.
| [Files with missing lines](https://app.codecov.io/gh/apache/beam/pull/40640?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [...s/go/pkg/beam/runners/prism/internal/preprocess.go](https://app.codecov.io/gh/apache/beam/pull/40640?src=pr&el=tree&filepath=sdks%2Fgo%2Fpkg%2Fbeam%2Frunners%2Fprism%2Finternal%2Fpreprocess.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c2Rrcy9nby9wa2cvYmVhbS9ydW5uZXJzL3ByaXNtL2ludGVybmFsL3ByZXByb2Nlc3MuZ28=) | 77.77% | [1 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/beam/pull/40640?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #40640 +/- ##
=============================================
- Coverage 56.16% 28.62% -27.55%
=============================================
Files 1124 380 -744
Lines 178336 70981 -107355
Branches 1489 0 -1489
=============================================
- Hits 100170 20318 -79852
+ Misses 75645 48820 -26825
+ Partials 2521 1843 -678
```
| [Flag](https://app.codecov.io/gh/apache/beam/pull/40640/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [go](https://app.codecov.io/gh/apache/beam/pull/40640/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `28.62% <77.77%> (-0.52%)` | :arrow_down: |
| [java](https://app.codecov.io/gh/apache/beam/pull/40640/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [python](https://app.codecov.io/gh/apache/beam/pull/40640/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/beam/pull/40640?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Prism] Finalize bundles of DoFns fused after another transform [beam]
Posted by "lostluck (via GitHub)" <gi...@apache.org>.
lostluck commented on PR #40640:
URL: https://github.com/apache/beam/pull/40640#issuecomment-6226902325
Good find! Looking presently.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Prism] Finalize bundles of DoFns fused after another transform [beam]
Posted by "lostluck (via GitHub)" <gi...@apache.org>.
lostluck merged PR #40640:
URL: https://github.com/apache/beam/pull/40640
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org