[
https://issues.apache.org/jira/browse/TINKERPOP-2294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16932572#comment-16932572
]
stephen mallette commented on TINKERPOP-2294:
---------------------------------------------
> How would this translate to python code?
That example is:
1. Specific to JanusGraph and specific to IBM Compose. It uses both
{{ConfiguredGraphFactory}} which is bound to JanusGraph and {{ToInputStream}}
which I assume is a function of Compose. That won't work on a raw Gremlin
Server so unless you're using that service then that won't work for you.
2. Uses the old {{graph.io()}} API which is now deprecated
So, rather than dwell on that example, let's just say what you should do. As I
expressed in my previous comment, you have two options:
1. [Send a
script|http://tinkerpop.apache.org/docs/current/reference/#_submitting_scripts_2]
from Python that uses that {{graph.io()}} API
2. Use the {{io()}} Gremlin [step
|http://tinkerpop.apache.org/docs/current/reference/#io-step]
For (1) that just means:
{code}
client = client.Client('ws://localhost:8182/gremlin', 'g')
client.submit("graph.io(IoCore.graphml()).readGraph('file.xml')")
{code}
With scripts you can basically get access to the entire TinkerPop API (along
with all of Groovy/Java related libraries on the server) so you can do what you
want there without too many restrictions. Note that "file.xml" is expected to
be available on the server path (which is probably why Compose built the
{ToInputStream()}} add-on function in their service.
To avoid scripts, which is better, we can just use the Gremlin {{io()}} step
which replaces the above functionality (this of course could also be submitted
as a script but why bother if we can just use native python).
{code}
g =
traversal().withRemote(DriverRemoteConnection('ws://localhost:8182/gremlin','g'))
g.io("file.xml").read().iterate()
{code}
again - that "file.xml" should be accessible by the server. Note that aside
from the construction of "g", Gremlin is just Gremlin. There really is no
Python way versus Java way versus Groovy way. It's just Gremlin.
{{g.io("file.xml").read().iterate()}} is the same in all of those languages so
you can just refer to the standard list of steps to determine how to use them
no matter what language you use:
http://tinkerpop.apache.org/docs/current/reference/#traversal
> In the gremlin console a command like :remote connect tinkerpop.server
> conf/remote.yaml is possible. What would be the equivalent in python?
there is no equivalent in python. {{:remote}} is a console command:
http://tinkerpop.apache.org/docs/current/reference/#_console_commands
> My current understanding is the server needs to be restarted with a different
> yaml file to get this effect. That is why i am asking for some kind of API to
> automate this.
Right, that feature is not available in Gremlin Server, but different graph
systems that implement the Gremlin Server protocol do allow for that. I believe
that the JanusGraph {{ConfiguredGraphFactory}} referenced in your commented
above is designed to help do that for their system. DSE Graph has a mechanism
for it, as do the other remote graph providers like CosmosDB and Neptune. I
think Gremlin Server has evolved into more of a reference implementation for
the protocol. While it can be used to serve production graphs it seems like
major graph providers are mostly interested in the protocol itself, so I'm not
sure that adding that kind of major feature at this point is worthwhile.
> Gremlin-Python usability and tutorial
> -------------------------------------
>
> Key: TINKERPOP-2294
> URL: https://issues.apache.org/jira/browse/TINKERPOP-2294
> Project: TinkerPop
> Issue Type: Improvement
> Components: python
> Affects Versions: 3.4.3
> Reporter: Wolfgang Fahl
> Priority: Major
>
> The Gremlin-Python environment is not useable "out of the box" at this time
> and hard to configure. It needs a specially configured gremlin-server for
> each use case.
> The handling of the server configuration and startup could be simplified if
> it would be done by some kind of API instead of the YAML file. Especially it
> is important to make graph io available to be able to create python specific
> tutorials that are based on typical databases. The handling of typical
> backend database configurations should be simplified.
>
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)