Hi,

Done for the night. Here is PythonStringGraphTraversal.

https://gist.github.com/okram/4705fed038dde673f4c5323416899992

??? Cool?

Marko.

http://markorodriguez.com

On Apr 19, 2016, at 4:28 PM, Marko Rodriguez <okramma...@gmail.com> wrote:

> Hi,
> 
> So I "learned" Python and am able to do a Python class wrapper around 
> GraphTraversal.
> 
>       https://gist.github.com/okram/1a0c5f6b65a4b70c558537e5eeaad429
> 
> Its crazy, it "just works" -- with __ static methods and all.
> 
> The reason I wanted to create a wrapper is because I want to use 
> Python-specific language constructs and not only Gremlin-Java. What those 
> specific language constructs are, I don't know as I don't know Python :). 
> Moreover, this shell of a wrapper will be used for the JNI and String 
> construction models. Right?
> 
> >>> g = PythonGraphTraversalSource(graph)
> >>> g
> graphtraversalsource[tinkergraph[vertices:6 edges:6], standard]
> >>> g.V()
> [GraphStep(vertex,[])]
> >>> g.V().toList()
> [v[1], v[2], v[3], v[4], v[5], v[6]]
> >>> g.V().where(__.out("created")).values("name").toList()
> [marko, josh, peter]
> >>>
> 
> Even valueMap() which takes var args of different types works.
> 
> >>> g.V().valueMap()
> [GraphStep(vertex,[]), PropertyMapStep(value)]
> >>> g.V().valueMap().toList()
> [{name=[marko], age=[29]}, {name=[vadas], age=[27]}, {name=[lop], 
> lang=[java]}, {name=[josh], age=[32]}, {name=[ripple], lang=[java]}, 
> {name=[peter], age=[35]}]
> >>> g.V().valueMap("name").toList()
> [{name=[marko]}, {name=[vadas]}, {name=[lop]}, {name=[josh]}, 
> {name=[ripple]}, {name=[peter]}]
> >>> g.V().valueMap(True,"name").toList()
> [{label=person, name=[marko], id=1}, {label=person, name=[vadas], id=2}, 
> {label=software, name=[lop], id=3}, {label=person, name=[josh], id=4}, 
> {label=software, name=[ripple], id=5}, {label=person, name=[peter], id=6}]
> >>>
> 
> Easy peasy lemon squeezy or is there something fundamental I'm missing?
> 
> Marko.
> 
> http://markorodriguez.com
> 
> On Apr 19, 2016, at 2:58 PM, Marko Rodriguez <okramma...@gmail.com> wrote:
> 
>> Hi,
>> 
>> So I downloaded and installed Jython 2.7.0.
>> 
>> This how easy it was to get Gremlin working in Jython.
>> 
>> import sys
>> sys.path.append("/Users/marko/software/tinkerpop/tinkerpop3/gremlin-console/target/apache-gremlin-console-3.2.1-SNAPSHOT-standalone/lib/commons-codec-1.9.jar")
>> sys.path.append("/Users/marko/software/tinkerpop/tinkerpop3/gremlin-console/target/apache-gremlin-console-3.2.1-SNAPSHOT-standalone/lib/commons-configuration-1.10.jar")
>> … lots of jars to add
>> sys.path.append("/Users/marko/software/tinkerpop/tinkerpop3/gremlin-console/target/apache-gremlin-console-3.2.1-SNAPSHOT-standalone/ext/tinkergraph-gremlin/lib/tinkergraph-gremlin-3.2.1-SNAPSHOT.jar")
>> 
>> from org.apache.tinkerpop.gremlin.tinkergraph.structure import TinkerFactory
>> graph = TinkerFactory.createModern()
>> g = graph.traversal()
>> g
>> g.V().hasLabel("person").out("knows").out("created")
>> g.V().hasLabel("person").out("knows").out("created").toList()
>> 
>> Then, the output looks like this:
>> 
>> >>> from org.apache.tinkerpop.gremlin.tinkergraph.structure import 
>> >>> TinkerFactory
>> >>> graph = TinkerFactory.createModern()
>> >>> g = graph.traversal()
>> >>> g
>> graphtraversalsource[tinkergraph[vertices:6 edges:6], standard]
>> >>> g.V().hasLabel("person").out("knows").out("created")
>> [GraphStep(vertex,[]), HasStep([~label.eq(person)]), 
>> VertexStep(OUT,[knows],vertex), VertexStep(OUT,[created],vertex)]
>> >>> g.V().hasLabel("person").out("knows").out("created").toList()
>> [v[5], v[3]]
>> 
>> Note that, of course, Jython's command line doesn't auto-iterate traversals. 
>> Besides that -- sheez, that was simple.
>> 
>> The trick now is to use Jython idioms to make Gremlin-Jython be comfortable 
>> to Python users…
>> 
>> Marko.
>> 
>> http://markorodriguez.com
>> 
>> On Apr 19, 2016, at 11:43 AM, Marko Rodriguez <okramma...@gmail.com> wrote:
>> 
>>> Hi,
>>> 
>>> So I just pushed:
>>>     
>>> https://git1-us-west.apache.org/repos/asf?p=incubator-tinkerpop.git;a=commitdiff;h=0beae616
>>> 
>>> This should help provide the scaffolding for the tutorial. Given that I 
>>> know nothing about Python, I think my contributions start to fall off 
>>> significantly here. :) … Well, I can help and write more text, I just don't 
>>> know how to use Jython, Python idioms, Gremlinpy, etc…..
>>> 
>>> @Mark/Dylan: If you want to build the tutorial and look at it, you simple 
>>> do:
>>> 
>>>     $ bin/process-docs.sh --dryRun
>>> 
>>> And then for me, the URI to which I point my browser for the index.html on 
>>> my local computer is:
>>> 
>>>     
>>> file:///Users/marko/software/tinkerpop/tinkerpop3/target/docs/htmlsingle/tutorials/gremlin-language-variants/index.html
>>> 
>>> Marko.
>>> 
>>> http://markorodriguez.com
>>> 
>>> On Apr 19, 2016, at 9:16 AM, Marko Rodriguez <okramma...@gmail.com> wrote:
>>> 
>>>> Hello (NOTE: I dropped gremlin-users@),
>>>> 
>>>> Thank you Stephen. Its crazy how simple that is :D.
>>>>    https://twitter.com/apachetinkerpop/status/722432843360546816 
>>>> 
>>>> So Mark, now your fork's TINKERPOP-1232/ branch and 
>>>> https://github.com/apache/incubator-tinkerpop/tree/TINKERPOP-1232 exist 
>>>> and we can keep them sync'd accordingly as we develop this tutorial. When 
>>>> we feel that the tutorial is ready for primetime, we will issue a PR to 
>>>> have it merged into tp31/ (and thus, up merged to master/).
>>>> 
>>>> Where do we go from here? I think this is a good opportunity to work both 
>>>> on Gremlinpy and the tutorial. Can we make Gremlinpy as true to the spirit 
>>>> of "host language embedding" as possible? In doing so, can we explain how 
>>>> we did it so other language providers can learn the best practices?
>>>> 
>>>> In the tutorial we have 3 models we want to promote:
>>>> 
>>>>    1. Jython
>>>>    2. Python JINI
>>>>    3. Python String
>>>> 
>>>> (1) is easy to knock off. In fact, we should ask Michael Pollmeier for 
>>>> advice here given his work on Gremlin-Scala. (2) -- ?? do you know how do 
>>>> this? If so, it should be only fairly more difficult than (1). Finally, 
>>>> (3) is the big win and where I think most of the work both in the tutorial 
>>>> and in Gremlinpy will happen.
>>>> 
>>>> How do you propose we proceed?
>>>> 
>>>> Thank you,
>>>> Marko.
>>>> 
>>>> http://markorodriguez.com
>>>> 
>>>> On Apr 19, 2016, at 8:24 AM, Stephen Mallette <spmalle...@gmail.com> wrote:
>>>> 
>>>>> ok - done: 
>>>>> https://github.com/apache/incubator-tinkerpop/tree/TINKERPOP-1232
>>>>> 
>>>>> On Tue, Apr 19, 2016 at 9:41 AM, Marko Rodriguez <okramma...@gmail.com> 
>>>>> wrote:
>>>>> Hello,
>>>>> 
>>>>> *** Mark, if you are not on dev@tinkerpop, I would recommend joining that 
>>>>> as I will drop gremlin-users@ from communication on this ticket from here 
>>>>> on out. ***
>>>>> 
>>>>> @Stephen: Mark forked the TinkerPop repository to his GitHub account. I 
>>>>> believe he gave you access as well as me.
>>>>> 
>>>>> Can you create a new stub tutorial for Mark+Dylan+me? (Moving forward, I 
>>>>> will learn how to do it from your one commit).
>>>>> 
>>>>>   gremlin-language-variants/
>>>>> 
>>>>> After that Mark+Dylan+me will go to town on:
>>>>>   https://issues.apache.org/jira/browse/TINKERPOP-1232
>>>>> 
>>>>> Thank you,
>>>>> Marko.
>>>>> 
>>>>> http://markorodriguez.com
>>>>> 
>>>>> Begin forwarded message:
>>>>> 
>>>>>> From: Mark Henderson <nore...@github.com>
>>>>>> Subject: emehrkay added you to incubator-tinkerpop
>>>>>> Date: April 15, 2016 10:04:54 AM MDT
>>>>>> To: "Marko A. Rodriguez" <okramma...@gmail.com>
>>>>>> 
>>>>>> You can now push to this repository.
>>>>>> 
>>>>>> ---
>>>>>> View it on GitHub:
>>>>>> https://github.com/emehrkay/incubator-tinkerpop
>>>>> 
>>>>> 
>>>>> -- 
>>>>> You received this message because you are subscribed to the Google Groups 
>>>>> "Gremlin-users" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>>>> email to gremlin-users+unsubscr...@googlegroups.com.
>>>>> To view this discussion on the web visit 
>>>>> https://groups.google.com/d/msgid/gremlin-users/18A7D2FD-B9B1-4DC9-980B-66A6A8F9C7C8%40gmail.com.
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>> 
>>>>> 
>>>>> -- 
>>>>> You received this message because you are subscribed to the Google Groups 
>>>>> "Gremlin-users" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>>>> email to gremlin-users+unsubscr...@googlegroups.com.
>>>>> To view this discussion on the web visit 
>>>>> https://groups.google.com/d/msgid/gremlin-users/CAA-H43990bN1xrtkL%2BWW4Z%3DKY-bhamBuunpzmYcqVxniyv3NOw%40mail.gmail.com.
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>> 
>>> 
>> 
> 

Reply via email to