Skip to content

Commit 27388d5

Browse files
RafalSkolasinskiFlorentinD
authored andcommitted
remove dotenv block + generate docs
1 parent deb833c commit 27388d5

File tree

3 files changed

+30
-37
lines changed

3 files changed

+30
-37
lines changed

doc/modules/ROOT/pages/tutorials/graph-analytics-serverless-self-managed.adoc

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,10 @@ As the data source, we assume that a self-managed Neo4j DBMS instance
6969
has been set up and is accessible. We need to pass the database address,
7070
user name and password to the `DbmsConnectionInfo` class.
7171

72-
We also need to specify the session size. Please refer to the API
73-
reference documentation or the manual for a full list.
72+
We also need to specify the session `memory` and `cloud++_++location`.
73+
Please refer to the API reference
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.
7476

7577
Finally, we need to give our session a name. We will call ours
7678
`people-and-fruits-sm'. It is possible to reconnect to an existing session by calling`get++_++or++_++create++`++
@@ -83,7 +85,7 @@ delete the session ourselves.
8385

8486
[source, python, role=no-test]
8587
----
86-
from graphdatascience.session import AlgorithmCategory, SessionMemory
88+
from graphdatascience.session import AlgorithmCategory, CloudLocation, SessionMemory
8789
8890
# Explicitly define the size of the session
8991
memory = SessionMemory.m_8GB
@@ -97,10 +99,12 @@ memory = sessions.estimate(
9799
98100
print(f"Estimated memory: {memory}")
99101
100-
# Find out and specify where to create the GDS session
102+
# Specify your cloud location
103+
cloud_location = CloudLocation("gcp", "europe-west1")
104+
105+
# You can find available cloud locations by calling
101106
cloud_locations = sessions.available_cloud_locations()
102107
print(f"Available locations: {cloud_locations}")
103-
cloud_location = cloud_locations[0]
104108
----
105109

106110
[source, python, role=no-test]

doc/modules/ROOT/pages/tutorials/graph-analytics-serverless-standalone.adoc

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The notebook shows how to use the `graphdatascience` Python library to
1515
create, manage, and use a GDS Session.
1616

1717
We consider a graph of people and fruits, which we’re using as a simple
18-
example to show how to load data from Pandas DataFrames to a GDS
18+
example to show how to load data from Pandas `DataFrame` to a GDS
1919
Session, run algorithms, and inspect the results. We will cover all
2020
management operations: creation, listing, and deletion.
2121

@@ -66,16 +66,16 @@ sessions = GdsSessions(api_credentials=AuraAPICredentials(client_id, client_secr
6666
== Creating a new session
6767

6868
A new session is created by calling `sessions.get++_++or++_++create()`.
69-
As the data source, we assume that a self-managed Neo4j DBMS instance
70-
has been set up and is accessible. We need to pass the database address,
71-
user name and password to the `DbmsConnectionInfo` class.
69+
We also need to specify the session `memory` and `cloud++_++location`.
7270

73-
We also need to specify the session size. Please refer to the API
74-
reference documentation or the manual for a full list.
71+
Please refer to the API reference
72+
https://neo4j.com/docs/graph-data-science-client/current/api/sessions/gds_sessions/#graphdatascience.session.gds_sessions.GdsSessions.get_or_create[documentation]
73+
or the manual for a full list options.
7574

7675
Finally, we need to give our session a name. We will call ours
77-
`people-and-fruits-sm'. It is possible to reconnect to an existing session by calling`get++_++or++_++create++`++
78-
with the same session name and configuration.
76+
`people-and-fruits-standalone`. It is possible to reconnect to an
77+
existing session by calling `get++_++or++_++create` with the same
78+
session name and configuration.
7979

8080
We will also set a time-to-live (TTL) for the session. This ensures that
8181
our session is automatically deleted after being unused for 30 minutes.
@@ -84,7 +84,7 @@ delete the session ourselves.
8484

8585
[source, python, role=no-test]
8686
----
87-
from graphdatascience.session import AlgorithmCategory, SessionMemory
87+
from graphdatascience.session import AlgorithmCategory, CloudLocation, SessionMemory
8888
8989
# Explicitly define the size of the session
9090
memory = SessionMemory.m_4GB
@@ -98,19 +98,24 @@ memory = sessions.estimate(
9898
9999
print(f"Estimated memory: {memory}")
100100
101-
# Find out and specify where to create the GDS session
101+
# Specify your cloud location
102+
cloud_location = CloudLocation("gcp", "europe-west1")
103+
104+
# You can find available cloud locations by calling
102105
cloud_locations = sessions.available_cloud_locations()
103106
print(f"Available locations: {cloud_locations}")
104-
cloud_location = cloud_locations[0]
105107
----
106108

107109
[source, python, role=no-test]
108110
----
111+
from datetime import timedelta
112+
109113
# Create a GDS session!
110114
gds = sessions.get_or_create(
111115
# we give it a representative name
112116
session_name="people-and-fruits-standalone",
113117
memory=memory,
118+
ttl=timedelta(minutes=30),
114119
cloud_location=cloud_location,
115120
)
116121
----
@@ -179,16 +184,15 @@ knows_df["relationshipType"] = "KNOWS"
179184

180185
Now that we have imported a graph to our database, we create graphs
181186
directly from pandas `DataFrame` objects. We do that by using the
182-
`gds.graph.construct()` endpoint.
187+
`gds.graph.construct()` method.
183188

184189
[source, python, role=no-test]
185190
----
186-
nodes = [people_df.drop(columns="name"), fruits_df.drop(columns="name")] # GDS does not support string properties
191+
# Dropping `name` column as GDS does not support string properties
192+
nodes = [people_df.drop(columns="name"), fruits_df.drop(columns="name")]
187193
relationships = [likes_df, knows_df]
188194
189195
G = gds.graph.construct("people-fruits", nodes, relationships)
190-
191-
192196
str(G)
193197
----
194198

@@ -222,16 +226,15 @@ print(f"Compute millis: {frp_result['computeMillis']}")
222226
# stream back the results
223227
result = gds.graph.nodeProperties.stream(G, ["pagerank", "fastRP"], separate_property_columns=True)
224228
225-
print(result)
229+
result
226230
----
227231

228-
To resolve the nodeIds to names, we can merge it back with the source
232+
To resolve each `nodeId` to name, we can merge it back with the source
229233
data frames.
230234

231235
[source, python, role=no-test]
232236
----
233237
names = pd.concat([people_df, fruits_df])[["nodeId", "name"]]
234-
235238
result.merge(names, how="left")
236239
----
237240

examples/graph-analytics-serverless-standalone.ipynb

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,5 @@
11
{
22
"cells": [
3-
{
4-
"cell_type": "code",
5-
"execution_count": null,
6-
"metadata": {},
7-
"outputs": [],
8-
"source": [
9-
"import os\n",
10-
"\n",
11-
"from dotenv import load_dotenv\n",
12-
"\n",
13-
"cfg_path = \"~/Documents/Credentials/devrafal/python-client.env\"\n",
14-
"load_dotenv(os.path.expanduser(cfg_path))"
15-
]
16-
},
173
{
184
"cell_type": "markdown",
195
"metadata": {

0 commit comments

Comments
 (0)