Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warn when using auto_unique_labels #31551

Merged
merged 3 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion sdks/python/apache_beam/options/pipeline_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,10 @@ def _add_argparse_args(cls, parser):
action='store_true',
help='Whether to automatically generate unique transform labels '
'for every transform. The default behavior is to raise an '
'exception if a transform is created with a non-unique label.')
'exception if a transform is created with a non-unique label. '
'Using --auto_unique_labels could cause data loss when '
'updating a pipeline or reloading the job state. '
'This is not recommended for streaming jobs.')


class StreamingOptions(PipelineOptions):
Expand Down
9 changes: 8 additions & 1 deletion sdks/python/apache_beam/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,10 @@ def apply(
if auto_unique_labels:
# If auto_unique_labels is set, we will append a unique suffix to the
# label to make it unique.
logging.warning(
'Using --auto_unique_labels could cause data loss when '
liferoad marked this conversation as resolved.
Show resolved Hide resolved
'updating a pipeline or reloading the job state. '
'This is not recommended for streaming jobs.')
unique_label = self._generate_unique_label(transform)
return self.apply(transform, pvalueish, unique_label)
else:
Expand All @@ -702,7 +706,10 @@ def apply(
'To apply a transform with a specified label, write '
'pvalue | "label" >> transform or use the option '
'"auto_unique_labels" to automatically generate unique '
'transform labels' % full_label)
'transform labels. Note "auto_unique_labels" '
'could cause data loss when updating a pipeline or '
'reloading the job state. This is not recommended for '
'streaming jobs.' % full_label)
self.applied_labels.add(full_label)

pvalueish, inputs = transform._extract_input_pvalues(pvalueish)
Expand Down
5 changes: 4 additions & 1 deletion sdks/python/apache_beam/pipeline_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,10 @@ def test_reuse_custom_transform_instance(self):
'pipeline. To apply a transform with a specified label, write '
'pvalue | "label" >> transform or use the option '
'"auto_unique_labels" to automatically generate unique '
'transform labels')
'transform labels. Note "auto_unique_labels" '
'could cause data loss when updating a pipeline or '
'reloading the job state. This is not recommended for '
'streaming jobs.')

def test_auto_unique_labels(self):

Expand Down
Loading