You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+76-32Lines changed: 76 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,18 @@
1
-
##Graph Notebook: easily query and visualize graphs
1
+
# Graph Notebook: easily query and visualize graphs
2
2
3
3
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/).

11
10
12
-
###Visualizing openCypher queries
11
+
## Visualizing openCypher queries
13
12
14
13

15
14
16
-
###Visualizing SPARQL queries:
15
+
## Visualizing SPARQL queries
17
16
18
17

19
18
@@ -30,7 +29,8 @@ We encourage others to contribute configurations they find useful. There is an [
30
29
31
30
## Features
32
31
33
-
#### Notebook cell 'magic' extensions in the IPython 3 kernel
32
+
### Notebook cell 'magic' extensions in the IPython 3 kernel
33
+
34
34
`%%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)
35
35
36
36
`%%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 [
48
48
**TIP**:point_right: There is syntax highlighting for language query magic cells to help you structure your queries more easily.
49
49
50
50
#### Notebook line 'magic' extensions in the IPython 3 kernel
51
+
51
52
`%gremlin_status` - Obtain the status of Gremlin queries. [Documentation](https://docs.aws.amazon.com/neptune/latest/userguide/gremlin-api-status.html)
52
53
53
54
`%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 [
84
85
**TIP**:point_right: Many of the magic commands support a `--help` option in order to provide additional information.
85
86
86
87
## Example notebooks
88
+
87
89
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.
88
90
89
91
## Keeping track of new features
92
+
90
93
It is recommended to check the [ChangeLog.md](ChangeLog.md) file periodically to keep up to date as new features are added.
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
159
165
%load_ext graph_notebook.magics
160
166
```
161
167
162
168
## Upgrading an existing installation
163
169
164
-
```
170
+
```bash
165
171
# upgrade graph-notebook
166
172
pip install graph-notebook --upgrade
167
173
```
@@ -170,11 +176,28 @@ After the above command completes, rerun the commands given at [Jupyter Classic
170
176
171
177
## Connecting to a graph database
172
178
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 |
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:
176
199
177
-
```
200
+
```python
178
201
%%graph_notebook_config
179
202
{
180
203
"host": "localhost",
@@ -195,7 +218,7 @@ To setup a new local Gremlin Server for use with the graph notebook, check out [
195
218
196
219
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:
197
220
198
-
```
221
+
```python
199
222
%%graph_notebook_config
200
223
{
201
224
"host": "localhost",
@@ -209,7 +232,7 @@ Change the configuration using `%%graph_notebook_config` and modify the fields f
209
232
210
233
You can also make use of namespaces for Blazegraph by specifying the path `graph-notebook` should use when querying your SPARQL like below:
211
234
212
-
```
235
+
```python
213
236
%%graph_notebook_config
214
237
215
238
{
@@ -230,7 +253,7 @@ To setup a new local Blazegraph database for use with the graph notebook, check
230
253
231
254
Change the configuration using `%%graph_notebook_config` and modify the defaults as they apply to your Neptune cluster:
232
255
233
-
```
256
+
```python
234
257
%%graph_notebook_config
235
258
{
236
259
"host": "your-neptune-endpoint",
@@ -242,15 +265,36 @@ Change the configuration using `%%graph_notebook_config` and modify the defaults
242
265
"aws_region": "your-neptune-region"
243
266
}
244
267
```
268
+
245
269
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).
246
270
247
271
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).
248
272
273
+
in addition to the above configuration options, you can also specify the following options:
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
+
249
293
## Authentication (Amazon Neptune)
250
294
251
295
If you are running a SigV4 authenticated endpoint, ensure that your configuration has `auth_mode` set to `IAM`:
252
296
253
-
```
297
+
```python
254
298
%%graph_notebook_config
255
299
{
256
300
"host": "your-neptune-endpoint",
@@ -265,24 +309,24 @@ If you are running a SigV4 authenticated endpoint, ensure that your configuratio
265
309
266
310
Additionally, you should have the following Amazon Web Services credentials available in a location accessible to Boto3:
267
311
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)
272
316
273
317
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)
274
318
275
319
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).
276
320
277
321
### Neo4J
278
322
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.
280
324
281
325
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.
282
326
283
327
For a local Neo4j Desktop database, you can use the following command:
284
328
285
-
```
329
+
```python
286
330
%%graph_notebook_config
287
331
{
288
332
"host": "localhost",
@@ -305,7 +349,7 @@ To setup a new local Neo4J Desktop database for use with the graph notebook, che
305
349
306
350
A pre-release distribution can be built from the graph-notebook repository via the following steps:
307
351
308
-
```
352
+
```bash
309
353
# 1) Clone the repository and navigate into the clone directory
0 commit comments