Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: 'range' #216

Open
echennh-zz opened this issue May 12, 2022 · 5 comments
Open

KeyError: 'range' #216

echennh-zz opened this issue May 12, 2022 · 5 comments

Comments

@echennh-zz
Copy link

In the __init_statics() method of GremlinUtils in neptune_python_utils/gremlin_utils.py, the code:


leads to a KeyError if the global doesn't already exist. I believe this should be changed to:

        globs_to_delete = ['range', 'map', 'min', 'sum', 'property', 'max']

        for glob in globs_to_delete:
            if glob in globals:
                del globals[glob]

which has patched the problem in my app's version of neptune_python_utils.

@krlawrence
Copy link
Contributor

krlawrence commented May 12, 2022

There was a change made in Apache TinkerPop 3.6. In that release of the Python client all the names of Gremlin steps that conflict with Python reserved words were removed and replaced with ones of the form range_. In the 3.5.x TinkerPop versions both forms existed (eg range and range_) but the range form was declared deprecated. I think the gremlin_utils.py code needs to probably be version aware and not even try to delete any globals if the gremlin-python version is 3.6.0 or higher. Thanks for pointing out this issue.

@krlawrence
Copy link
Contributor

The version of the client can be checked using something like this:

from gremlin_python import __version__ as gremv
print(gremv.version)

@iowusu
Copy link

iowusu commented Jun 24, 2022

I am getting the same error. Client version 3.6.0

@iowusu
Copy link

iowusu commented Jun 24, 2022

it looks like this update get you pass this error

del globals['range_']
del globals['map']
del globals['min']
del globals['sum_']
del globals['property']
 del globals['max_']

@hungnguyendinh1999
Copy link

I'm not sure how to bypass this error. Temporarily I'm doing this (very bad) practice which seems to work. Highly NOT recommended.

globs_to_delete = ['range', 'map', 'min', 'sum', 'property', 'max']

for glob in globs_to_delete:
    if glob not in globals():
        globals()[glob] = glob

GremlinUtils.init_statics(globals())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants