Skip to content

Commit

Permalink
Better error messaging for chain-type pipeline (#33210)
Browse files Browse the repository at this point in the history
  • Loading branch information
mravi authored Nov 26, 2024
1 parent 720b824 commit 0d55231
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sdks/python/apache_beam/yaml/yaml_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,8 +576,8 @@ def is_not_output_of_last_transform(new_transforms, value):
pass
else:
raise ValueError(
f'Transform {identify_object(transform)} is part of a chain, '
'must have implicit inputs and outputs.')
f'Transform {identify_object(transform)} is part of a chain. '
'Cannot define explicit inputs on chain pipeline')
if ix == 0:
if is_explicitly_empty(transform.get('input', None)):
pass
Expand Down
17 changes: 17 additions & 0 deletions sdks/python/apache_beam/yaml/yaml_transform_unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,23 @@ def test_chain_as_composite_with_input(self):
self.assertEqual(
chain_as_composite(spec)['transforms'][0]['input'], {"input": "input"})

def test_chain_as_composite_with_transform_input(self):
spec = '''
type: chain
transforms:
- type: Create
config:
elements: [0,1,2]
- type: LogForTesting
input: Create
'''
spec = yaml.load(spec, Loader=SafeLineLoader)
with self.assertRaisesRegex(
ValueError,
r"Transform .* is part of a chain. "
r"Cannot define explicit inputs on chain pipeline"):
chain_as_composite(spec)

def test_normalize_source_sink(self):
spec = '''
source:
Expand Down

0 comments on commit 0d55231

Please sign in to comment.