You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by al...@apache.org on 2018/03/23 01:11:50 UTC

[beam] branch master updated: More graceful fallback when grpc is not present.

This is an automated email from the ASF dual-hosted git repository.

altay 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 9be0148  More graceful fallback when grpc is not present.
     new 0221de7  This closes #4936
9be0148 is described below

commit 9be0148970158f253d202b7eddc221270d6c12a5
Author: Robert Bradshaw <ro...@gmail.com>
AuthorDate: Thu Mar 22 01:38:01 2018 -0700

    More graceful fallback when grpc is not present.
---
 sdks/python/apache_beam/runners/direct/direct_runner.py | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/sdks/python/apache_beam/runners/direct/direct_runner.py b/sdks/python/apache_beam/runners/direct/direct_runner.py
index 531423a..062509f 100644
--- a/sdks/python/apache_beam/runners/direct/direct_runner.py
+++ b/sdks/python/apache_beam/runners/direct/direct_runner.py
@@ -83,8 +83,10 @@ class SwitchingDirectRunner(PipelineRunner):
     class _FnApiRunnerSupportVisitor(PipelineVisitor):
       """Visitor determining if a Pipeline can be run on the FnApiRunner."""
 
-      def __init__(self):
+      def accept(self, pipeline):
         self.supported_by_fnapi_runner = True
+        pipeline.visit(self)
+        return self.supported_by_fnapi_runner
 
       def visit_transform(self, applied_ptransform):
         transform = applied_ptransform.transform
@@ -115,9 +117,13 @@ class SwitchingDirectRunner(PipelineRunner):
 
     # Check whether all transforms used in the pipeline are supported by the
     # FnApiRunner.
-    visitor = _FnApiRunnerSupportVisitor()
-    pipeline.visit(visitor)
-    if not visitor.supported_by_fnapi_runner:
+    use_fnapi_runner = _FnApiRunnerSupportVisitor().accept(pipeline)
+
+    # Also ensure grpc is available.
+    try:
+      # pylint: disable=unused-variable
+      import grpc
+    except ImportError:
       use_fnapi_runner = False
 
     if use_fnapi_runner:

-- 
To stop receiving notification emails like this one, please contact
altay@apache.org.