How may one connect to a graph with the gremlinpython package when there are multiple graphs created with ConfiguredGraphFactory.create("<graphname>")?
when trying to connect with graph air_routes,
g = graph.traversal().withRemote(DriverRemoteConnection('ws://localhost:8182', 'air_routes'))
I encountered the error below
gremlin_python.driver.protocol.GremlinServerError: 499: The traversal source [air_routes] for alias [g] is not configured on the server.
it works with a single graph config using the following code
g = graph.traversal().withRemote(DriverRemoteConnection('ws://localhost:8182', 'g'))
Hi,
The issue is your gremlin server did not know your traversal.
I think that you did not define your traversal in the groovy file of your gremlin server.
The default traversal is "injected" in the scope thanks to the empty-sample.groovy script:
globals << [g : graph.traversal()]
The script is loaded when the Gremlin server starts because of this line in the configuration gremlin-server.yaml
scriptEngines: {
gremlin-groovy: {
imports: [java.lang.Math],
staticImports: [java.lang.Math.PI],
scripts: [scripts/empty-sample.groovy]}}
If you want to connect to multiple graphs from Python, you will need two things:
Graph instances in gremlin-server.yamlgraphs: {
graph1: conf/gremlin-server/graph1.properties,
graph2: conf/gremlin-server/graph2.properties
}
empty-sample.groovy to load multiple graph traversals, one for each of your Graph instancesglobals << [g1 : graph1.traversal(), g2: graph2.traversal()]
Then in Python
g1 = graph.traversal().withRemote(DriverRemoteConnection('ws://localhost:8182', 'g1'))
g2 = graph.traversal().withRemote(DriverRemoteConnection('ws://localhost:8182', 'g2'))
I have wrote a complete walk through on how to connect to JanusGraph from Python here
Hope this helps
@benoitguigal would you be interested in contributing some of the knowledge from your blog towards improving the documentation around configuring the Gremlin Server for the Python GLV?
@zhiboz I am facing the same issue. Were you able to find a solution?
@benoitguigal I tried changing as per your comments above but still get the same error.
Below are the changes I made:
Added a new file in /conf 'graph1.properties' :-
gremlin.graph=org.janusgraph.core.ConfiguredGraphFactory
storage.backend=cql
graph.graphname=airroutes
storage.hostname=127.0.0.1
cache.db-cache = true
cache.db-cache-clean-wait = 20
cache.db-cache-time = 180000
cache.db-cache-size = 0.5
Update graphs in gremlin-server.yaml as:-
graphs: {
ConfigurationManagementGraph: conf/janusgraph-cql-configurationgraph.properties,graph1: conf/graph1.properties
}
Updated empty-sample.groovy as:-
globals << [g : graph.traversal(), g1 : graph1.traversal()]
When I query for available graphs from gremlin console I get below results:-
gremlin> ConfiguredGraphFactory.getGraphNames()
==>airroutes
Below is the python code to connect to the server:-
from gremlin_python.structure.graph import Graph
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
graph = Graph()
g = graph.traversal().withRemote(DriverRemoteConnection('ws://localhost:8182/gremlin','g1'))
g.V().count().next()
the last command gives below error:-
gremlin_python.driver.driver_remote_connection.GremlinServerError: 499: The traversal source [g1] for alias [g] is not configured on the server.
I am not sure what I am missing here. Can you please help me with this?
@akshitbhatnagar2008 Did you work this out?
@syseeker not yet...I had to go back to older version of Janusgraph for it to work.
So, no solution for this yet?
You can refer to my configuration
https://github.com/JanusGraph/janusgraph/issues/1299#issuecomment-455479457
To prevent confusion we have recently added a default template for new issues containing the guidelines as to what belongs in issues. Usage, configuration, and general questions should be asked in gitter, stackoverflow, or the janusgraph-users google group. Github issues are for reporting bugs, requesting new features, and tracking the development of JanusGraph. If your issue is still outstanding please consult one of the communities mentioned. If you still feel like your issue belongs here and was closed in error please feel free to repoen it.
@benoitguigal I am not able to use this for ConfiguredGraphFactory
globals << [g1 : graph1.traversal(), g2: ConfigurationManagementGraph.traversal()]
It seems to not work with 'ConfigurationManagementGraph' (https://github.com/JanusGraph/janusgraph/blob/master/docs/configuredgraphfactory.adoc)
I get this error
java.lang.IllegalStateException: javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: static org.janusgraph.graphdb.management.ConfigurationManagementGraph.traversal() is applicable for argument types: () values: []
at org.apache.tinkerpop.gremlin.jsr223.DefaultGremlinScriptEngineManager.lambda$createGremlinScriptEngine$16(DefaultGremlinScriptEngineManager.java:464)
at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:270)
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
at org.apache.tinkerpop.gremlin.jsr223.DefaultGremlinScriptEngineManager.createGremlinScriptEngine(DefaultGremlinScriptEngineManager.java:450)
at org.apache.tinkerpop.gremlin.jsr223.DefaultGremlinScriptEngineManager.getEngineByName(DefaultGremlinScriptEngineManager.java:219)
at org.apache.tinkerpop.gremlin.jsr223.CachedGremlinScriptEngineManager.lambda$getEngineByName$0(CachedGremlinScriptEngineManager.java:57)
at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
at org.apache.tinkerpop.gremlin.jsr223.CachedGremlinScriptEngineManager.getEngineByName(CachedGremlinScriptEngineManager.java:57)
at org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.lambda$eval$0(GremlinExecutor.java:263)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: static org.janusgraph.graphdb.management.ConfigurationManagementGraph.traversal() is applicable for argument types: () values: []
at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine.eval(GremlinGroovyScriptEngine.java:397)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
at org.apache.tinkerpop.gremlin.jsr223.DefaultGremlinScriptEngineManager.lambda$createGremlinScriptEngine$16(DefaultGremlinScriptEngineManager.java:460)
... 24 more
Caused by: javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: static org.janusgraph.graphdb.management.ConfigurationManagementGraph.traversal() is applicable for argument types: () values: []
at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine.eval(GremlinGroovyScriptEngine.java:713)
at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine.eval(GremlinGroovyScriptEngine.java:395)
... 26 more
Caused by: groovy.lang.MissingMethodException: No signature of method: static org.janusgraph.graphdb.management.ConfigurationManagementGraph.traversal() is applicable for argument types: () values: []
at groovy.lang.MetaClassImpl.invokeStaticMissingMethod(MetaClassImpl.java:1518)
at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1504)
at org.codehaus.groovy.runtime.callsite.StaticMetaClassSite.call(StaticMetaClassSite.java:52)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
at Script1.run(Script1.groovy:16)
at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine.eval(GremlinGroovyScriptEngine.java:690)
... 27 more
15015 [main] WARN org.apache.tinkerpop.gremlin.server.util.ServerGremlinExecutor - Could not initialize gremlin-groovy GremlinScriptEngine as init script could not be evaluated
java.util.concurrent.CompletionException: java.lang.IllegalArgumentException: gremlin-groovy is not an available GremlinScriptEngine
at java.util.concurrent.CompletableFuture.reportJoin(CompletableFuture.java:375)
at java.util.concurrent.CompletableFuture.join(CompletableFuture.java:1934)
at org.apache.tinkerpop.gremlin.server.util.ServerGremlinExecutor.lambda$new$4(ServerGremlinExecutor.java:141)
at java.util.LinkedHashMap$LinkedKeySet.forEach(LinkedHashMap.java:559)
at org.apache.tinkerpop.gremlin.server.util.ServerGremlinExecutor.<init>(ServerGremlinExecutor.java:136)
at org.apache.tinkerpop.gremlin.server.GremlinServer.<init>(GremlinServer.java:120)
at org.apache.tinkerpop.gremlin.server.GremlinServer.<init>(GremlinServer.java:84)
at org.apache.tinkerpop.gremlin.server.GremlinServer.main(GremlinServer.java:343)
Caused by: java.lang.IllegalArgumentException: gremlin-groovy is not an available GremlinScriptEngine
at org.apache.tinkerpop.gremlin.jsr223.CachedGremlinScriptEngineManager.registerLookUpInfo(CachedGremlinScriptEngineManager.java:95)
at org.apache.tinkerpop.gremlin.jsr223.CachedGremlinScriptEngineManager.getEngineByName(CachedGremlinScriptEngineManager.java:58)
at org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.lambda$eval$0(GremlinExecutor.java:263)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
@benoitguigal I am not able to use this for ConfiguredGraphFactory
globals << [g1 : graph1.traversal(), g2: ConfigurationManagementGraph.traversal()]It seems to not work with 'ConfigurationManagementGraph' (https://github.com/JanusGraph/janusgraph/blob/master/docs/configuredgraphfactory.adoc)
I get this errorjava.lang.IllegalStateException: javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: static org.janusgraph.graphdb.management.ConfigurationManagementGraph.traversal() is applicable for argument types: () values: [] at org.apache.tinkerpop.gremlin.jsr223.DefaultGremlinScriptEngineManager.lambda$createGremlinScriptEngine$16(DefaultGremlinScriptEngineManager.java:464) at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382) at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580) at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:270) at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) at org.apache.tinkerpop.gremlin.jsr223.DefaultGremlinScriptEngineManager.createGremlinScriptEngine(DefaultGremlinScriptEngineManager.java:450) at org.apache.tinkerpop.gremlin.jsr223.DefaultGremlinScriptEngineManager.getEngineByName(DefaultGremlinScriptEngineManager.java:219) at org.apache.tinkerpop.gremlin.jsr223.CachedGremlinScriptEngineManager.lambda$getEngineByName$0(CachedGremlinScriptEngineManager.java:57) at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660) at org.apache.tinkerpop.gremlin.jsr223.CachedGremlinScriptEngineManager.getEngineByName(CachedGremlinScriptEngineManager.java:57) at org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.lambda$eval$0(GremlinExecutor.java:263) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: static org.janusgraph.graphdb.management.ConfigurationManagementGraph.traversal() is applicable for argument types: () values: [] at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine.eval(GremlinGroovyScriptEngine.java:397) at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264) at org.apache.tinkerpop.gremlin.jsr223.DefaultGremlinScriptEngineManager.lambda$createGremlinScriptEngine$16(DefaultGremlinScriptEngineManager.java:460) ... 24 more Caused by: javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: static org.janusgraph.graphdb.management.ConfigurationManagementGraph.traversal() is applicable for argument types: () values: [] at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine.eval(GremlinGroovyScriptEngine.java:713) at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine.eval(GremlinGroovyScriptEngine.java:395) ... 26 more Caused by: groovy.lang.MissingMethodException: No signature of method: static org.janusgraph.graphdb.management.ConfigurationManagementGraph.traversal() is applicable for argument types: () values: [] at groovy.lang.MetaClassImpl.invokeStaticMissingMethod(MetaClassImpl.java:1518) at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1504) at org.codehaus.groovy.runtime.callsite.StaticMetaClassSite.call(StaticMetaClassSite.java:52) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120) at Script1.run(Script1.groovy:16) at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine.eval(GremlinGroovyScriptEngine.java:690) ... 27 more 15015 [main] WARN org.apache.tinkerpop.gremlin.server.util.ServerGremlinExecutor - Could not initialize gremlin-groovy GremlinScriptEngine as init script could not be evaluated java.util.concurrent.CompletionException: java.lang.IllegalArgumentException: gremlin-groovy is not an available GremlinScriptEngine at java.util.concurrent.CompletableFuture.reportJoin(CompletableFuture.java:375) at java.util.concurrent.CompletableFuture.join(CompletableFuture.java:1934) at org.apache.tinkerpop.gremlin.server.util.ServerGremlinExecutor.lambda$new$4(ServerGremlinExecutor.java:141) at java.util.LinkedHashMap$LinkedKeySet.forEach(LinkedHashMap.java:559) at org.apache.tinkerpop.gremlin.server.util.ServerGremlinExecutor.<init>(ServerGremlinExecutor.java:136) at org.apache.tinkerpop.gremlin.server.GremlinServer.<init>(GremlinServer.java:120) at org.apache.tinkerpop.gremlin.server.GremlinServer.<init>(GremlinServer.java:84) at org.apache.tinkerpop.gremlin.server.GremlinServer.main(GremlinServer.java:343) Caused by: java.lang.IllegalArgumentException: gremlin-groovy is not an available GremlinScriptEngine at org.apache.tinkerpop.gremlin.jsr223.CachedGremlinScriptEngineManager.registerLookUpInfo(CachedGremlinScriptEngineManager.java:95) at org.apache.tinkerpop.gremlin.jsr223.CachedGremlinScriptEngineManager.getEngineByName(CachedGremlinScriptEngineManager.java:58) at org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.lambda$eval$0(GremlinExecutor.java:263) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)
e.g. g = traversal().withRemote(DriverRemoteConnection.using("tinkerpop/remote-objects.yaml", "ig_traversal"))
see
https://docs.janusgraph.org/basics/configured-graph-factory/#graph-and-traversal-bindings
https://docs.janusgraph.org/basics/multi-node/#dynamic-graph-and-traversal-bindings
english is not good
I think you will understand.
@wjtien it failed me to auto generate xx_traversal when it comes to docker env, do you use docker for this?
Most helpful comment
The default traversal is "injected" in the scope thanks to the
empty-sample.groovyscript:The script is loaded when the Gremlin server starts because of this line in the configuration
gremlin-server.yamlIf you want to connect to multiple graphs from Python, you will need two things:
Graphinstances ingremlin-server.yamlempty-sample.groovyto load multiple graph traversals, one for each of yourGraphinstancesThen in Python
I have wrote a complete walk through on how to connect to JanusGraph from Python here
Hope this helps