This is an automated email from the ASF dual-hosted git repository.
robertwb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/master by this push:
new d4d99a1d76f Avoid unreasonably long stage names for @ptransform_fn.
(#35547)
d4d99a1d76f is described below
commit d4d99a1d76fd1782c972f73312d16012ad0c9af3
Author: Robert Bradshaw <[email protected]>
AuthorDate: Mon Jul 14 10:51:29 2025 -0700
Avoid unreasonably long stage names for @ptransform_fn. (#35547)
This was noticed in particular when the first argument was a large config
object.
Also added a note about the (existing) intent for that function.
---
sdks/python/apache_beam/transforms/ptransform.py | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/sdks/python/apache_beam/transforms/ptransform.py
b/sdks/python/apache_beam/transforms/ptransform.py
index 7f48c24a2db..c653eb62c6f 100644
--- a/sdks/python/apache_beam/transforms/ptransform.py
+++ b/sdks/python/apache_beam/transforms/ptransform.py
@@ -1027,11 +1027,18 @@ class _PTransformFnPTransform(PTransform):
pass
return self._fn(pcoll, *args, **kwargs)
- def default_label(self):
+ def default_label(self) -> str:
+ # Attempt to give a reasonable name to this transform.
+ # We want it to be reasonably unique, but also not sensitive to
+ # irrelevent parameters to minimize pipeline-to-pipeline variance.
+ # For now, use only the first argument (if any), iff it would not make
+ # the name unwieldy.
if self._args:
- return '%s(%s)' % (
- label_from_callable(self._fn), label_from_callable(self._args[0]))
- return label_from_callable(self._fn)
+ first_arg_string = label_from_callable(self._args[0])
+ suffix = '(%s)' % first_arg_string if len(first_arg_string) <= 16 else ''
+ else:
+ suffix = ''
+ return label_from_callable(self._fn) + suffix
def ptransform_fn(fn):