@@ -25,12 +25,12 @@ example].
25
25
26
26
== Prerequisites
27
27
28
- This notebook requires having a Neo4j instance instance available and
29
- that the Graph Analytics Serverless
28
+ This notebook requires having a Neo4j instance available and that the
29
+ Graph Analytics Serverless
30
30
https://neo4j.com/docs/aura/graph-analytics/#aura-gds-serverless[feature]
31
31
is enabled for your Neo4j Aura project.
32
32
33
- We also need to have the `graphdatascience` Python library installed,
33
+ You also need to have the `graphdatascience` Python library installed,
34
34
version `1.15` or later.
35
35
36
36
[source, python, role=no-test]
@@ -40,12 +40,9 @@ version `1.15` or later.
40
40
41
41
== Aura API credentials
42
42
43
- A GDS Session is managed via the Aura API. In order to use the Aura API,
44
- we need to have https://neo4j.com/docs/aura/api/authentication[Aura API
45
- credentials].
46
-
47
- Using these credentials, we can create our `GdsSessions` object, which
48
- is the main entry point for managing GDS Sessions.
43
+ The entry point for managing GDS Sessions is the `GdsSessions` object,
44
+ which requires creating
45
+ https://neo4j.com/docs/aura/api/authentication[Aura API credentials].
49
46
50
47
[source, python, role=no-test]
51
48
----
@@ -64,24 +61,18 @@ sessions = GdsSessions(api_credentials=AuraAPICredentials(client_id, client_secr
64
61
65
62
== Creating a new session
66
63
67
- A new session is created by calling `sessions.get++_++or++_++create()`.
68
- As the data source, we assume that a self-managed Neo4j DBMS instance
69
- has been set up and is accessible. We need to pass the database address,
70
- user name and password to the `DbmsConnectionInfo` class.
64
+ A new session is created by calling `sessions.get++_++or++_++create()`
65
+ with the following parameters: ++*++ A session name, which lets you
66
+ reconnect to an existing session by calling `get++_++or++_++create`
67
+ again. ++*++ The `DbmsConnectionInfo` containing the address, user name
68
+ and password for an accessible self-manged Neo4j DBMS instance ++*++ The
69
+ session memory. ++*++ The cloud location. ++*++ A time-to-live (TTL),
70
+ which ensures that the session is automatically deleted after being
71
+ unused for the set time, to avoid incurring costs.
71
72
72
- We also need to specify the session `memory` and `cloud++_++location`.
73
- Please refer to the API reference
73
+ See the API reference
74
74
https://neo4j.com/docs/graph-data-science-client/current/api/sessions/gds_sessions/#graphdatascience.session.gds_sessions.GdsSessions.get_or_create[documentation]
75
- or the manual for a full list options.
76
-
77
- Finally, we need to give our session a name. We will call ours
78
- `people-and-fruits-sm'. It is possible to reconnect to an existing session by calling`get++_++or++_++create++`++
79
- with the same session name and configuration.
80
-
81
- We will also set a time-to-live (TTL) for the session. This ensures that
82
- our session is automatically deleted after being unused for 30 minutes.
83
- This is a good practice to avoid incurring costs should we forget to
84
- delete the session ourselves.
75
+ or the manual for more details on the parameters.
85
76
86
77
[source, python, role=no-test]
87
78
----
@@ -121,7 +112,7 @@ db_connection = DbmsConnectionInfo(
121
112
122
113
# Create a GDS session!
123
114
gds = sessions.get_or_create(
124
- # we give it a representative name
115
+ # give it a representative name
125
116
session_name="people-and-fruits-sm",
126
117
memory=memory,
127
118
db_connection=db_connection,
@@ -132,8 +123,8 @@ gds = sessions.get_or_create(
132
123
133
124
== Listing sessions
134
125
135
- Now that we have created a session, let’s list all our sessions to see
136
- what that looks like
126
+ You can use `sessions.list()` to see the details for each created
127
+ session.
137
128
138
129
[source, python, role=no-test]
139
130
----
@@ -147,10 +138,10 @@ DataFrame(gds_sessions)
147
138
148
139
== Adding a dataset
149
140
150
- We assume that the configured Neo4j database instance is empty. We will
151
- add our dataset using standard Cypher.
141
+ We assume that the configured Neo4j database instance is empty. You will
142
+ add the dataset using standard Cypher.
152
143
153
- In a more realistic scenario, this step is already done, and we would
144
+ In a more realistic scenario, this step is already done, and you would
154
145
just connect to the existing database.
155
146
156
147
[source, python, role=no-test]
@@ -201,15 +192,15 @@ gds.run_cypher("MATCH (n) RETURN count(n) AS nodeCount")
201
192
202
193
== Projecting Graphs
203
194
204
- Now that we have imported a graph to our database, we can project it
205
- into our GDS Session. We do that by using the `gds.graph.project()`
195
+ Now that you have imported a graph to the database, you can project it
196
+ into our GDS Session. You do that by using the `gds.graph.project()`
206
197
endpoint.
207
198
208
- The remote projection query that we are using selects all `Person` nodes
209
- and their `LIKES` relationships, and all `Fruit` nodes and their `LIKES`
210
- relationships. Additionally, we project node properties for illustrative
211
- purposes. We can use these node properties as input to algorithms,
212
- although we do not do that in this notebook.
199
+ The remote projection query that you are using selects all `Person`
200
+ nodes and their `LIKES` relationships, and all `Fruit` nodes and their
201
+ `LIKES` relationships. Additionally, node properties are projected for
202
+ illustrative purposes. You can use these node properties as input to
203
+ algorithms, although it is note done in this notebook.
213
204
214
205
[source, python, role=no-test]
215
206
----
@@ -246,12 +237,8 @@ str(G)
246
237
247
238
== Running Algorithms
248
239
249
- We can now run algorithms on the projected graph. This is done using the
250
- standard GDS Python Client API. There are many other tutorials covering
251
- some interesting things we can do at this step, so we will keep it
252
- rather brief here.
253
-
254
- We will simply run PageRank and FastRP on the graph.
240
+ You can run algorithms on the constructed graph using the standard GDS
241
+ Python Client API. See the other tutorials for more examples.
255
242
256
243
[source, python, role=no-test]
257
244
----
@@ -289,15 +276,15 @@ the PageRank and FastRP algorithms to the Neo4j database.
289
276
gds.graph.nodeProperties.write(G, ["pagerank", "fastRP"])
290
277
----
291
278
292
- Of course, we can just use `.write` modes as well. Let’s run Louvain in
279
+ Of course, you can just use `.write` modes as well. Let’s run Louvain in
293
280
write mode to show:
294
281
295
282
[source, python, role=no-test]
296
283
----
297
284
gds.louvain.write(G, writeProperty="louvain")
298
285
----
299
286
300
- We can now use the `gds.run++_++cypher()` method to query the updated
287
+ You can now use the `gds.run++_++cypher()` method to query the updated
301
288
graph. Note that the `run++_++cypher()` method will run the query on the
302
289
Neo4j database.
303
290
@@ -314,10 +301,10 @@ gds.run_cypher(
314
301
315
302
== Deleting the session
316
303
317
- Now that we have finished our analysis, we can delete the session. The
318
- results that we produced were written back to our Neo4j database, and
319
- will not be lost. If we computed additional things that we did not write
320
- back, those will be lost.
304
+ Now that you have finished the analysis, you can delete the session. The
305
+ results that you produced were written back to our Neo4j database, and
306
+ will not be lost. If you computed additional things that you did not
307
+ write back, those will be lost.
321
308
322
309
Deleting the session will release all resources associated with it, and
323
310
stop incurring costs.
@@ -339,9 +326,3 @@ sessions.list()
339
326
# Lastly, let's clean up the database
340
327
gds.run_cypher("MATCH (n:Person|Fruit) DETACH DELETE n")
341
328
----
342
-
343
- == Conclusion
344
-
345
- And we’re done! We have created a GDS Session, projected a graph, run
346
- some algorithms, written back the results, and deleted the session. This
347
- is a simple example, but it shows the main steps of using GDS Sessions.
0 commit comments