aws / graph-notebook

Library extending Jupyter notebooks to integrate with Apache TinkerPop, openCypher, and RDF SPARQL.
https://github.com/aws/graph-notebook
Apache License 2.0
723 stars 166 forks source link

Unable to Display SPARQL Query Results Using %%sparql Magic Cell #515

Open miguelsmuller opened 1 year ago

miguelsmuller commented 1 year ago

Hello,

I hope this message finds you well. I am currently using the AWS Graph Notebook in Visual Studio Code to execute SPARQL queries. However, I'm facing an issue with displaying the results of SPARQL queries using the %%sparql magic cell annotation.

Problem:

When I attempt to execute a SPARQL query using the %%sparql cell annotation in Visual Studio Code, the query runs successfully, but the results are not being displayed in the output. Instead, I only see an empty cell with no visible output.

Steps to Reproduce:

  1. Open Visual Studio Code.
  2. Create a new notebook.
  3. Use the %%sparql magic cell annotation to execute a SPARQL query.
  4. Run the cell.
  5. Notice that the query executes, but the results are not displayed.

Expected Outcome:

I expect that when I execute a SPARQL query using the %%sparql magic cell annotation, the query results should be displayed in the output cell as expected.

Additional Information:

I would greatly appreciate your assistance in resolving this issue.

Please let me know if there's any additional information or logs that would be helpful for debugging.

Thank you for your attention to this matter.

michaelnchin commented 1 year ago

Hi @miguelsmuller,

Can you describe the process you took install graph-notebook onto VS Code? Please provide additional details around your env (Python version and package versions used, at least for Jupyter core - run !jupyter --version)

If possible, please also provide the VS Code Jupyter logs from running the %%sparql cell. You can enable and grab the logs via these steps:

  1. In VS Code, open Settings, then go to Extensions -> Jupyter -> Logging
  2. Set the Logging level in the dropdown to "verbose", then restart VS Code
  3. Re-run the %%sparql query in the Jupyter Notebook
  4. Pull the logs from the "Output" tab in the lower console
michaelnchin commented 1 year ago

This issue might be related: https://github.com/aws/graph-notebook/issues/515

Worth checking if a downgrade to jupyter_client<8 and pyzmq<25 fixes the issue.

miguelsmuller commented 1 year ago

I will provide two comments. For the first one, I will share the environment setup I have here and the current screenshots:

Currently, I'm using a virtual environment (venv) with Python version 3.9.16. I set up the venv as follows:

~/.pyenv/versions/3.9.16/bin/python -m venv .venv

I have the following libraries installed:

pylama==8.4.1
pycodestyle==2.10.0
black==23.7.0

ipykernel==5.3.4
graph-notebook==3.8.2
jupyter==1.0.0
jupyter-client==7.1.2
jupyter-console==6.4.3
jupyter-contrib-core==0.3.3
jupyter-contrib-nbextensions==0.5.1
jupyter-core==4.9.2
jupyter-highlight-selected-word==0.2.0
jupyter-latex-envs==1.4.6
jupyter-nbextensions-configurator==0.4.1
jupyter-server==1.13.1
jupyterlab==3.2.8
jupyterlab-server==2.10.3
jupyterlab-widgets==1.1.0

rdflib==5.0.0
SPARQLWrapper==1.8.4
networkx==2.4

pandas==1.5.3
numpy<1.24.0
spacy==3.5.0
nltk==3.8.1
pydantic==1.10.7
pyarrow==12.0.1
seaborn==0.12.2
matplotlib==3.7.2
google-cloud-bigquery==3.11.3

fuzzywuzzy==0.18.0
python-Levenshtein==0.21.1
stringcase==1.2.0
python-stopwatch==1.0.5

VSCode Screenshot

Screenshot 2023-08-11 at 10 59 38

Jupyter in Browser screenshot:

Screenshot 2023-08-11 at 10 58 29

miguelsmuller commented 1 year ago

@michaelnchin, As you requested, here's the log generated when I execute the SPARQL query in Visual Studio Code:

11:13:24.886 [info] Handle Execution of Cells 6 for {MY_FOLDER}/0001.ipynb
11:13:24.887 [debug] start the kernel, options.disableUI=false for {MY_FOLDER}/0001.ipynb
11:13:24.889 [debug] Execution Request Sent to Kernel for cell 6
11:13:24.902 [debug] Start cell 6 execution @ 1691763204899 (clear output)
11:13:24.902 [info] Kernel acknowledged execution of cell 6 @ 1691763204899
11:13:24.922 [debug] Widget Message: WidgetManager: Loading class LayoutModel:@jupyter-widgets/base:1.2.0
11:13:24.940 [debug] Widget Message: WidgetManager: Loading class TabModel:@jupyter-widgets/controls:1.5.0
11:13:24.942 [debug] Widget Message: WidgetManager: Loading class LayoutModel:@jupyter-widgets/base:1.2.0
11:13:24.946 [debug] Widget Message: WidgetManager: Loading class TabModel:@jupyter-widgets/controls:1.5.0
11:13:24.950 [debug] Widget Message: WidgetManager: Loading class OutputModel:@jupyter-widgets/output:1.0.0
11:13:24.957 [debug] Widget Message: WidgetManager: Loading class LayoutModel:@jupyter-widgets/base:1.2.0
11:13:24.963 [debug] Widget Message: WidgetManager: Loading class ForceModel:graph_notebook_widgets:3.8.2
11:13:24.967 [debug] Widget Message: WidgetManager: Loading class OutputModel:@jupyter-widgets/output:1.0.0
11:13:24.979 [debug] Widget Message: WidgetManager: Loading class OutputModel:@jupyter-widgets/output:1.0.0
11:13:24.984 [debug] Widget Message: Received display data message c08a61d1b64f40dba9a011caaf5ad593
11:13:24.999 [debug] Version of IPyWidgets 7 determined after 0s
11:13:25.012 [debug] Widget Message: Waiting for model to be available before rendering it c08a61d1b64f40dba9a011caaf5ad593
11:13:25.014 [error] Widget Error: Error: Failed to render widget c08a61d1b64f40dba9a011caaf5ad593, Error: widget model not found
11:13:25.018 [info] End cell 6 execution @ 1691763204950, started @ 1691763204899, elapsed time = 0.051s
11:13:25.018 [debug] Cell 6 executed with state Success
michaelnchin commented 1 year ago

Hi @miguelsmuller , apologies for the late response.

Thank you for the additional information around your setup - I was able to reproduce this locally on VSCode, while the same env setup worked with Jupyter Classic Notebook and JupyterLab. The application-specific nature of the bug seems suggests that VSCode has additional requirements to get Jupyter widgets running in general.

I haven't been able to nail down a root cause as of yet, so scope of the changes needed remains ambiguous to me. Given the unclear dev time commitment required here, I think we have to consider VSCode support lower priority for now, but we will keep this in the backlog for investigation.

miguelsmuller commented 1 year ago

No problem, @michaelnchin .

I appreciate the time you've taken to conduct this initial investigation.

If I can assist in any way, please let me know. I'd be happy to collaborate.

Pidem commented 1 week ago

I would recommend making sure that the latest version of ipywidgets is installed my running pip install ipywidgets. Potentially also make sure to have the widgets enabled: jupyter nbextension enable --py widgetsnbextension Additionally, reload the VSCode window >Developer: Reload Window