Skip to content

Instantly share code, notes, and snippets.

@lmeyerov
Created July 9, 2021 20:11
Show Gist options
  • Save lmeyerov/459f6f0360abea787909c7c8c8f04cee to your computer and use it in GitHub Desktop.
Save lmeyerov/459f6f0360abea787909c7c8c8f04cee to your computer and use it in GitHub Desktop.
Handling gremlin_python, Neptune async version issues

Handle gremlinpython, Neptune, jupyter, tornado version issues

Different Neptune versions support different gremlin_python versions, and different gremlin_python versions may require workarounds for Python asyncio / Jupyter's builtin Tornado client.

As needed, use the below workarounds. If installing packages, remember to restart your Python kernel (kernel -> restart) before continuing

Graphistry maintains versions that should work for latest known in both its main distributions, GPU base Docker containers, and graph-app-kit Streamlit dashboarding containers

Pick a gremlin_python version that is Neptune-compatible

Version matching: https://docs.aws.amazon.com/neptune/latest/userguide/access-graph-gremlin-client.html

Inspect your versions:

! pip show gremlinpython tornado graphistry | grep 'Name\|Version'

Switch:

! pip install --user gremlinpython==3.4.10

Workarounds for gremlinpython / tornado async event loop conflicts

gremlinpython (versions < 3.5.0) gets confused by multiple event loops such as jupyter's use of tornado. This is supposed to be better in gremlinpython 3.5.0+ which switches to asyncio, but at the time of writing, Neptune does not officially support it.

Approaches:

Downgrade tornado and gremlin

! pip install --user tornado==4.5.3

enable loop nesting

import nest_asyncio
nest_asyncio.apply()

start a new loop

import asyncio
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment