Skip to content

Commit d285645

Browse files
tf-transform-teamtfx-copybara
authored andcommitted
Update due to use of changed internal Beam API.
PiperOrigin-RevId: 724432137
1 parent e982a7b commit d285645

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

tensorflow_transform/beam/deep_copy.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"""
2626

2727
import queue
28+
import re
2829

2930
import apache_beam as beam
3031
from apache_beam import pipeline as beam_pipeline
@@ -203,8 +204,18 @@ def _clone_items(pipeline, to_clone):
203204
# Create the copy. Note that in the copy, copied.outputs will start out
204205
# empty. Any outputs that are used will be repopulated in the PCollection
205206
# copy branch above.
206-
copied = beam_pipeline.AppliedPTransform(item.parent, item.transform,
207-
new_label, new_inputs)
207+
maybe_int = lambda s: int(s) if re.match(r'^\d+$', s) else s
208+
semver = tuple(maybe_int(s) for s in beam.__version__.split('.'))
209+
if semver >= (2, 63):
210+
extra_args = {
211+
'environment_id': item.environment_id,
212+
'annotations': item.annotations,
213+
}
214+
else:
215+
extra_args = {}
216+
copied = beam_pipeline.AppliedPTransform(
217+
item.parent, item.transform, new_label, new_inputs, **extra_args
218+
)
208219

209220
# Add a 'close to resource' resource hint to the copied PTransforms. The
210221
# PTransforms that are generated from each deep copy have the same unique

0 commit comments

Comments
 (0)