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:
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/gremlinnpm
@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.5 Replies
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 oversightGitHub
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.
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.jsGitHub
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.
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.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.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.