fix(python): Register all declared DoOutputsTuple outputs in composite transforms #37556
+44
−5
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
_pcollsdictDoOutputsTuplesubclasses haven't accessed all outputs at registration timeDoOutputsTuplesubclass with__or__overrideDescription
PR #36220 changed composite output registration to iterate over
result._pcolls.items(). However,_pcollsis lazily populated — PCollections are only added when accessed via__getitem__. This means unaccessed outputs are silently dropped from the composite's registered outputs.This breaks when a
DoOutputsTuplesubclass (e.g. one that overrides__or__to pipe to the main output) is returned from a composite'sexpand(). At registration time, only outputs that happened to be accessed are in_pcolls, so the main output may be missing from the pipeline proto. This causes disconnected edges in pipeline visualization.Fix: Iterate over all declared tags (
_main_tag+_tags) and access each viaresult[tag]to trigger lazy creation, ensuring all outputs are registered.Test plan
test_do_outputs_tuple_subclass_registers_all_outputsverifies consumed PCollection appears in composite's proto outputstest_multiple_outputs_composite_ptransformupdated to expect all 3 outputs (main + 2 tagged)pipeline_test.pysuite passes (63 passed, 2 skipped)🤖 Generated with Claude Code