You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2018/09/25 15:46:29 UTC

[22/49] tinkerpop git commit: TINKERPOP-1913 Retrieve status attributes through side-effects in python

TINKERPOP-1913 Retrieve status attributes through side-effects in python


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/3aacd06f
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/3aacd06f
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/3aacd06f

Branch: refs/heads/TINKERPOP-2039
Commit: 3aacd06fa84c4250505aad3809265a578cfc3d8f
Parents: d457d7c
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Sep 18 15:51:32 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Sep 18 15:51:32 2018 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                                           | 2 +-
 .../jython/gremlin_python/driver/driver_remote_connection.py | 8 ++++----
 .../main/jython/gremlin_python/driver/remote_connection.py   | 7 ++++++-
 .../jython/tests/driver/test_driver_remote_connection.py     | 4 ++++
 4 files changed, 15 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3aacd06f/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index a151bc7..32094ea 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -39,7 +39,7 @@ This release also includes changes from <<release-3-3-3, 3.3.3>>.
 * Bumped to Spark 2.3.1.
 * Modified Gremlin Server to return a "host" status attribute on responses.
 * Added ability to the Java, .NET and Python drivers to retrieve status attributes returned from the server on the `ResultSet` object.
-* Modified remote traversals to retrieve status attributes from traversal side-effects.
+* Modified remote traversals to retrieve status attributes from traversal side-effects in Python and Java drivers.
 * Deprecated two `submit()`-related methods on the Java driver `Client` class.
 * Modified Java and Gremlin.Net `ResponseException` to include status code and status attributes.
 * Modified Python `GremlinServerError` to include status attributes.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3aacd06f/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py b/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
index d447cbd..dcd2fa3 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
@@ -52,8 +52,8 @@ class DriverRemoteConnection(RemoteConnection):
     def submit(self, bytecode):
         result_set = self._client.submit(bytecode)
         results = result_set.all().result()
-        side_effects = RemoteTraversalSideEffects(result_set.request_id,
-                                                  self._client)
+        side_effects = RemoteTraversalSideEffects(result_set.request_id, self._client,
+                                                  result_set.status_attributes)
         return RemoteTraversal(iter(results), side_effects)
 
     def submitAsync(self, bytecode):
@@ -64,8 +64,8 @@ class DriverRemoteConnection(RemoteConnection):
             try:
                 result_set = f.result()
                 results = result_set.all().result()
-                side_effects = RemoteTraversalSideEffects(result_set.request_id,
-                                                          self._client)
+                side_effects = RemoteTraversalSideEffects(result_set.request_id, self._client,
+                                                          result_set.status_attributes)
                 future.set_result(RemoteTraversal(iter(results), side_effects))
             except Exception as e:
                 future.set_exception(e)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3aacd06f/gremlin-python/src/main/jython/gremlin_python/driver/remote_connection.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/remote_connection.py b/gremlin-python/src/main/jython/gremlin_python/driver/remote_connection.py
index b9ec4e5..e9b52a5 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/remote_connection.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/remote_connection.py
@@ -63,12 +63,17 @@ class RemoteTraversal(traversal.Traversal):
 
 
 class RemoteTraversalSideEffects(traversal.TraversalSideEffects):
-    def __init__(self, side_effect, client):
+    def __init__(self, side_effect, client, status_attributes):
         self._side_effect = side_effect
         self._client = client
         self._keys = set()
         self._side_effects = {}
         self._closed = False
+        self._status_attributes = status_attributes
+
+    @property
+    def status_attributes(self):
+        return self._status_attributes
 
     def keys(self):
         if not self._closed:

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3aacd06f/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py b/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py
index 627fbe4..0ef20c1 100644
--- a/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py
+++ b/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py
@@ -183,6 +183,10 @@ class TestDriverRemoteConnection(object):
         assert 1 == m["ripple"]
         assert isinstance(m["lop"], long)
         assert isinstance(m["ripple"], long)
+
+        # check status attributes
+        assert "host" in t.side_effects.status_attributes
+
         ##
         t = g.V().out("created").groupCount("m").by("name").name.aggregate("n")
         results = t.toSet()