Using a SeedStrategy in javascript to control shuffle.

On my project we are trying to select random vertices from the graph and use a seed to keep the results predictable. The docs mention passing in a SeedStrategy like so:
seedStrategy = new SeedStrategy(999998L)
g.withStrategies(seedStrategy).V().values('name').fold().order(local).by(shuffle)
seedStrategy = new SeedStrategy(999998L)
g.withStrategies(seedStrategy).V().values('name').fold().order(local).by(shuffle)
However we are unable to figure out the import for the SeedStrategy class. We have tried on Gremlin version 3.4.6 and 3.6.2 and both seem to be missing SeedStrategy. Are there any know issues with strategies in javascript or alternate ways of seeding randomness in Gremlin? We have currently tried exploring the properties of the gremlin.process. Importing it off of the process object. We can get a generic "traversalStrategy" however that doesn't seem to have the one we are looking for. const foo = gremlin.process.TraversalStrategy // valid const foo = gremlin.process.SeedStrategy // invalid We are using the following packages: Typescript types: https://www.npmjs.com/package/@types/gremlin Gremlin NPM package: https://www.npmjs.com/package/gremlin
npm
@types/gremlin
TypeScript definitions for gremlin. Latest version: 3.6.0, last published: 8 months ago. Start using @types/gremlin in your project by running npm i @types/gremlin. There are 7 other projects in the npm registry using @types/gremlin.
npm
gremlin
JavaScript Gremlin Language Variant. Latest version: 3.6.2, last published: 2 months ago. Start using gremlin in your project by running npm i gremlin. There are 86 other projects in the npm registry using gremlin.
S
spmallette390d ago
SeedStrategy landed in 3.5.x i think so it wouldn't be in 3.4.x. i would expect you would find it in 3.6.x though: https://github.com/apache/tinkerpop/blob/3.6.2/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal-strategy.js#L306-L316 Looks like the syntax is more like new SeedStrategy({seed:999999}) for some reason. not sure why we did that. probably a little oversight
GitHub
tinkerpop/traversal-strategy.js at 3.6.2 · apache/tinkerpop
Apache TinkerPop - a graph computing framework. Contribute to apache/tinkerpop development by creating an account on GitHub.
A
arc_rider390d ago
I agree, thats what I would've expected as well. I did notice that in the index.js file the process object only has TraversalStrategies, TraversalStrategy. The other strategies implemented in traversal-strategy.js aren't mentioned. Would we expect to see more of the strategiesModule exported from the index to make them accessible? This file lines 63 and 64 are what I am seeing that makes me think some strategies arent being exported.: https://github.com/apache/tinkerpop/blob/3.6.2/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
GitHub
tinkerpop/index.js at 3.6.2 · apache/tinkerpop
Apache TinkerPop - a graph computing framework. Contribute to apache/tinkerpop development by creating an account on GitHub.
S
spmallette390d ago
I guess the idea was to reference them from traversal-strategy.js - that seems to be how we did that in tests. offhand, i'm not sure if that was an intentional choice of the exports or not. i suppose that could be changed, but i'm not expert on gremlin-javascript.
A
arc_rider390d ago
That makes sense and is all good. We will continue investigating because we can successfully access the other properties of the process object ex: process.cardinality.single . Referencing the strategies directly from traversal-strategy.js is worth trying and that will be the next thing when we get back to work. It is the end of the workday here so any further experiments will have to wait until Monday. We are considering forking the repo and potentially posting a PR if this is something that needs code changes to address. Is there someone we can ask if this behavior is intentional? Also thank you so much for your rapid responses.
S
spmallette390d ago
As this would be your first contribution (i assume), feel free to raise awareness of your question here and the improvement you'd like to make in the #new-contributors channel. We will help guide you to a PR from there.
Want results from more Discord servers?
Add your server
More Posts
Horizontal cache for gremlin server deployment.I have gremlin deployment, which has 3 pods within it. On top of it I have a load balancer to accessworker thread pool of 1, gremlin pool of 1 and boss thread pool of 1 ?Hello - I have an remote gremlin setup backend as cassandra, In my gremlin remote logs I see a log sMultiple next() steps in a traversalIs there a way to exit traversals at different steps? I tried using the `next()` step on a static, btell me writing query this patternvartex(orange): question: {code:string, type: string } vartex(purple):LeaningElement What I want toVersion Update differencesHi guys, We are upgrading from gremlin_python 3.4.11 to 3.6.2. We had some functions break and it What is the ordering of group?For instance (on Tinkerpop modern) g.V().group().by('age').by('name') gives [{32=[josh], 35=[peter],Export to graphml/graphson with PythonHello everyone, I hope this question has not been asked yet, if so I'm sorry for redundant content.Publish all Q&A on the webTo my best knowledge, Discord contents are not indexed by search engine crawlers. If we can export aOut edge of vertex is slowWhen i run this below query: "g.V().has("guid", "6203620951906330066").limit(10).out("matching").proTranslating bytecode into JupyterLabs compatible script.I've found that the gremlin syntax in jupyter is different from every other language, including pythQuery if else in gremlinI have a query and that return a list vertex. I want to do a query from those vertexes like this (ifDoes Gremlin do DFS or BFS?Does Gremlin perform a Depth First Search (DFS) or Breadth First Search (BFS) when traversing?Self-service roles for providers and areas of expertiseWe have roles for providers right now as listed in #roles - they are handed out by moderators. So faMore elaborate sack examples in the docsThere are a few examples for the `sack` step, but it would be good to have a more concrete one. For Isolated vertices vs connected vertices with no join benefitIs there any downside to storing an isolated vertex with references to other nodes? Creating relatioSubgraph Strategy with vertexProperties + project().by("field name") = crashRunning the following query: `g.withStrategies(new SubgraphStrategy(vertexProperties: constant(true)