TINKERPOP-1799 Fixed serialization of Path objects for python. This issue only related to GraphSON 3.0 and was fairly straightforward to fix. Tests did not pick up the failure because they continued to use GraphSON 2.0 format in the test itself.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/d5ed2f7c Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/d5ed2f7c Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/d5ed2f7c Branch: refs/heads/TINKERPOP-1799 Commit: d5ed2f7cb9a110453667be0b1dbfc6bf9c0383a6 Parents: 0a183f8 Author: Stephen Mallette <[email protected]> Authored: Fri Oct 13 12:34:42 2017 -0400 Committer: Stephen Mallette <[email protected]> Committed: Fri Oct 13 12:37:42 2017 -0400 ---------------------------------------------------------------------- CHANGELOG.asciidoc | 1 + docs/src/upgrade/release-3.3.x.asciidoc | 8 ++++++++ .../main/jython/gremlin_python/structure/io/graphsonV3d0.py | 4 +--- .../src/main/jython/tests/structure/io/test_graphsonV3d0.py | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d5ed2f7c/CHANGELOG.asciidoc ---------------------------------------------------------------------- diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index f948391..07ce7b2 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -25,6 +25,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima This release also includes changes from <<release-3-2-7, 3.2.7>>. +* Fixed bug in serialization of `Path` for GraphSON 3.0 in `gremlin-python`. * Added support for GraphSON 3.0 in Gremlin.Net. * Added `math()`-step which supports scientific calculator capabilities for numbers within a traversal. * Added missing `GraphTraversalSource.addE()`-method to `GremlinDslProcessor`. http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d5ed2f7c/docs/src/upgrade/release-3.3.x.asciidoc ---------------------------------------------------------------------- diff --git a/docs/src/upgrade/release-3.3.x.asciidoc b/docs/src/upgrade/release-3.3.x.asciidoc index e36bdf1..80aff8b 100644 --- a/docs/src/upgrade/release-3.3.x.asciidoc +++ b/docs/src/upgrade/release-3.3.x.asciidoc @@ -29,6 +29,14 @@ Please see the link:https://github.com/apache/tinkerpop/blob/3.3.1/CHANGELOG.asc === Upgrading for Users +==== Gremlin Python path() + +There was a bug in GraphSON 3.0 serialization that prevented proper handling of results contain `Path` object. As a +result, traversals that used and returned results from the `path()` step in Python would return unusable results, +but did not actually cause an exception condition. This problem is now resolved. + +See: link:https://issues.apache.org/jira/browse/TINKERPOP-1799[TINKERPOP-1799] + ==== Added `math()`-step for Scientific Traversal Computing `GraphTraversal.math(String)` was added. This step provides scientific calculator capabilities to a Gremlin traversal. http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d5ed2f7c/gremlin-python/src/main/jython/gremlin_python/structure/io/graphsonV3d0.py ---------------------------------------------------------------------- diff --git a/gremlin-python/src/main/jython/gremlin_python/structure/io/graphsonV3d0.py b/gremlin-python/src/main/jython/gremlin_python/structure/io/graphsonV3d0.py index 7194f48..6b5144e 100644 --- a/gremlin-python/src/main/jython/gremlin_python/structure/io/graphsonV3d0.py +++ b/gremlin-python/src/main/jython/gremlin_python/structure/io/graphsonV3d0.py @@ -465,6 +465,4 @@ class PathDeserializer(_GraphSONTypeIO): @classmethod def objectify(cls, d, reader): - labels = [set(label) for label in d["labels"]] - objects = [reader.toObject(o) for o in d["objects"]] - return Path(labels, objects) + return Path(reader.toObject(d["labels"]), reader.toObject(d["objects"])) http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d5ed2f7c/gremlin-python/src/main/jython/tests/structure/io/test_graphsonV3d0.py ---------------------------------------------------------------------- diff --git a/gremlin-python/src/main/jython/tests/structure/io/test_graphsonV3d0.py b/gremlin-python/src/main/jython/tests/structure/io/test_graphsonV3d0.py index b4dfcac..d04db13 100644 --- a/gremlin-python/src/main/jython/tests/structure/io/test_graphsonV3d0.py +++ b/gremlin-python/src/main/jython/tests/structure/io/test_graphsonV3d0.py @@ -143,7 +143,7 @@ class TestGraphSONReader(object): def test_path(self): path = self.graphson_reader.readObject( - """{"@type":"g:Path","@value":{"labels":[["a"],["b","c"],[]],"objects":[{"@type":"g:Vertex","@value":{"id":{"@type":"g:Int32","@value":1},"label":"person","properties":{"name":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":0},"value":"marko","label":"name"}}],"age":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":1},"value":{"@type":"g:Int32","@value":29},"label":"age"}}]}}},{"@type":"g:Vertex","@value":{"id":{"@type":"g:Int32","@value":3},"label":"software","properties":{"name":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":4},"value":"lop","label":"name"}}],"lang":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":5},"value":"java","label":"lang"}}]}}},"lop"]}}""" + """{"@type":"g:Path","@value":{"labels":{"@type":"g:List","@value":[{"@type":"g:Set","@value":["a"]},{"@type":"g:Set","@value":["b","c"]},{"@type":"g:Set","@value":[]}]},"objects":{"@type":"g:List","@value":[{"@type":"g:Vertex","@value":{"id":{"@type":"g:Int32","@value":1},"label":"person","properties":{"name":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":0},"value":"marko","label":"name"}}],"age":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":1},"value":{"@type":"g:Int32","@value":29},"label":"age"}}]}}},{"@type":"g:Vertex","@value":{"id":{"@type":"g:Int32","@value":3},"label":"software","properties":{"name":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":4},"value":"lop","label":"name"}}],"lang":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":5},"value":"java","label":"lang"}}]}}},"lop"]}}}""" ) assert isinstance(path, Path) if six.PY3:
