Skip to content

Commit 1216eb9

Browse files
upgrade project to jupyterlab 4x
1 parent fb66141 commit 1216eb9

File tree

24 files changed

+598
-1089
lines changed

24 files changed

+598
-1089
lines changed

.github/workflows/unit.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ jobs:
1515
uses: actions/setup-python@v2
1616
with:
1717
python-version: ${{ matrix.python-version }}
18-
- name: Set up Node.js 14.x
18+
- name: Set up Node.js 20.x
1919
uses: actions/setup-node@v3
2020
with:
21-
node-version: 14.17.4
21+
node-version: '20.18.3'
2222
- name: Install dependencies
2323
run: |
2424
python -m pip install --upgrade pip
25-
pip install wheel
25+
pip install build hatch hatch-jupyter-builder
2626
pip install flake8 pytest
27-
pip install "jupyterlab>=3,<4"
27+
pip install "jupyterlab>=4.3.5,<5"
2828
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
2929
- name: Lint with flake8
3030
run: |
@@ -33,14 +33,14 @@ jobs:
3333
flake8 ./test --max-complexity 10 --ignore E501,C901,W291 --show-source --statistics
3434
- name: Install
3535
run: |
36-
python setup.py bdist_wheel
36+
python -m build .
3737
pip install ./dist/graph_notebook-*-py3-none-any.whl
3838
- name: Post-install commands
3939
run: |
40-
jupyter nbextension enable --py --sys-prefix graph_notebook.widgets
40+
jupyter nbclassic-extension enable --py --sys-prefix graph_notebook.widgets
4141
python -m graph_notebook.static_resources.install
4242
python -m graph_notebook.nbextensions.install
4343
python -m graph_notebook.notebooks.install
4444
- name: Test with pytest
4545
run: |
46-
pytest test/unit
46+
pytest test/unit

=3,

Whitespace-only changes.

README.md

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,26 +96,26 @@ It is recommended to check the [ChangeLog.md](ChangeLog.md) file periodically to
9696

9797
You will need:
9898

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

105107
## Installation
106108

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

109-
``` bash
110-
# install the package
111-
pip install graph-notebook
112-
```
113111

114112
### Jupyter Classic Notebook
115113

116114
``` bash
115+
pip install graph-notebook
116+
117117
# Enable the visualization widget
118-
jupyter nbextension enable --py --sys-prefix graph_notebook.widgets
118+
jupyter nbclassic-extension enable --py --sys-prefix graph_notebook.widgets
119119

120120
# copy static html resources
121121
python -m graph_notebook.static_resources.install
@@ -132,12 +132,39 @@ touch ~/.jupyter/nbconfig/notebook.json
132132
python -m graph_notebook.start_notebook --notebooks-dir ~/notebook/destination/dir
133133
```
134134

135-
### JupyterLab 3.x
135+
### Jupyter Lab
136+
137+
Graph-notebook has been upgraded to support JupyterLab 4.x since version 5.0.0, featuring a modernized widget architecture and improved compatibility.
138+
139+
Choose your installation based on your JupyterLab version requirements.
140+
141+
142+
### JupyterLab 4.x (Recommended)
143+
144+
``` bash
145+
# install jupyterlab
146+
pip install "jupyterlab>=4.3.5,<5"
147+
148+
# Install the latest version with JupyterLab 4.x support
149+
pip install graph-notebook
150+
151+
# copy premade starter notebooks
152+
python -m graph_notebook.notebooks.install --destination ~/notebook/destination/dir
153+
154+
# start jupyterlab
155+
python -m graph_notebook.start_jupyterlab --jupyter-dir ~/notebook/destination/dir
156+
```
157+
158+
### JupyterLab 3.x (Legacy)
136159

137160
``` bash
161+
138162
# install jupyterlab
139163
pip install "jupyterlab>=3,<4"
140164

165+
# Install legacy version for JupyterLab 3.x compatibility
166+
pip install "graph-notebook<5.0.0"
167+
141168
# copy premade starter notebooks
142169
python -m graph_notebook.notebooks.install --destination ~/notebook/destination/dir
143170

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

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

385414
# 2b) Option 2 - venv
415+
deactivate
416+
conda deactivate
386417
rm -rf /tmp/venv
387-
python3 -m venv /tmp/venv
418+
python3 -m venv --clear /tmp/venv
388419
source /tmp/venv/bin/activate
389420

421+
390422
# 3) Install build dependencies
391-
pip install --upgrade pip setuptools wheel twine
392-
pip install "jupyterlab>=3,<4"
423+
pip install --upgrade build hatch hatch-jupyter-builder
424+
pip install "jupyterlab>=4.3.5,<5"
393425

394426
# 4) Build the distribution
395-
python3 setup.py bdist_wheel
427+
python3 -m build .
396428
```
397429

398430
You should now be able to find the built distribution at
399431

400-
`./dist/graph_notebook-4.6.2-py3-none-any.whl`
432+
`./dist/graph_notebook-5.0.0-py3-none-any.whl`
401433

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

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

