tvalentyn commented on code in PR #40283:
URL: https://github.com/apache/beam/pull/40283#discussion_r4225048071


##########
sdks/python/apache_beam/runners/dask/transform_evaluator.py:
##########
@@ -87,13 +87,24 @@ class DaskBagWindowedIterator:
 
   bag: db.Bag
   window_fn: WindowFn
+  lazy_side_inputs: bool = False
 
   def __iter__(self):
-    # FIXME(cisaacstern): list() is likely inefficient, since it presumably
-    # materializes the full result before iterating over it. doing this for
-    # now as a proof-of-concept. can we can generate results incrementally?
-    for result in list(self.bag):
-      yield get_windowed_value(result, self.window_fn)
+    if not self.lazy_side_inputs:
+      for result in list(self.bag):
+        yield get_windowed_value(result, self.window_fn)
+    else:
+      try:
+        from dask.distributed import worker_client
+        with worker_client() as client:
+          for partition in self.bag.to_delayed():
+            # explicitly submit and wait to avoid deadlock
+            for result in client.compute(partition).result():
+              yield get_windowed_value(result, self.window_fn)
+      except (ImportError, ValueError):
+        for partition in self.bag.to_delayed():

Review Comment:
   do you anticipate a particular scenario when we hit this branch or this is 
defensive coding + fallback to original implementation? In the latter case 
consider removing since this flag is opt-in



-- 
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.

To unsubscribe, e-mail: [email protected]

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

Reply via email to