Skip to content

Commit 1068ac5

Browse files
authored
updates to graph_notebook_config for Amazon Neptune Proxy Connection (#504)
* updates to graph_notebook_config for Amazon Neptune Proxy Connection * no more mardown warnings on README * Typo * Update README.md
1 parent 6bb8a0b commit 1068ac5

File tree

1 file changed

+76
-32
lines changed

1 file changed

+76
-32
lines changed

README.md

Lines changed: 76 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
## Graph Notebook: easily query and visualize graphs
1+
# Graph Notebook: easily query and visualize graphs
22

33
The graph notebook provides an easy way to interact with graph databases using Jupyter notebooks. Using this open-source Python package, you can connect to any graph database that supports the [Apache TinkerPop](https://tinkerpop.apache.org/), [openCypher](https://github.com/opencypher/openCypher) or the [RDF SPARQL](https://www.w3.org/TR/rdf-sparql-query/) graph models. These databases could be running locally on your desktop or in the cloud. Graph databases can be used to explore a variety of use cases including [knowledge graphs](https://aws.amazon.com/neptune/knowledge-graphs-on-aws/) and [identity graphs](https://aws.amazon.com/neptune/identity-graphs-on-aws/).
44

55
![A colorful graph picture](./images/ColorfulGraph.png)
66

7-
8-
### Visualizing Gremlin queries:
7+
## Visualizing Gremlin queries
98

109
![Gremlin query and graph](./images/GremlinQueryGraph.png)
1110

12-
### Visualizing openCypher queries
11+
## Visualizing openCypher queries
1312

1413
![openCypher query and graph](./images/OCQueryGraph.png)
1514

16-
### Visualizing SPARQL queries:
15+
## Visualizing SPARQL queries
1716

1817
![SPARL query and graph](./images/SPARQLQueryGraph.png)
1918

@@ -30,7 +29,8 @@ We encourage others to contribute configurations they find useful. There is an [
3029

3130
## Features
3231

33-
#### Notebook cell 'magic' extensions in the IPython 3 kernel
32+
### Notebook cell 'magic' extensions in the IPython 3 kernel
33+
3434
`%%sparql` - Executes a SPARQL query against your configured database endpoint. [Documentation](https://docs.aws.amazon.com/neptune/latest/userguide/notebooks-magics.html#notebooks-cell-magics-sparql)
3535

3636
`%%gremlin` - Executes a Gremlin query against your database using web sockets. The results are similar to those a Gremlin console would return. [Documentation](https://docs.aws.amazon.com/neptune/latest/userguide/notebooks-magics.html#notebooks-cell-magics-gremlin)
@@ -48,6 +48,7 @@ We encourage others to contribute configurations they find useful. There is an [
4848
**TIP** :point_right: There is syntax highlighting for language query magic cells to help you structure your queries more easily.
4949

5050
#### Notebook line 'magic' extensions in the IPython 3 kernel
51+
5152
`%gremlin_status` - Obtain the status of Gremlin queries. [Documentation](https://docs.aws.amazon.com/neptune/latest/userguide/gremlin-api-status.html)
5253

5354
`%sparql_status` - Obtain the status of SPARQL queries. [Documentation](https://docs.aws.amazon.com/neptune/latest/userguide/sparql-api-status.html)
@@ -84,9 +85,11 @@ We encourage others to contribute configurations they find useful. There is an [
8485
**TIP** :point_right: Many of the magic commands support a `--help` option in order to provide additional information.
8586

8687
## Example notebooks
88+
8789
This project includes many example Jupyter notebooks. It is recommended to explore them. All of the commands and features supported by `graph-notebook` are explained in detail with examples within the sample notebooks. You can find them [here](./src/graph_notebook/notebooks/). As this project has evolved, many new features have been added. If you are already familiar with graph-notebook but want a quick summary of new features added, a good place to start is the Air-Routes notebooks in the [02-Visualization](./src/graph_notebook/notebooks/02-Visualization) folder.
8890

8991
## Keeping track of new features
92+
9093
It is recommended to check the [ChangeLog.md](ChangeLog.md) file periodically to keep up to date as new features are added.
9194

9295
## Prerequisites
@@ -95,22 +98,22 @@ You will need:
9598

9699
* [Python](https://www.python.org/downloads/) 3.7.x-3.10.11
97100
* A graph database that provides one or more of:
98-
* A SPARQL 1.1 endpoint
99-
* An Apache TinkerPop Gremlin Server compatible endpoint
100-
* An endpoint compatible with openCypher
101+
* A SPARQL 1.1 endpoint
102+
* An Apache TinkerPop Gremlin Server compatible endpoint
103+
* An endpoint compatible with openCypher
101104

102105
## Installation
103106

104107
Begin by installing `graph-notebook` and its prerequisites, then follow the remaining instructions for either Jupyter Classic Notebook or JupyterLab.
105108

106-
```
109+
``` bash
107110
# install the package
108111
pip install graph-notebook
109112
```
110113

111114
### Jupyter Classic Notebook
112115

113-
```
116+
``` bash
114117
# Enable the visualization widget
115118
jupyter nbextension enable --py --sys-prefix graph_notebook.widgets
116119

@@ -131,7 +134,7 @@ python -m graph_notebook.start_notebook --notebooks-dir ~/notebook/destination/d
131134

132135
### JupyterLab 3.x
133136

134-
```
137+
``` bash
135138
# install jupyterlab
136139
pip install "jupyterlab>=3,<4"
137140

@@ -145,23 +148,26 @@ python -m graph_notebook.start_jupyterlab --jupyter-dir ~/notebook/destination/d
145148
#### Loading magic extensions in JupyterLab
146149

147150
When attempting to run a line/cell magic on a new notebook in JupyterLab, you may encounter the error:
148-
```
151+
152+
``` bash
149153
UsageError: Cell magic `%%graph_notebook_config` not found.
150154
```
151155

152-
To fix this, run the following command, then restart JupyterLab.
153-
```
156+
To fix this, run the following command, then restart JupyterLab.
157+
158+
``` bash
154159
python -m graph_notebook.ipython_profile.configure_ipython_profile
155160
```
156161

157162
Alternatively, the magic extensions can be manually reloaded for a single notebook by running the following command in any empty cell.
158-
```
163+
164+
``` bash
159165
%load_ext graph_notebook.magics
160166
```
161167

162168
## Upgrading an existing installation
163169

164-
```
170+
``` bash
165171
# upgrade graph-notebook
166172
pip install graph-notebook --upgrade
167173
```
@@ -170,11 +176,28 @@ After the above command completes, rerun the commands given at [Jupyter Classic
170176

171177
## Connecting to a graph database
172178

179+
Configuration options can be set using the `%graph_notebook_config` magic command. The command accepts a JSON object as an argument. The JSON object can contain any of the configuration options listed below. The command can be run multiple times to change the configuration. The configuration is stored in the notebook's metadata and will be used for all subsequent queries.
180+
181+
| Configuration Option | Description | Default Value | Type |
182+
| --- | --- | --- | --- |
183+
| auth_mode | The authentication mode to use for Amazon Neptune connections | DEFAULT | string |
184+
| aws_region | The AWS region to use for Amazon Neptune connections | your-region-1 | string |
185+
| host | The host url to form a connection with | localhost | string |
186+
| load_from_s3_arn | The ARN of the S3 bucket to load data from [Amazon Neptune only] | | string |
187+
| port | The port to use when creating a connection | 8182 | number |
188+
| proxy_host | The proxy host url to route a connection through [Amazon Neptune only]| | string |
189+
| proxy_port | The proxy port to use when creating proxy connection [Amazon Neptune only] | 8182 | number |
190+
| ssl | Whether to make connections to the created endpoint with ssl or not [True/False] | False | boolean |
191+
| ssl_verify | Whether to verify the server's TLS certificate or not [True/False] | True | boolean |
192+
| sparql | SPARQL connection object | ``` { "path": "sparql" } ``` | string |
193+
| gremlin | Gremlin connection object | ``` { "username": "", "password": "", "traversal_source": "g", "message_serializer": "graphsonv3" } ```| string |
194+
| neo4j | Neo4J connection object |``` { "username": "neo4j", "password": "password", "auth": true, "database": null } ``` | string |
195+
173196
### Gremlin Server
174197

175198
In a new cell in the Jupyter notebook, change the configuration using `%%graph_notebook_config` and modify the fields for `host`, `port`, and `ssl`. Optionally, modify `traversal_source` if your graph traversal source name differs from the default value, `username` and `password` if required by the graph store, or `message_serializer` for a specific data transfer format. For a local Gremlin server (HTTP or WebSockets), you can use the following command:
176199

177-
```
200+
``` python
178201
%%graph_notebook_config
179202
{
180203
"host": "localhost",
@@ -195,7 +218,7 @@ To setup a new local Gremlin Server for use with the graph notebook, check out [
195218

196219
Change the configuration using `%%graph_notebook_config` and modify the fields for `host`, `port`, and `ssl`. For a local Blazegraph database, you can use the following command:
197220

198-
```
221+
``` python
199222
%%graph_notebook_config
200223
{
201224
"host": "localhost",
@@ -209,7 +232,7 @@ Change the configuration using `%%graph_notebook_config` and modify the fields f
209232

210233
You can also make use of namespaces for Blazegraph by specifying the path `graph-notebook` should use when querying your SPARQL like below:
211234

212-
```
235+
``` python
213236
%%graph_notebook_config
214237

215238
{
@@ -230,7 +253,7 @@ To setup a new local Blazegraph database for use with the graph notebook, check
230253

231254
Change the configuration using `%%graph_notebook_config` and modify the defaults as they apply to your Neptune cluster:
232255

233-
```
256+
``` python
234257
%%graph_notebook_config
235258
{
236259
"host": "your-neptune-endpoint",
@@ -242,15 +265,36 @@ Change the configuration using `%%graph_notebook_config` and modify the defaults
242265
"aws_region": "your-neptune-region"
243266
}
244267
```
268+
245269
To setup a new Amazon Neptune cluster, check out the [Amazon Web Services documentation](https://docs.aws.amazon.com/neptune/latest/userguide/manage-console-launch.html).
246270

247271
When connecting the graph notebook to Neptune, make sure you have a network setup to communicate to the VPC that Neptune runs on. If not, you can follow [this guide](https://github.com/aws/graph-notebook/tree/main/additional-databases/neptune).
248272

273+
in addition to the above configuration options, you can also specify the following options:
274+
275+
### Amazon Neptune Proxy Connection
276+
277+
``` python
278+
%%graph_notebook_config
279+
{
280+
"host": "clustername.cluster-ididididid.us-east-1.neptune.amazonaws.com",
281+
"port": 8182,
282+
"ssl": true,
283+
"proxy_port": 8182,
284+
"proxy_host": "host.proxy.com",
285+
"auth_mode": "IAM",
286+
"aws_region": "us-east-1",
287+
"load_from_s3_arn": ""
288+
}
289+
```
290+
291+
Connecting to Amazon Neptune from clients outside the Neptune VPC using AWS Network [Load Balancer](https://aws-samples.github.io/aws-dbs-refarch-graph/src/connecting-using-a-load-balancer/#connecting-to-amazon-neptune-from-clients-outside-the-neptune-vpc-using-aws-network-load-balancer)
292+
249293
## Authentication (Amazon Neptune)
250294

251295
If you are running a SigV4 authenticated endpoint, ensure that your configuration has `auth_mode` set to `IAM`:
252296

253-
```
297+
``` python
254298
%%graph_notebook_config
255299
{
256300
"host": "your-neptune-endpoint",
@@ -265,24 +309,24 @@ If you are running a SigV4 authenticated endpoint, ensure that your configuratio
265309

266310
Additionally, you should have the following Amazon Web Services credentials available in a location accessible to Boto3:
267311

268-
- Access Key ID
269-
- Secret Access Key
270-
- Default Region
271-
- Session Token (OPTIONAL. Use if you are using temporary credentials)
312+
* Access Key ID
313+
* Secret Access Key
314+
* Default Region
315+
* Session Token (OPTIONAL. Use if you are using temporary credentials)
272316

273317
These variables must follow a specific naming convention, as listed in the [Boto3 documentation](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/configuration.html#using-environment-variables)
274318

275319
A list of all locations checked for Amazon Web Services credentials can also be found [here](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html#configuring-credentials).
276320

277321
### Neo4J
278322

279-
Change the configuration using `%%graph_notebook_config` and modify the fields for `host`, `port`, `ssl`, and `neo4j` authentication.
323+
Change the configuration using `%%graph_notebook_config` and modify the fields for `host`, `port`, `ssl`, and `neo4j` authentication.
280324

281325
If your Neo4J instance supports [multiple databases](https://neo4j.com/developer/manage-multiple-databases/), you can specify a database name via the `database` field. Otherwise, leave the `database` field blank to query the default database.
282326

283327
For a local Neo4j Desktop database, you can use the following command:
284328

285-
```
329+
``` python
286330
%%graph_notebook_config
287331
{
288332
"host": "localhost",
@@ -305,7 +349,7 @@ To setup a new local Neo4J Desktop database for use with the graph notebook, che
305349

306350
A pre-release distribution can be built from the graph-notebook repository via the following steps:
307351

308-
```
352+
``` bash
309353
# 1) Clone the repository and navigate into the clone directory
310354
git clone https://github.com/aws/graph-notebook.git
311355
cd graph-notebook
@@ -336,16 +380,16 @@ You should now be able to find the built distribution at
336380

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

339-
```
383+
``` python
340384
pip install graph-notebook
341385
```
342386

343387
with
344388

345-
```
389+
``` python
346390
pip install ./dist/graph_notebook-3.8.2-py3-none-any.whl
347-
```
348391

392+
```
349393

350394
## Contributing Guidelines
351395

0 commit comments

Comments
 (0)