410442
``` python
411-
pip install ./dist/graph_notebook-4.6.2-py3-none-any.whl
443+
pip install ./dist/graph_notebook-5.0.0-py3-none-any.whl --force-reinstall
412444
```
413445

414446
## Contributing Guidelines

additional-databases/sagemaker/sagemaker-notebook-lifecycle/install-graph-notebook-lc.sh

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,6 @@ python3 -m ipykernel install --sys-prefix --name python3 --display-name "Python
1919
echo "installing python dependencies..."
2020
pip uninstall NeptuneGraphNotebook -y # legacy uninstall when we used to install from source in s3
2121
22-
pip install "jupyter_core<=5.3.2"
23-
pip install "jupyter_server<=2.7.3"
24-
pip install "jupyter-console<=6.4.0"
25-
pip install "jupyter-client<=6.1.12"
26-
pip install "ipywidgets==7.7.2"
27-
pip install "jupyterlab_widgets==1.1.1"
28-
pip install "notebook==6.4.12"
29-
pip install "nbclient<=0.7.0"
30-
pip install "itables<=1.4.2"
31-
pip install awswrangler
32-
3322
if [[ ${NOTEBOOK_VERSION} == "" ]]; then
3423
pip install --upgrade graph-notebook
3524
else
@@ -42,16 +31,30 @@ python -m graph_notebook.nbextensions.install
4231
echo "installing static resources..."
4332
python -m graph_notebook.static_resources.install
4433
45-
echo "enabling visualization..."
34+
echo "enabling visualization for classic notebook......"
4635
if [[ ${NOTEBOOK_VERSION//./} < 330 ]] && [[ ${NOTEBOOK_VERSION} != "" ]]; then
47-
jupyter nbextension install --py --sys-prefix graph_notebook.widgets
36+
echo "Using nbextension install for version ${NOTEBOOK_VERSION} (< 3.3.0)..."
37+
jupyter nbextension install --py --sys-prefix graph_notebook.widgets
4838
fi
49-
jupyter nbextension enable --py --sys-prefix graph_notebook.widgets
5039
40+
if [[ ${NOTEBOOK_VERSION//./} < 500 ]] && [[ ${NOTEBOOK_VERSION} != "" ]]; then
41+
echo "Using nbextension enable for version ${NOTEBOOK_VERSION} (< 5.0.0)..."
42+
jupyter nbextension enable --py --sys-prefix graph_notebook.widgets
43+
else
44+
echo "Using nbclassic-extension enable for version ${NOTEBOOK_VERSION} (>= 5.0.0)..."
45+
jupyter nbclassic-extension enable --py --sys-prefix graph_notebook.widgets || {
46+
echo "nbclassic-extension enable failed, trying standard nbextension as fallback..."
47+
jupyter nbextension enable --py --sys-prefix graph_notebook.widgets
48+
}
49+
fi
50+
echo "enabled visualization..."
51+
52+
echo "Copying starter notebooks..."
5153
mkdir -p ~/SageMaker/Neptune
5254
cd ~/SageMaker/Neptune || exit
5355
python -m graph_notebook.notebooks.install
5456
chmod -R a+rw ~/SageMaker/Neptune/*
57+
echo "Copied starter notebooks..."
5558
5659
source ~/.bashrc || exit
5760
HOST=${GRAPH_NOTEBOOK_HOST}
@@ -89,7 +92,9 @@ else
8992
echo "Skipping, unsupported on graph-notebook<=3.4.1"
9093
fi
9194
92-
conda /home/ec2-user/anaconda3/bin/deactivate
95+
echo "graph-notebook installation complete."
96+
97+
conda deactivate || echo "Already deactivated or not in an environment."
9398
echo "done."
9499
95100
EOF

pyproject.toml

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
[build-system]
2+
requires = [
3+
"hatchling>=1.5.0",
4+
"jupyterlab>=4.0.0,<5.0.0",
5+
"hatch-nodejs-version",
6+
"hatch-jupyter-builder>=0.5"
7+
]
8+
build-backend = "hatchling.build"
9+
10+
[project]
11+
name = "graph-notebook"
12+
version = "5.0.0"
13+
description = "Jupyter notebook extension to connect to graph databases"
14+
readme = "README.md"
15+
license = { file = "LICENSE" }
16+
requires-python = ">=3.9,<3.12"
17+
authors = [
18+
{ name = "amazon-neptune", email = "[email protected]" },
19+
]
20+
classifiers = [
21+
"Development Status :: 5 - Production/Stable",
22+
"Programming Language :: Python :: 3.9",
23+
"Programming Language :: Python :: 3.10",
24+
"Programming Language :: Python :: 3.11",
25+
"License :: OSI Approved :: Apache Software License"
26+
]
27+
keywords = ["jupyter", "neptune", "gremlin", "sparql", "opencypher"]
28+
dependencies = [
29+
# Jupyter ecosystem
30+
'ipyfilechooser==0.6.0',
31+
'ipykernel>=6.5.0',
32+
'ipython>=7.16.1,<=8.10.0',
33+
'ipywidgets>=8.0.0,<9.0.0',
34+
'jupyter-server>=2.0.0,<3.0.0',
35+
'jupyter-server-proxy>=4.0.0,<5.0.0',
36+
'jupyter_client>=8.0.0,<9.0.0',
37+
'jupyterlab>=4.3.5,<5.0.0',
38+
'jupyterlab-widgets>=3.0.0,<4.0.0',
39+
'nbclient>=0.7.3',
40+
'nbconvert>=6.3.0,<=7.2.8',
41+
'notebook>=7.0.0,<8.0.0',
42+
'nbclassic>=1.0.0',
43+
44+
# Data processing and visualization
45+
'itables>=2.0.0,<=2.1.0',
46+
'networkx==2.4',
47+
'numpy>=1.23.5,<1.24.0',
48+
'pandas>=2.1.0,<=2.2.2',
49+
50+
# Graph databases and query languages
51+
'gremlinpython>=3.5.1,<=3.7.2',
52+
'neo4j>=5.0.0,<=5.23.1',
53+
'rdflib==7.0.0',
54+
'SPARQLWrapper==2.0.0',
55+
56+
# AWS SDK
57+
'boto3>=1.34.74',
58+
'botocore>=1.34.74',
59+
60+
# Utilities
61+
'async-timeout>=4.0,<5.0',
62+
'jedi>=0.18.1,<=0.18.2',
63+
'Jinja2>=3.0.3,<=3.1.4',
64+
'json-repair==0.29.2',
65+
'nest_asyncio>=1.5.5,<=1.6.0',
66+
'requests>=2.32.0,<=2.32.2'
67+
]
68+
69+
[project.optional-dependencies]
70+
test = [
71+
"pytest==6.2.5"
72+
]
73+
74+
[project.entry-points.ipython]
75+
graph_notebook_magics = "graph_notebook.magics:load_ipython_extension"
76+
77+
[project.entry-points.jupyter_server]
78+
serverextensions = "graph_notebook.nbextensions.install:_jupyter_server_extension_points"
79+
80+
[project.entry-points.notebook_extensions]
81+
graph_notebook_widgets = "graph_notebook.widgets:_jupyter_nbextension_paths"
82+
graph_notebook_nbextensions = "graph_notebook.nbextensions:_jupyter_nbextension_paths"
83+
84+
[project.entry-points.jupyter_labextension]
85+
graph_notebook_widgets = "graph_notebook.widgets:_jupyter_labextension_paths"
86+
87+
88+
[tool.hatch.build.hooks.jupyter-builder]
89+
dependencies = ["hatch-jupyter-builder>=0.5"]
90+
build-function = "hatch_jupyter_builder.npm_builder"
91+
ensured-targets = [
92+
"src/graph_notebook/widgets/labextension/package.json",
93+
"src/graph_notebook/widgets/labextension/static/style.js",
94+
"src/graph_notebook/widgets/nbextension/index.js",
95+
]
96+
skip-if-exists = ["src/graph_notebook/widgets/labextension/static/style.js"]
97+
98+
[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
99+
build_cmd = "build:prod"
100+
npm = ["npm", "--prefix", "src/graph_notebook/widgets"]
101+
source_dir = "src/graph_notebook/widgets"
102+
build_dir = "src/graph_notebook/widgets/lib"
103+
104+
[tool.hatch.build]
105+
artifacts = [
106+
"src/graph_notebook/widgets/labextension",
107+
"src/graph_notebook/widgets/nbextension",
108+
]
109+
110+
[tool.hatch.build.targets.wheel.shared-data]
111+
"src/graph_notebook/widgets/labextension" = "share/jupyter/labextensions/graph_notebook_widgets"
112+
"src/graph_notebook/widgets/nbextension" = "share/jupyter/nbextensions/graph_notebook_widgets"
113+
"src/graph_notebook/widgets/graph_notebook_widgets.json" = "etc/jupyter/nbconfig/notebook.d/graph_notebook_widgets.json"
114+
"src/graph_notebook/nbextensions" = "share/jupyter/nbextensions/graph_notebook"
115+
116+
[tool.hatch.build.targets.sdist]
117+
exclude = [
118+
"/.github",
119+
"/docs",
120+
"node_modules",
121+
]
122+
123+
[tool.hatch.build.targets.wheel]
124+
packages = ["src/graph_notebook"]
125+
include = [
126+
"src/graph_notebook/**/*.py",
127+
"src/graph_notebook/**/*.ipynb",
128+
"src/graph_notebook/**/*.json",
129+
"src/graph_notebook/**/*.txt",
130+
"src/graph_notebook/**/*.html",
131+
"src/graph_notebook/**/*.css",
132+
"src/graph_notebook/**/*.js",
133+
"src/graph_notebook/**/*.yaml",
134+
"src/graph_notebook/**/*.csv"
135+
]

0 commit comments

Comments
 (0)