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/04/13 21:57:17 UTC
[GitHub] [beam] rohdesamuel commented on a change in pull request #11389:
Refactor the BCJ and capture controls to be more testable
rohdesamuel commented on a change in pull request #11389: Refactor the BCJ and capture controls to be more testable
URL: https://github.com/apache/beam/pull/11389#discussion_r407745006
##########
File path: sdks/python/apache_beam/runners/interactive/interactive_runner_test.py
##########
@@ -196,6 +197,28 @@ def process(self, element):
# applied but needs an IPython environment. So we manually run this here.
ie.current_env().track_user_pipelines()
+ # Create a fake limiter that cancels the BCJ once the main job receives the
+ # expected amount of results.
+ class FakeLimiter:
+ def __init__(self, p, pcoll):
+ self.p = p
+ self.pcoll = pcoll
+
+ def is_triggered(self):
+ result = ie.current_env().pipeline_result(self.p)
+ if result:
+ try:
+ results = result.get(self.pcoll)
+ except ValueError:
+ return False
+ return len(results) >= 10
+ return False
+
+ # This sets the limiters to stop reading when the test receives 10 elements
+ # or after 5 seconds have elapsed (to eliminate the possibility of hanging).
+ ie.current_env().options.capture_control.set_limiters_for_test(
+ [FakeLimiter(p, data), DurationLimiter(timedelta(seconds=5))])
Review comment:
Yep!
----------------------------------------------------------------
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
With regards,
Apache Git Services