kamilwu commented on a change in pull request #13048:
URL: https://github.com/apache/beam/pull/13048#discussion_r503332709



##########
File path: sdks/python/apache_beam/transforms/core.py
##########
@@ -1970,10 +1985,14 @@ def add_input_types(transform):
       return combined
 
     if self.has_defaults:
-      combine_fn = (
-          self.fn if isinstance(self.fn, CombineFn) else
-          CombineFn.from_callable(self.fn))
-      default_value = combine_fn.apply([], *self.args, **self.kwargs)
+      combine_fn = copy.copy(

Review comment:
       Better protection against potential side effects.
   
   If using default values, `CombineFn.apply` is called at pipeline 
construction time. `CombineFn.setup` and `CombineFn.teardown` are called along 
with it. The same instance of CombineFn is then serialized and sent to runner. 
I think it would be better to perform initial `CombineFn.apply` on a copy, so 
that the state of the instance is not polluted.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to