Constructor parameter should be str in Notebook

0

I have a Python 3 Neptune Notebook. When I try to run a command such as

result = g.V().has('code','test').valueMap().toList()
print('result is ' + str(result))

I get:

~/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/yarl/_url.py in new(cls, val, encoded, strict)
156 val = urlsplit(str(val))
157 else:
--> 158 raise TypeError("Constructor parameter should be str")
159
160 if not encoded:

TypeError: Constructor parameter should be str

This is a new error, these commands worked for the past year or so. This is a similar error I get in python when I use Python 3.8 instead of 3.7 to call Neptune... is it possible for me to change the notebook Python to 3.7?

Edited by: ColinWithMothrazzz on Nov 18, 2021 6:09 AM

Over the past week or so, in order to run a notebook I have been downgrading my notebook using this command:

%%bash
aws s3 cp s3://aws-neptune-notebook/graph_notebook.tar.gz /tmp/graph_notebook.tar.gz
rm -rf /tmp/graph_notebook
tar -zxvf /tmp/graph_notebook.tar.gz -C /tmp
/tmp/graph_notebook/install.sh -v="3.0.6"

to run the code. Now I am unable to downgrade the notebook, when I try I get this:

WARNING: Skipping NeptuneGraphNotebook as it is not installed.
Config option kernel_spec_manager_class not recognized by InstallNBExtensionApp.
Installing /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/gremlin_syntax/static -> gremlin_syntax
Removing: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/gremlin_syntax
Making directory: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/gremlin_syntax/
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/gremlin_syntax/static/init.py -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/gremlin_syntax/init.py
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/gremlin_syntax/static/main.js -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/gremlin_syntax/main.js
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/gremlin_syntax/static/description.yaml -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/gremlin_syntax/description.yaml
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/gremlin_syntax/static/README.md -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/gremlin_syntax/README.md
Making directory: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/gremlin_syntax/pycache
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/gremlin_syntax/static/pycache/init.cpython-36.pyc -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/gremlin_syntax/pycache/init.cpython-36.pyc
- Validating: OK
Installing /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/sparql_syntax/static -> sparql_syntax
Removing: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/sparql_syntax
Making directory: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/sparql_syntax/
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/sparql_syntax/static/init.py -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/sparql_syntax/init.py
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/sparql_syntax/static/main.js -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/sparql_syntax/main.js
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/sparql_syntax/static/description.yaml -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/sparql_syntax/description.yaml
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/sparql_syntax/static/README.md -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/sparql_syntax/README.md
Making directory: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/sparql_syntax/pycache
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/sparql_syntax/static/pycache/init.cpython-36.pyc -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/sparql_syntax/pycache/init.cpython-36.pyc
- Validating: OK
Installing /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/opencypher_syntax/static -> opencypher_syntax
Removing: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/opencypher_syntax
Making directory: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/opencypher_syntax/
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/opencypher_syntax/static/init.py -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/opencypher_syntax/init.py
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/opencypher_syntax/static/main.js -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/opencypher_syntax/main.js
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/opencypher_syntax/static/description.yaml -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/opencypher_syntax/description.yaml
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/opencypher_syntax/static/README.md -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/opencypher_syntax/README.md
Making directory: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/opencypher_syntax/pycache
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/opencypher_syntax/static/pycache/init.cpython-36.pyc -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/opencypher_syntax/pycache/init.cpython-36.pyc
- Validating: OK
Installing /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/neptune_menu/static -> neptune_menu
Removing: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/neptune_menu
Making directory: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/neptune_menu/
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/neptune_menu/static/init.py -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/neptune_menu/init.py
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/neptune_menu/static/main.js -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/neptune_menu/main.js
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/neptune_menu/static/description.yaml -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/neptune_menu/description.yaml
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/neptune_menu/static/README.md -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/neptune_menu/README.md
Making directory: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/neptune_menu/pycache
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/neptune_menu/static/pycache/init.cpython-36.pyc -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/neptune_menu/pycache/init.cpython-36.pyc
- Validating: OK
Installing /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/playable_cells/static -> playable_cells
Removing: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/playable_cells
Making directory: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/playable_cells/
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/playable_cells/static/playable_cells.css -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/playable_cells/playable_cells.css
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/playable_cells/static/init.py -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/playable_cells/init.py
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/playable_cells/static/main.js -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/playable_cells/main.js
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/playable_cells/static/description.yaml -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/playable_cells/description.yaml
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/playable_cells/static/README.md -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/playable_cells/README.md
Making directory: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/playable_cells/pycache
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/playable_cells/static/pycache/init.cpython-36.pyc -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/playable_cells/pycache/init.cpython-36.pyc
- Validating: OK

**To initialize this nbextension in the browser every time the notebook (or other app) loads:**  
  
      **jupyter nbextension enable graph_notebook.nbextensions --py --sys-prefix**  
  

Config option kernel_spec_manager_class not recognized by EnableNBExtensionApp.
Enabling notebook extension gremlin_syntax/main...
- Validating: OK
Enabling notebook extension sparql_syntax/main...
- Validating: OK
Enabling notebook extension opencypher_syntax/main...
- Validating: OK
Enabling notebook extension neptune_menu/main...
- Validating: OK
Enabling notebook extension playable_cells/main...
- Validating: OK
Config option kernel_spec_manager_class not recognized by InstallNBExtensionApp.
Installing /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/widgets/nbextension/static -> graph_notebook_widgets
Out of date: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/graph_notebook_widgets/init.py
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/widgets/nbextension/static/init.py -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/graph_notebook_widgets/init.py
Up to date: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/graph_notebook_widgets/extension.js
Up to date: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/graph_notebook_widgets/index.js
Out of date: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/graph_notebook_widgets/pycache/init.cpython-36.pyc
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/widgets/nbextension/static/pycache/init.cpython-36.pyc -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/graph_notebook_widgets/pycache/init.cpython-36.pyc
- Validating: OK

**To initialize this nbextension in the browser every time the notebook (or other app) loads:**  
  
      **jupyter nbextension enable graph_notebook.widgets --py --sys-prefix**  
  

Config option kernel_spec_manager_class not recognized by EnableNBExtensionApp.
Enabling notebook extension graph_notebook_widgets/extension...
- Validating: OK
/home/ec2-user/anaconda3/envs/JupyterSystemEnv/bin/python: No module named graph_notebook.start_notebook
DeprecationWarning: 'source deactivate' is deprecated. Use 'conda deactivate'.

Edited by: ColinWithMothrazzz on Nov 18, 2021 6:31 AM

asked 2 years ago676 views
9 Answers
0
Accepted Answer

Hi @ColinWithMothrazzz,

Could you try removing the previously added nest_asyncio.apply() call from the "SEND THE REQUEST" section? We should not need this at the moment since we are back on using Tornado HttpClient instead of AIOHTTP, and I'm not sure what side effects it might have had.

Also, could you retrieve the dependencies list by running "!pip list" in an empty cell, and post the result?

Thanks,
Michael

AWS
AWS-MC
answered 2 years ago
0

Hi again, using the 3.0.8 version of the notebook on SageMaker everything seems to work fine using a connection created as follows:

from gremlin_python import statics
from gremlin_python.structure.graph import Graph
from gremlin_python.process.graph_traversal import __
from gremlin_python.process.strategies import *
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
from gremlin_python.driver.aiohttp.transport import AiohttpTransport
from gremlin_python.process.traversal import *
import os

port = 8182
server = '<your server endpoint goes here>'

endpoint = f'wss://{server}:{port}/gremlin'
print(endpoint)

graph=Graph()

connection = DriverRemoteConnection(endpoint,'g',
                 transport_factory=lambda:AiohttpTransport(call_from_event_loop=True))

g = graph.traversal().withRemote(connection)

result = g.V().has('code','AUS').valueMap().toList()
print('result is ' + str(result))
connection.close()

I am using the default Python provided by my SageMaker instance when I created it which was 3.6.13, however, we have tested the notebooks all the way up to Python 3.9 I believe. Are you creating your connection as above or are you using client.Client() ?

I notice that in the error you posted it is still pointing the the Python 3.6 site packages path. Can you say a bit more about your configuration please? Are you running on SageMaker and how did you change the Python version?

Rather than downgrade the graph-notebook version, are you able to try on the latest version using the connection steps I shared above? That will avoid the issues we discussed in your prior post where you had to revert to the older version.

Cheers,
Kelvin

AWS
AWS-KRL
answered 2 years ago
0

Hi-
I'm using the Signed Connector connection from my other thread:
https://forums.aws.amazon.com/thread.jspa?threadID=347690&tstart=0

When I try to run the code you posted, I get a 403 Forbidden error. It is probably since I am not using the signed connector in that code. I was downgrading the notebook after our last conversation and that worked well until recently where it looks like it gives an error when I run the downgrade command (WARNING: Skipping NeptuneGraphNotebook as it is not installed). I set up the notebook by going to Neptune in the AWS console, then Notebooks, create notebook, I used the default values (ml.t3.medium), then after it was set up I selected Python 3. I tried your additional solution of running a gremlin cell before a Python one but that gives me the "TypeError: Constructor parameter should be str" Error.

Also I did not do anything to change the Python version in the notebook: I was referring to code I had writen on my own computer which gave that error when I used Python 3.8 but not 3.7.

Also: I think the constructor error has to do with the version of grremlin, not python. I get it in lambdas now unless I explicitly set the gremlin python library to gremlinpython==3.4.11

Edited by: ColinWithMothrazzz on Nov 18, 2021 7:42 AM

Edited by: ColinWithMothrazzz on Nov 18, 2021 1:00 PM

answered 2 years ago
0

Hi @ColinWithMothrazzz,

In regards to the error:
"/home/ec2-user/anaconda3/envs/JupyterSystemEnv/bin/python: No module named graph_notebook.start_notebook"

We have updated the Sagemaker Neptune Notebooks installation script(at s3://aws-neptune-notebook/graph_notebook.tar.gz) to address this, and it should no longer cause the notebook version downgrade to fail. Could you try the downgrade to graph_notebook version 3.0.6 again with same bash commands as before, and let us know of the result?

answered 2 years ago
0

Hi-

I tried running the downgrade step and just got this error (the downgrade was working last week):

WARNING: Skipping NeptuneGraphNotebook as it is not installed.
Config option kernel_spec_manager_class not recognized by InstallNBExtensionApp.
Installing /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/gremlin_syntax/static -> gremlin_syntax
Removing: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/gremlin_syntax
Making directory: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/gremlin_syntax/
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/gremlin_syntax/static/init.py -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/gremlin_syntax/init.py
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/gremlin_syntax/static/main.js -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/gremlin_syntax/main.js
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/gremlin_syntax/static/description.yaml -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/gremlin_syntax/description.yaml
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/gremlin_syntax/static/README.md -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/gremlin_syntax/README.md
Making directory: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/gremlin_syntax/pycache
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/gremlin_syntax/static/pycache/init.cpython-36.pyc -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/gremlin_syntax/pycache/init.cpython-36.pyc
- Validating: OK
Installing /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/sparql_syntax/static -> sparql_syntax
Removing: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/sparql_syntax
Making directory: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/sparql_syntax/
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/sparql_syntax/static/init.py -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/sparql_syntax/init.py
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/sparql_syntax/static/main.js -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/sparql_syntax/main.js
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/sparql_syntax/static/description.yaml -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/sparql_syntax/description.yaml
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/sparql_syntax/static/README.md -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/sparql_syntax/README.md
Making directory: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/sparql_syntax/pycache
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/sparql_syntax/static/pycache/init.cpython-36.pyc -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/sparql_syntax/pycache/init.cpython-36.pyc
- Validating: OK
Installing /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/opencypher_syntax/static -> opencypher_syntax
Removing: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/opencypher_syntax
Making directory: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/opencypher_syntax/
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/opencypher_syntax/static/init.py -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/opencypher_syntax/init.py
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/opencypher_syntax/static/main.js -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/opencypher_syntax/main.js
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/opencypher_syntax/static/description.yaml -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/opencypher_syntax/description.yaml
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/opencypher_syntax/static/README.md -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/opencypher_syntax/README.md
Making directory: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/opencypher_syntax/pycache
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/opencypher_syntax/static/pycache/init.cpython-36.pyc -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/opencypher_syntax/pycache/init.cpython-36.pyc
- Validating: OK
Installing /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/neptune_menu/static -> neptune_menu
Removing: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/neptune_menu
Making directory: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/neptune_menu/
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/neptune_menu/static/init.py -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/neptune_menu/init.py
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/neptune_menu/static/main.js -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/neptune_menu/main.js
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/neptune_menu/static/description.yaml -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/neptune_menu/description.yaml
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/neptune_menu/static/README.md -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/neptune_menu/README.md
Making directory: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/neptune_menu/pycache
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/neptune_menu/static/pycache/init.cpython-36.pyc -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/neptune_menu/pycache/init.cpython-36.pyc
- Validating: OK
Installing /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/playable_cells/static -> playable_cells
Removing: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/playable_cells
Making directory: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/playable_cells/
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/playable_cells/static/playable_cells.css -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/playable_cells/playable_cells.css
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/playable_cells/static/init.py -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/playable_cells/init.py
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/playable_cells/static/main.js -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/playable_cells/main.js
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/playable_cells/static/description.yaml -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/playable_cells/description.yaml
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/playable_cells/static/README.md -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/playable_cells/README.md
Making directory: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/playable_cells/pycache
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/nbextensions/playable_cells/static/pycache/init.cpython-36.pyc -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/playable_cells/pycache/init.cpython-36.pyc
- Validating: OK

**To initialize this nbextension in the browser every time the notebook (or other app) loads:**  
  
      **jupyter nbextension enable graph_notebook.nbextensions --py --sys-prefix**  
  

Config option kernel_spec_manager_class not recognized by EnableNBExtensionApp.
Enabling notebook extension gremlin_syntax/main...
- Validating: OK
Enabling notebook extension sparql_syntax/main...
- Validating: OK
Enabling notebook extension opencypher_syntax/main...
- Validating: OK
Enabling notebook extension neptune_menu/main...
- Validating: OK
Enabling notebook extension playable_cells/main...
- Validating: OK
Config option kernel_spec_manager_class not recognized by InstallNBExtensionApp.
Installing /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/widgets/nbextension/static -> graph_notebook_widgets
Out of date: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/graph_notebook_widgets/init.py
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/widgets/nbextension/static/init.py -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/graph_notebook_widgets/init.py
Up to date: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/graph_notebook_widgets/extension.js
Up to date: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/graph_notebook_widgets/index.js
Out of date: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/graph_notebook_widgets/pycache/init.cpython-36.pyc
Copying: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/graph_notebook/widgets/nbextension/static/pycache/init.cpython-36.pyc -> /home/ec2-user/anaconda3/envs/JupyterSystemEnv/share/jupyter/nbextensions/graph_notebook_widgets/pycache/init.cpython-36.pyc
- Validating: OK

**To initialize this nbextension in the browser every time the notebook (or other app) loads:**  
  
      **jupyter nbextension enable graph_notebook.widgets --py --sys-prefix**  
  

Config option kernel_spec_manager_class not recognized by EnableNBExtensionApp.
Enabling notebook extension graph_notebook_widgets/extension...
- Validating: OK
DeprecationWarning: 'source deactivate' is deprecated. Use 'conda deactivate'.

answered 2 years ago
0

Hi Colin,

I tried running the downgrade on a Sagemaker instance running on 3.0.8, and received the same sequence of outputs as you listed. However, on my side, the 3.0.6 downgrade did appear to be have completed successfully; After restarting the kernel to pick up the update, and refreshing the webpage to reload the notebook extensions, I see that %graph_notebook_config returns "3.0.6". I am also able to run gremlin queries through the %%gremlin magic.

I have not yet verified whether I am able to reproduce the constructor error that you showed in the root post, looking into this currently.

Could you also confirm what the current issue with the 3.0.6 downgrade is on your side? Does the notebook downgrade fail entirely after the sequence of outputs listed, with %graph_notebook_config still showing 3.0.8 after refreshing the kernel? Or does it succeed in downgrading, and is it just the constructor error that you are still seeing?

Thanks,
Michael

Edited by: AWS-MC on Nov 19, 2021 12:19 PM

AWS
AWS-MC
answered 2 years ago
0

Hi- I downgraded the notebook and now get a timeout when I try to run a query to my DB. I am using Sig4 signing to connect: the code works in lambdas and was working in the notebook a week or so ago. My code:

import boto3
import botocore.config
import json
import csv

import sys
import datetime
import hashlib
import hmac
import json
import logging
#from requests import RequestException
from gremlin_python.driver import client
from tornado import httpclient

from gremlin_python import statics
from gremlin_python.structure.graph import Graph
from gremlin_python.process.graph_traversal import __
*from gremlin_python.process.strategies import **
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection

from boto3.compat import six
from boto3 import Session

import nest_asyncio

class SignedConnector():

**#------------------------------------------------------------------------------**  
**#**  
**# __init__ method starts the class with default values**  
**#**  
**#------------------------------------------------------------------------------**  
**def __init__(self, host, region = 'us-east-1'):**  

    **self.host = host**  
    **session = Session()**  
    **credentials = session.get_credentials()**  
    **current_credentials = credentials.get_frozen_credentials()**  
    **self.access_key = current_credentials.access_key**  
    **self.secret_key = current_credentials.secret_key**  
    **self.session_token = current_credentials.token**  

    **self.region = region**  
    **self.query_type = 'gremlin'**  
    **self.service = 'neptune-db'**  
    **self.endpoint = 'https://' + host**  
    **self.method = 'GET'**  
    **self.canonical_uri = '/gremlin'**    


**def sign(self, key, msg):**  
    **return hmac.new(key, msg.encode('utf-8'), hashlib.sha256).digest()**  


**def getSignatureKey(self, key, dateStamp, regionName, serviceName):**  
    **kDate = self.sign(('AWS4' + key).encode('utf-8'), dateStamp)**  
    **kRegion = self.sign(kDate, regionName)**  
    **kService = self.sign(kRegion, serviceName)**  
    **kSigning = self.sign(kService, 'aws4_request')**  
    **return kSigning**          
      
      
**def get_graph(self):**  
    *# ************* TASK 1: CREATE A CANONICAL REQUEST **************  
    **# http://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html**  

    **# Step 1 is to define the verb (GET, POST, etc.)--already done.**  

    **# Create a date for headers and the credential string.**  
    **t = datetime.datetime.utcnow()**  
    **amzdate = t.strftime('%Y%m%dT%H%M%SZ')**  
    **datestamp = t.strftime('%Y%m%d')**  


    *# ************* TASK 1: CREATE A CANONICAL REQUEST **************  
    **# http://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html**  

    **# Step 1 is to define the verb (GET, POST, etc.)--already done.**  
    **# Step 2: is to define the canonical_uri--already done.**  

    **# Step 3: Create the canonical query string. This should be an empty string for**  
    **# the purposes of establishing a websocket connection.  Once the websocket is created**  
    **# requests can be submitted to the websocket.**  
    **canonical_querystring = ''**  

    **# Step 4: Create the canonical headers and signed headers. Header names**  
    **# must be trimmed and lowercase, and sorted in code point order from**  
    **# low to high. Note that there is a trailing \n.**  
    **canonical_headers = 'host:' _ self.host _ '\n' _ 'x-amz-date:' _ amzdate _ '\n' _ 'x-amz-security-token:' _ self.session_token _ '\n'**  


    **# Step 5: Create the list of signed headers. This lists the headers**  
    **# in the canonical_headers list, delimited with ";" and in alpha order.**  
    **# Note: The request can include any headers; canonical_headers and**  
    **# signed_headers lists those that you want to be included in the**  
    **# hash of the request. "Host" and "x-amz-date" are always required.**  
    **signed_headers = 'host;x-amz-date;x-amz-security-token'**  

    **# Step 6: Create payload hash (hash of the request body content). For GET**  
    **# requests, the payload is an empty string ("").**  
    **post_payload = ''**  

    **payload_hash = hashlib.sha256(post_payload.encode('utf-8')).hexdigest()**  

    **# Step 7: Combine elements to create canonical request.**  
    **canonical_request = self.method _ '\n' _ self.canonical_uri _ '\n' _ canonical_querystring _ '\n' _ canonical_headers _ '\n' _ signed_headers _ '\n' _ payload_hash**  

    *# ************* TASK 2: CREATE THE STRING TO SIGN**************  
    **# Match the algorithm to the hashing algorithm you use, either SHA-1 or**  
    **# SHA-256 (recommended)**  
    **algorithm = 'AWS4-HMAC-SHA256'**  
    **credential_scope = datestamp _ '/' _ self.region _ '/' _ self.service _ '/' _ 'aws4_request'**  
    **string_to_sign = algorithm _ '\n' _ amzdate _ '\n' _ credential_scope _ '\n' _ hashlib.sha256(canonical_request.encode('utf-8')).hexdigest()**  

    *# ************* TASK 3: CALCULATE THE SIGNATURE **************  
    **# Create the signing key using the function defined above.**  
    **signing_key = self.getSignatureKey(self.secret_key, datestamp, self.region, self.service)**  

    **# Sign the string_to_sign using the signing_key**  
    **signature = hmac.new(signing_key, (string_to_sign).encode('utf-8'), hashlib.sha256).hexdigest()**  


    *# ************* TASK 4: ADD SIGNING INFORMATION TO THE REQUEST **************  
    **# The signing information can be either in a query string value or in**  
    **# a header named Authorization. This code shows how to use a header.**  
    **# Create authorization header and add to request headers**  
    **authorization_header = algorithm _ ' ' _ 'Credential=' _ self.access_key _ '/' _ credential_scope _ ', ' _ 'SignedHeaders=' _ signed_headers _ ', ' _ 'Signature=' + signature**  

    **# The request can include any headers, but MUST include "host", "x-amz-date",**  
    **# and (for this scenario) "Authorization". "host" and "x-amz-date" must**  
    **# be included in the canonical_headers and signed_headers, as noted**  
    **# earlier. Order here is not significant.**  
    **# Python note: The 'host' header is added automatically by the Python 'requests' library.**  
    **headers = {'x-amz-date': amzdate, 'Authorization': authorization_header, 'x-amz-security-token': self.session_token}**  

    *# ************* SEND THE REQUEST **************  
    **request_url = self.endpoint + self.canonical_uri**  

    **print()**  
    **print('++++ OUTPUT REQUEST PARAMETERS +++++')**  
    **print('Request URL = ' + request_url)**  
    **print()**  
    **print('++++ ESTABLISH WEB SOCKET CONNECTION ++++')**  
    **nest_asyncio.apply()**  
    **websocket_url = request_url.replace("http", "ws")**  
    **print('Converting Request URL from HTTP to WS: ' + websocket_url)**  
    **print('Generating a signed HTTP requests to initiate the creation of the websocket session. Using Tornado HTTP Client...')**  
    **signed_ws_request = httpclient.HTTPRequest(websocket_url, headers=headers)**  
    **#signed_ws_request = requests.Request(method='GET', url=websocket_url, headers=headers)**  
    **print('Creating websocket connection...')**  
    **#websocketClient = client.Client(signed_ws_request, 'g')**  
    **#print('Websocket establishd to: ' + websocketClient._url.url)**  
    **#print('Executing a count of all vertices - g.V().count()...')**  
    **#testQuery = websocketClient.submit('g.V().count()')**  
    **#print("Test Result Returned: " + json.dumps(testQuery.one()))**  
      
      
    **graph = Graph()**  
    **print('got graph')**  
    **remoteConn = DriverRemoteConnection(signed_ws_request,'g')**  
    **print('got remoteconn')**  
    **g = graph.traversal().withRemote(remoteConn)**  
    **print('got graph')**  
    **return g, remoteConn**  

import boto3
import botocore.config
import json
import csv
import hashlib
import uuid
import logging
import os

import datetime

from gremlin_python import statics
from gremlin_python.structure.graph import Graph
from gremlin_python.process.graph_traversal import __
*from gremlin_python.process.strategies import **
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
from gremlin_python.process.traversal import Cardinality
from gremlin_python.process.traversal import T

def get_client():

**ssm_client = boto3.client('ssm')**  

**neptune_endpoint = MYENDPOINT**  
**#print('endpoint is' + neptune_endpoint)**  
**sc = SignedConnector(host=neptune_endpoint + ':8182')**  

**g, remoteConn = sc.get_graph()**  

**status = ''**  


**return g, remoteConn, status**  

g, remoteConn, status = get_client()

res = g.V().has('code','test').valueMap(True).toList()
print(res)

I get:


HTTPError Traceback (most recent call last)
<ipython-input-7-a083343178f8> in <module>
----> 1 res = g.V().has('code','test').valueMap(True).toList()
2 print(res)

~/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/gremlin_python/process/traversal.py in toList(self)
56
57 def toList(self):
---> 58 return list(iter(self))
59
60 def toSet(self):

~/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/gremlin_python/process/traversal.py in next(self)
46 def next(self):
47 if self.traversers is None:
---> 48 self.traversal_strategies.apply_strategies(self)
49 if self.last_traverser is None:
50 self.last_traverser = next(self.traversers)

~/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/gremlin_python/process/traversal.py in apply_strategies(self, traversal)
575 def apply_strategies(self, traversal):
576 for traversal_strategy in self.traversal_strategies:
--> 577 traversal_strategy.apply(traversal)
578
579 def apply_async_strategies(self, traversal):

~/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/gremlin_python/driver/remote_connection.py in apply(self, traversal)
147 def apply(self, traversal):
148 if traversal.traversers is None:
--> 149 remote_traversal = self.remote_connection.submit(traversal.bytecode)
150 traversal.remote_results = remote_traversal
151 traversal.side_effects = remote_traversal.side_effects

~/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/gremlin_python/driver/driver_remote_connection.py in submit(self, bytecode)
55
56 def submit(self, bytecode):
---> 57 result_set = self._client.submit(bytecode, request_options=self._extract_request_options(bytecode))
58 results = result_set.all().result()
59 side_effects = RemoteTraversalSideEffects(result_set.request_id, self._client,

~/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/gremlin_python/driver/client.py in submit(self, message, bindings, request_options)
128
129 def submit(self, message, bindings=None, request_options=None):
--> 130 return self.submitAsync(message, bindings=bindings, request_options=request_options).result()
131
132 def submitAsync(self, message, bindings=None, request_options=None):

~/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/gremlin_python/driver/client.py in submitAsync(self, message, bindings, request_options)
149 if request_options:
150 message.args.update(request_options)
--> 151 return conn.write(message)

~/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/gremlin_python/driver/connection.py in write(self, request_message)
53 def write(self, request_message):
54 if not self._inited:
---> 55 self.connect()
56 request_id = str(uuid.uuid4())
57 result_set = resultset.ResultSet(queue.Queue(), request_id)

~/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/gremlin_python/driver/connection.py in connect(self)
43 self._transport.close()
44 self._transport = self._transport_factory()
---> 45 self._transport.connect(self._url, self._headers)
46 self._protocol.connection_made(self._transport)
47 self._inited = True

~/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/gremlin_python/driver/tornado/transport.py in connect(self, url, headers)
44 url = httpclient.HTTPRequest(url, headers=headers, ssl_options=self._ssl_options)
45 self._ws = self._loop.run_sync(
---> 46 lambda: websocket.websocket_connect(url, compression_options=self._compression_options,
47 max_message_size=self._max_content_length))
48

~/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/tornado/ioloop.py in run_sync(self, func, timeout)
456 if not future_cell[0].done():
457 raise TimeoutError('Operation timed out after %s seconds' % timeout)
--> 458 return future_cell[0].result()
459
460 def time(self):

~/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/tornado/concurrent.py in result(self, timeout)
236 if self._exc_info is not None:
237 try:
--> 238 raise_exc_info(self._exc_info)
239 finally:
240 self = None

~/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/tornado/util.py in raise_exc_info(exc_info)

~/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/tornado/stack_context.py in wrapped(*args, **kwargs)
314 if top is None:
315 try:
--> 316 ret = fn(*args, **kwargs)
317 except:
318 exc = sys.exc_info()

~/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/tornado/simple_httpclient.py in _on_timeout(self, info)
305 error_message = "Timeout {0}".format(info) if info else "Timeout"
306 if self.final_callback is not None:
--> 307 raise HTTPError(599, error_message)
308
309 def _remove_timeout(self):

HTTPError: HTTP 599: Timeout while connecting

answered 2 years ago
0

That's so much- removing that netsyncho fixed it. I'm back in business. Thanks again!!

answered 2 years ago
0

Great to hear, thanks @ColinWithMothrazzz. Let us know if you have any further questions or concerns.

Regards,
Michael

AWS
AWS-MC
answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions