Skip to content

Upgrade project to jupyterlab 4x #728

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
@@ -15,16 +15,16 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Set up Node.js 14.x
- name: Set up Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: 14.17.4
node-version: '20.18.3'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
pip install build hatch hatch-jupyter-builder
pip install flake8 pytest
pip install "jupyterlab>=3,<4"
pip install "jupyterlab>=4.3.5,<5"
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
@@ -33,7 +33,7 @@ jobs:
flake8 ./test --max-complexity 10 --ignore E501,C901,W291 --show-source --statistics
- name: Install
run: |
python setup.py bdist_wheel
python -m build .
pip install ./dist/graph_notebook-*-py3-none-any.whl
- name: Post-install commands
run: |
@@ -43,4 +43,4 @@ jobs:
python -m graph_notebook.notebooks.install
- name: Test with pytest
run: |
pytest test/unit
pytest test/unit
Empty file removed =3,
Empty file.
58 changes: 45 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -96,24 +96,24 @@ It is recommended to check the [ChangeLog.md](ChangeLog.md) file periodically to

You will need:

* [Python](https://www.python.org/downloads/) 3.9.x-3.10.14
* [Python](https://www.python.org/downloads/)
* For JupyterLab 4x Version: 3.9.x-3.11.x
* For JupyterLab 3x Version: 3.9.x-3.10.14
* A graph database that provides one or more of:
* A SPARQL 1.1 endpoint
* An Apache TinkerPop Gremlin Server compatible endpoint
* An endpoint compatible with openCypher

## Installation

Begin by installing `graph-notebook` and its prerequisites, then follow the remaining instructions for either Jupyter Classic Notebook or JupyterLab.
Follow the instructions for either Jupyter Classic Notebook or JupyterLab based on your requirements.

``` bash
# install the package
pip install graph-notebook
```

### Jupyter Classic Notebook

``` bash
pip install graph-notebook

# Enable the visualization widget
jupyter nbextension enable --py --sys-prefix graph_notebook.widgets

@@ -132,12 +132,39 @@ touch ~/.jupyter/nbconfig/notebook.json
python -m graph_notebook.start_notebook --notebooks-dir ~/notebook/destination/dir
```

### JupyterLab 3.x
### Jupyter Lab

Graph-notebook has been upgraded to support JupyterLab 4.x since version 5.0.0, featuring a modernized widget architecture and improved compatibility.

Choose your installation based on your JupyterLab version requirements.


### JupyterLab 4.x (Recommended)

``` bash
# install jupyterlab
pip install "jupyterlab>=4.3.5,<5"

# Install the latest version with JupyterLab 4.x support
pip install graph-notebook

# copy premade starter notebooks
python -m graph_notebook.notebooks.install --destination ~/notebook/destination/dir

# start jupyterlab
python -m graph_notebook.start_jupyterlab --jupyter-dir ~/notebook/destination/dir
```

### JupyterLab 3.x (Legacy)

``` bash

# install jupyterlab
pip install "jupyterlab>=3,<4"

# Install legacy version for JupyterLab 3.x compatibility
pip install "graph-notebook<5.0.0"

# copy premade starter notebooks
python -m graph_notebook.notebooks.install --destination ~/notebook/destination/dir

@@ -378,26 +405,31 @@ cd graph-notebook
# 2) Create a new virtual environment

# 2a) Option 1 - pyenv
# install pyenv - https://github.com/pyenv/pyenv?tab=readme-ov-file#installation
# install pyenv-virtualenv - https://github.com/pyenv/pyenv-virtualenv?tab=readme-ov-file#installation
pyenv install 3.10.13 # Only if not already installed; this can be any supported Python 3 version in Prerequisites
pyenv virtualenv 3.10.13 build-graph-notebook
pyenv local build-graph-notebook

# 2b) Option 2 - venv
deactivate
conda deactivate
rm -rf /tmp/venv
python3 -m venv /tmp/venv
python3 -m venv --clear /tmp/venv
source /tmp/venv/bin/activate


# 3) Install build dependencies
pip install --upgrade pip setuptools wheel twine
pip install "jupyterlab>=3,<4"
pip install --upgrade build hatch hatch-jupyter-builder
pip install "jupyterlab>=4.3.5,<5"

# 4) Build the distribution
python3 setup.py bdist_wheel
python3 -m build .
```

You should now be able to find the built distribution at

`./dist/graph_notebook-4.6.2-py3-none-any.whl`
`./dist/graph_notebook-5.0.0-py3-none-any.whl`

And use it by following the [installation](https://github.com/aws/graph-notebook#installation) steps, replacing

@@ -408,7 +440,7 @@ pip install graph-notebook
with

``` python
pip install ./dist/graph_notebook-4.6.2-py3-none-any.whl
pip install ./dist/graph_notebook-5.0.0-py3-none-any.whl --force-reinstall
```

## Contributing Guidelines
Original file line number Diff line number Diff line change
@@ -19,17 +19,6 @@ python3 -m ipykernel install --sys-prefix --name python3 --display-name "Python
echo "installing python dependencies..."
pip uninstall NeptuneGraphNotebook -y # legacy uninstall when we used to install from source in s3

pip install "jupyter_core<=5.3.2"
pip install "jupyter_server<=2.7.3"
pip install "jupyter-console<=6.4.0"
pip install "jupyter-client<=6.1.12"
pip install "ipywidgets==7.7.2"
pip install "jupyterlab_widgets==1.1.1"
pip install "notebook==6.4.12"
pip install "nbclient<=0.7.0"
pip install "itables<=1.4.2"
pip install awswrangler

if [[ ${NOTEBOOK_VERSION} == "" ]]; then
pip install --upgrade graph-notebook
else
@@ -47,11 +36,14 @@ if [[ ${NOTEBOOK_VERSION//./} < 330 ]] && [[ ${NOTEBOOK_VERSION} != "" ]]; then
jupyter nbextension install --py --sys-prefix graph_notebook.widgets
fi
jupyter nbextension enable --py --sys-prefix graph_notebook.widgets
echo "enabled visualization..."

echo "Copying starter notebooks..."
mkdir -p ~/SageMaker/Neptune
cd ~/SageMaker/Neptune || exit
python -m graph_notebook.notebooks.install
chmod -R a+rw ~/SageMaker/Neptune/*
echo "Copied starter notebooks..."

source ~/.bashrc || exit
HOST=${GRAPH_NOTEBOOK_HOST}
@@ -89,7 +81,9 @@ else
echo "Skipping, unsupported on graph-notebook<=3.4.1"
fi

conda /home/ec2-user/anaconda3/bin/deactivate
echo "graph-notebook installation complete."

conda deactivate || echo "Already deactivated or not in an environment."
echo "done."

EOF
130 changes: 130 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
[build-system]
requires = [
"hatchling>=1.5.0",
"jupyterlab>=4.0.0,<5.0.0",
"hatch-nodejs-version",
"hatch-jupyter-builder>=0.5"
]
build-backend = "hatchling.build"

[project]
name = "graph-notebook"
version = "5.0.0"
description = "Jupyter notebook extension to connect to graph databases"
readme = "README.md"
license = { file = "LICENSE" }
requires-python = ">=3.9,<3.12"
authors = [
{ name = "amazon-neptune", email = "amazon-neptune-pypi@amazon.com" },
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"License :: OSI Approved :: Apache Software License"
]
keywords = ["jupyter", "neptune", "gremlin", "sparql", "opencypher"]
dependencies = [
# Jupyter ecosystem
'ipyfilechooser==0.6.0',
'ipykernel>=6.5.0',
'ipython>=7.16.1,<=8.10.0',
'ipywidgets>=8.0.0,<9.0.0',
'jupyter-server>=2.0.0,<3.0.0',
'jupyter-server-proxy>=4.0.0,<5.0.0',
'jupyter_client>=8.0.0,<9.0.0',
'jupyterlab>=4.3.5,<5.0.0',
'jupyterlab-widgets>=3.0.0,<4.0.0',
'nbclient>=0.7.3',
'nbconvert>=6.3.0,<=7.2.8',
# Pinned for compatibility with custom nbextensions and Jupyter classic notebooks.
# JupyterLab 7+ removed support for nbextensions as part of modernizing the extension system.
# Our project uses custom nbextensions (setup in src/graph_notebook/nbextensions/install.py)
# that need to work with Jupyter classic.
# See: https://github.com/ipython-contrib/jupyter_contrib_nbextensions/issues/1661
# Will require migration work to support JupyterLab 7+ in the future.
'notebook==6.4.2',

# Data processing and visualization
'itables>=2.0.0,<=2.1.0',
'networkx==2.4',
'numpy>=1.23.5,<1.24.0',
'pandas>=2.1.0,<=2.2.2',

# Graph databases and query languages
'gremlinpython>=3.5.1,<=3.7.2',
'neo4j>=5.0.0,<=5.23.1',
'rdflib==7.0.0',
'SPARQLWrapper==2.0.0',

# AWS SDK
'boto3>=1.34.74',
'botocore>=1.34.74',

# Utilities
'async-timeout>=4.0,<5.0',
'jedi>=0.18.1,<=0.18.2',
'Jinja2>=3.0.3,<=3.1.4',
'json-repair==0.29.2',
'nest_asyncio>=1.5.5,<=1.6.0',
'requests>=2.32.0,<=2.32.2'
]

[project.optional-dependencies]
test = [
"pytest==6.2.5"
]

[project.entry-points]
"ipython" = { "graph_notebook_magics" = "graph_notebook.magics:load_ipython_extension" }
"notebook.extensions" = { "graph_notebook_widgets" = "graph_notebook.widgets:_jupyter_nbextension_paths" }
"jupyter_labextension" = { "graph_notebook_widgets" = "graph_notebook.widgets:_jupyter_labextension_paths" }

[tool.hatch.build.hooks.jupyter-builder]
dependencies = ["hatch-jupyter-builder>=0.5"]
build-function = "hatch_jupyter_builder.npm_builder"
ensured-targets = [
"src/graph_notebook/widgets/labextension/package.json",
"src/graph_notebook/widgets/labextension/static/style.js",
"src/graph_notebook/widgets/nbextension/index.js",
]
skip-if-exists = ["src/graph_notebook/widgets/labextension/static/style.js"]

[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
build_cmd = "build:prod"
npm = ["npm", "--prefix", "src/graph_notebook/widgets"]
source_dir = "src/graph_notebook/widgets"
build_dir = "src/graph_notebook/widgets/lib"

[tool.hatch.build]
artifacts = [
"src/graph_notebook/widgets/labextension",
"src/graph_notebook/widgets/nbextension",
]

[tool.hatch.build.targets.wheel.shared-data]
"src/graph_notebook/widgets/labextension" = "share/jupyter/labextensions/graph_notebook_widgets"
"src/graph_notebook/widgets/nbextension" = "share/jupyter/nbextensions/graph_notebook_widgets"
"src/graph_notebook/widgets/graph_notebook_widgets.json" = "etc/jupyter/nbconfig/notebook.d/graph_notebook_widgets.json"

[tool.hatch.build.targets.sdist]
exclude = [
"/.github",
"/docs",
"node_modules",
]

[tool.hatch.build.targets.wheel]
packages = ["src/graph_notebook"]
include = [
"src/graph_notebook/**/*.py",
"src/graph_notebook/**/*.ipynb",
"src/graph_notebook/**/*.json",
"src/graph_notebook/**/*.txt",
"src/graph_notebook/**/*.html",
"src/graph_notebook/**/*.css",
"src/graph_notebook/**/*.js",
"src/graph_notebook/**/*.yaml",
"src/graph_notebook/**/*.csv"
]
58 changes: 31 additions & 27 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
SPARQLWrapper==2.0.0
networkx==2.4
Jinja2>=3.0.3,<=3.1.4
jupyter==1.0.0
notebook>=6.1.5,<7.0.0
ipywidgets==7.7.2
jupyterlab_widgets>=1.0.0,<=1.1.10
nbclient<=0.7.0
jupyter-contrib-nbextensions<=0.7.0
widgetsnbextension<=3.6.1
gremlinpython>=3.5.1,<=3.7.2
requests>=2.32.0,<=2.32.2
ipython>=7.16.1,<=8.10.0
ipykernel==5.3.4
# Jupyter ecosystem
ipyfilechooser==0.6.0
neo4j>=5.0.0,<=5.23.1
rdflib==7.0.0
setuptools>=70.0.0,<=70.0.3
ipykernel>=6.5.0
ipython>=7.16.1,<=8.10.0
ipywidgets>=8.0.0,<9.0.0
jupyter-server>=2.0.0,<3.0.0
jupyter-server-proxy>=4.0.0,<5.0.0
jupyter_client>=8.0.0,<9.0.0
jupyterlab>=4.3.5,<5.0.0
jupyterlab-widgets>=3.0.0,<4.0.0
nbclient>=0.7.3
nbconvert>=6.3.0,<=7.2.8
jedi>=0.18.1,<=0.18.2
markupsafe<2.1.0
notebook==6.4.2

# Data processing and visualization
itables>=2.0.0,<=2.1.0
networkx==2.4
numpy>=1.23.5,<1.24.0
pandas>=2.1.0,<=2.2.2
numpy<1.24.0
nest_asyncio>=1.5.5,<=1.6.0

# Graph databases and query languages
gremlinpython>=3.5.1,<=3.7.2
neo4j>=5.0.0,<=5.23.1
rdflib==7.0.0
SPARQLWrapper==2.0.0

# AWS SDK
boto3>=1.34.74
botocore>=1.34.74

# Utilities
async-timeout>=4.0,<5.0
jedi>=0.18.1,<=0.18.2
Jinja2>=3.0.3,<=3.1.4
json-repair==0.29.2

# requirements for testing
botocore~=1.34.74
boto3~=1.34.74
pytest==6.2.5
parameterized==0.8.1
nest_asyncio>=1.5.5,<=1.6.0
requests>=2.32.0,<=2.32.2
Loading