spmallette
spmallette
ATApache TinkerPop
Created by salman_walmart on 8/12/2024 in #questions
logging and alerting inside a gremlin step
you'll likely not be able to completely avoid ConcurrentModificationException situations. You can only hope to limit them. Usually implementing a simply automatic retry system with exponential backoff will solve the problem.
15 replies
ATApache TinkerPop
Created by b4lls4ck on 8/22/2024 in #questions
How to speed up gremlin query
at a minimum, i would think an index on your "name" property would help if you didn't have one. then, possibly a vertex centric index for the "weight" could help speed your query depending on how many edges you're dealing with that lead away from "Bob".
5 replies
ATApache TinkerPop
Created by b4lls4ck on 8/22/2024 in #questions
How to speed up gremlin query
I read that I should create a composite index to improve speed and performance or something of that sort, but I am unfamiliar with how to do that in Python.
as a point of clarification around indices, you wouldn't likely do that step with python. you typically use gremlinpython just to write Gremlin. For index management, you need to use JanusGraph's APIs directly. often those are just commands you would execute directly in Gremlin Console against a JanusGraph instance.
5 replies
ATApache TinkerPop
Created by salman_walmart on 8/12/2024 in #questions
logging and alerting inside a gremlin step
i think the best you can really do is to return something in your results to tell you what happened. something like:
...fold().
coalesce(unfold().project('v','status').
by().by(constant('found')),
addV().project('v','status').
by().by(constant('created')))...
...fold().
coalesce(unfold().project('v','status').
by().by(constant('found')),
addV().project('v','status').
by().by(constant('created')))...
15 replies
ATApache TinkerPop
Created by salman_walmart on 8/12/2024 in #questions
logging and alerting inside a gremlin step
i'm not sure that even works exactly as you want because next() isn't telling the server you want one more object. the call to next() is saying give me the next item that is in my client-side result set (i.e. the results are streaming from the server as soon as you call next() in the first place). are you just trying to tell if the shell flight was created or updated so that you can log that?
15 replies
ATApache TinkerPop
Created by salman_walmart on 8/12/2024 in #questions
logging and alerting inside a gremlin step
Neptune definitely does not offer a way to do that sort of thing since it doesn't support closures (i.e. lambdas). fail() is the closest thing there is. you can sort of use constant() to some degree, but that implies that you are able to get a result back to work with the constant(). i dont think there are options to do a side-effect like that. this might be a good use case for Neptune to consider for call() perhaps, where Neptune could write to logs you could view in aws console. @Dave what do you think?
15 replies
ATApache TinkerPop
Created by salman_walmart on 8/12/2024 in #questions
logging and alerting inside a gremlin step
Since you are getting a "Server error" I assume you are using Gremlin in a remote context. I'd further assume you are not sending a script to the server, but are using bytecode or are using a graph like Amazon Neptune. Those assumptions all point to the fact that you can't use a lambda that way in remote contexts. The approach you are using to write your lambda is for embedded use cases only (i.e. where query is executed in the same JVM where it was created). If you want to send a lambda remotely you would need to have a server that supports them (e.g. Neptune does not, but Gremlin Server with Groovy ScriptEngine processing does) and then follow these instructions: https://tinkerpop.apache.org/docs/current/reference/#gremlin-java-lambda The other thing to consider is that the lambda will be executed remotely so it might not know what "logger" is and the log message will appear on the server note the client. Gremlin doesn't have a better way to really do what you are trying to do. I've often thought a debug() or print() step might be helpful in some way, but we've never gotten around to building that.
15 replies
ATApache TinkerPop
Created by spmallette on 7/12/2024 in #questions
neo4j-gremlin not working with JDK17
we only build to jdk17 (though 11/8) should still work
7 replies
ATApache TinkerPop
Created by spmallette on 7/12/2024 in #questions
neo4j-gremlin not working with JDK17
should be made easier in Gremlin Console usage of Neo4j with: https://github.com/apache/tinkerpop/commit/4d9347088d0ec0e5f5d87ab78358d687620ca4d5 which detects JDK17 and inserts the flag.
7 replies
ATApache TinkerPop
Created by supercoal on 5/7/2024 in #questions
Gremlin with AWS Neptune
note that Neptune 1.3.2.1 now supports the functionality of TinkerPop 3.7.x. You can read more about it at https://aws.amazon.com/blogs/database/exploring-new-features-of-apache-tinkerpop-3-7-x-in-amazon-neptune/
6 replies
ATApache TinkerPop
Created by spmallette on 7/12/2024 in #questions
neo4j-gremlin not working with JDK17
This issue relates back to: https://tinkerpop.apache.org/docs/current/upgrade/#_building_and_running_with_jdk_17 and the need to add this JVM option:
--add-opens=java.base/sun.nio.ch=ALL-UNNAMED
7 replies
ATApache TinkerPop
Created by b4lls4ck on 7/9/2024 in #questions
I am unsure on how to use Python to add graphs to JanusGraph
a minor point but this line:
e = g.V(v1).add_e("knows").to(v2).iterate()
e = g.V(v1).add_e("knows").to(v2).iterate()
should probably just be:
g.V(v1).add_e("knows").to(v2).iterate()
g.V(v1).add_e("knows").to(v2).iterate()
the iterate() termination step really doesn't have a return value. i suppose that technically it returns the current Traversal object that would already be iterated to its end and no longer server a purpose, but that' sit. other than that, it looks like your code is working except for that. maybe you could try closing some resources before exiting?
...

rc = DriverRemoteConnection('ws://localhost:8182/gremlin','g',message_serializer=JanusGraphSONSerializersV3d0())
g = traversal().with_remote(rc)

...

rc.close()
...

rc = DriverRemoteConnection('ws://localhost:8182/gremlin','g',message_serializer=JanusGraphSONSerializersV3d0())
g = traversal().with_remote(rc)

...

rc.close()
42 replies
ATApache TinkerPop
Created by b4lls4ck on 7/9/2024 in #questions
I am unsure on how to use Python to add graphs to JanusGraph
So I would say that my python script is connecting to JanusGraph as opposed to the Gremlin Server
just to get the wording right for clarity, you are running Janus Server in that docker container, and therefore you are connecting to Gremln Server hosting a JanusGraph instance.
Is there any way of starting a JanusGraph server in Windows?
maybe someone from @janusgraph can provide some more details on Windows and for your other question on the KeyError you mentioned here: https://discord.com/channels/838910279550238720/1260358985974812743/1260401279520473108 I assume the KeyError has something to do with serialization. perhaps you need this add-on: https://github.com/JanusGraph/janusgraph-python
42 replies
ATApache TinkerPop
Created by b4lls4ck on 7/9/2024 in #questions
I am unsure on how to use Python to add graphs to JanusGraph
is that connecting to JanusGraph? or are you still working with Gremlin Server and TinkerGraph? also, some python examples here: https://github.com/apache/tinkerpop/tree/master/gremlin-python/src/main/python/examples
42 replies
ATApache TinkerPop
Created by b4lls4ck on 7/9/2024 in #questions
I am unsure on how to use Python to add graphs to JanusGraph
the termination step goes on the traversal itself to tell itbhow to iterate
42 replies
ATApache TinkerPop
Created by b4lls4ck on 7/9/2024 in #questions
I am unsure on how to use Python to add graphs to JanusGraph
its like g.V()....next()
42 replies
ATApache TinkerPop
Created by b4lls4ck on 7/9/2024 in #questions
I am unsure on how to use Python to add graphs to JanusGraph
regarding your question on cassandra, technically your data is in cassandra but i think its encoded so you wont be able to really see it directly
42 replies
ATApache TinkerPop
Created by b4lls4ck on 7/9/2024 in #questions
I am unsure on how to use Python to add graphs to JanusGraph
you dont usually do this in Gremlin Console because it automatically does that stuff for you
42 replies
ATApache TinkerPop
Created by b4lls4ck on 7/9/2024 in #questions
I am unsure on how to use Python to add graphs to JanusGraph
typically most times you will use to_list()
42 replies
ATApache TinkerPop
Created by b4lls4ck on 7/9/2024 in #questions
I am unsure on how to use Python to add graphs to JanusGraph
you need a terminal step to make that happen. i your case you would add next() to take the first item from the traversal (ie the new vertex)
42 replies