Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -33,14 +33,14 @@ 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: |
jupyter nbextension enable --py --sys-prefix graph_notebook.widgets
jupyter nbclassic-extension enable --py --sys-prefix graph_notebook.widgets
python -m graph_notebook.static_resources.install
python -m graph_notebook.nbextensions.install
python -m graph_notebook.notebooks.install
- name: Test with pytest
run: |
pytest test/unit
pytest test/unit
Empty file removed =3,
Empty file.
60 changes: 46 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,26 +96,26 @@ 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
jupyter nbclassic-extension enable --py --sys-prefix graph_notebook.widgets

# copy static html resources
python -m graph_notebook.static_resources.install
Expand All @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the --force-reinstall necessary? If it is, would it be worth adding a comment about why it is necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--force-reinstall not necessary per se. But since it is only for development, I thought it would be good to guarantees that subsequent builds with local changes will override existing installations, ensuring the latest changes are always reflected in the local installation.

```

## Contributing Guidelines
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -42,16 +31,30 @@ python -m graph_notebook.nbextensions.install
echo "installing static resources..."
python -m graph_notebook.static_resources.install

echo "enabling visualization..."
echo "enabling visualization for classic notebook......"
if [[ ${NOTEBOOK_VERSION//./} < 330 ]] && [[ ${NOTEBOOK_VERSION} != "" ]]; then
jupyter nbextension install --py --sys-prefix graph_notebook.widgets
echo "Using nbextension install for version ${NOTEBOOK_VERSION} (< 3.3.0)..."
jupyter nbextension install --py --sys-prefix graph_notebook.widgets
fi
jupyter nbextension enable --py --sys-prefix graph_notebook.widgets

if [[ ${NOTEBOOK_VERSION//./} < 500 ]] && [[ ${NOTEBOOK_VERSION} != "" ]]; then
echo "Using nbextension enable for version ${NOTEBOOK_VERSION} (< 5.0.0)..."
jupyter nbextension enable --py --sys-prefix graph_notebook.widgets
else
echo "Using nbclassic-extension enable for version ${NOTEBOOK_VERSION} (>= 5.0.0)..."
jupyter nbclassic-extension enable --py --sys-prefix graph_notebook.widgets || {
echo "nbclassic-extension enable failed, trying standard nbextension as fallback..."
jupyter nbextension enable --py --sys-prefix graph_notebook.widgets
}
fi
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}
Expand Down Expand Up @@ -89,7 +92,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
135 changes: 135 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
[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',
'notebook>=7.0.0,<8.0.0',
'nbclassic>=1.0.0',

# 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"

[project.entry-points.jupyter_server]
serverextensions = "graph_notebook.nbextensions.install:_jupyter_server_extension_points"

[project.entry-points.notebook_extensions]
graph_notebook_widgets = "graph_notebook.widgets:_jupyter_nbextension_paths"
graph_notebook_nbextensions = "graph_notebook.nbextensions:_jupyter_nbextension_paths"

[project.entry-points.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"
"src/graph_notebook/nbextensions" = "share/jupyter/nbextensions/graph_notebook"

[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"
]
Loading