You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2020/10/12 14:26:00 UTC

[GitHub] [beam] kamilwu commented on a change in pull request #13048: [BEAM-3736] Add CombineFn.setup and CombineFn.teardown to Python SDK

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:
users@infra.apache.org