Skip to content

Commit 4ea6f90

Browse files
authored
Format notebooks with ruff (#768)
* Format notebooks with ruff * Update nbconvert & fix title level * Print notebook diff * Bump dependencies to match CI * Format notebooks using pandoc 3.3.1 brew updated to 3.5 (and only has one version)
1 parent 83e5d02 commit 4ea6f90

24 files changed

+106
-67
lines changed

doc/modules/ROOT/pages/tutorials/centrality-algorithms.adoc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ connection to the database.
3434

3535
[source, python, role=no-test]
3636
----
37-
from graphdatascience import GraphDataScience
38-
import pandas as pd
3937
import os
38+
39+
import pandas as pd
40+
41+
from graphdatascience import GraphDataScience
4042
----
4143

4244
[source, python, role=no-test]
@@ -101,8 +103,8 @@ gds.run_cypher(
101103
102104
gds.run_cypher(
103105
"""
104-
UNWIND $rels AS rel
105-
MATCH (source:City {node_id: rel.Origin}), (target:City {node_id: rel.Destination})
106+
UNWIND $rels AS rel
107+
MATCH (source:City {node_id: rel.Origin}), (target:City {node_id: rel.Destination})
106108
CREATE (source)-[:HAS_FLIGHT_TO]->(target)
107109
""",
108110
params={"rels": routes_df.to_dict("records")},

doc/modules/ROOT/pages/tutorials/community-detection.adoc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ connection to the database.
3434

3535
[source, python, role=no-test]
3636
----
37-
from graphdatascience import GraphDataScience
38-
import pandas as pd
3937
import os
38+
39+
import pandas as pd
40+
41+
from graphdatascience import GraphDataScience
4042
----
4143

4244
[source, python, role=no-test]
@@ -114,8 +116,8 @@ gds.run_cypher(
114116
115117
gds.run_cypher(
116118
"""
117-
UNWIND $rels AS rel
118-
MATCH (source:Subreddit {name: rel.SOURCE_SUBREDDIT}), (target:Subreddit {name: rel.TARGET_SUBREDDIT})
119+
UNWIND $rels AS rel
120+
MATCH (source:Subreddit {name: rel.SOURCE_SUBREDDIT}), (target:Subreddit {name: rel.TARGET_SUBREDDIT})
119121
CREATE (source)-[:HYPERLINKED_TO]->(target)
120122
""",
121123
params={"rels": relationship_df.to_dict("records")},
@@ -232,7 +234,7 @@ We can also check that the property was written by the below command.
232234
----
233235
gds.run_cypher(
234236
"""
235-
MATCH (n) WHERE 'louvainCommunityId' IN keys(n)
237+
MATCH (n) WHERE 'louvainCommunityId' IN keys(n)
236238
RETURN n.name, n.louvainCommunityId LIMIT 10
237239
"""
238240
)

doc/modules/ROOT/pages/tutorials/fastrp-and-knn.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ our GDS client connection to the database.
5555
[source, python, role=no-test]
5656
----
5757
import os
58+
5859
from graphdatascience import GraphDataScience
5960
6061
# Get Neo4j DB URI and credentials from environment if applicable

doc/modules/ROOT/pages/tutorials/gds-sessions-self-managed.adoc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ version `+1.12a1+` or later.
3434
[source, python, role=no-test]
3535
----
3636
from datetime import timedelta
37+
3738
%pip install "graphdatascience>=1.12a1"
3839
----
3940

@@ -50,7 +51,8 @@ is the main entry point for managing GDS Sessions.
5051
[source, python, role=no-test]
5152
----
5253
import os
53-
from graphdatascience.session import GdsSessions, AuraAPICredentials
54+
55+
from graphdatascience.session import AuraAPICredentials, GdsSessions
5456
5557
client_id = os.environ["AURA_API_CLIENT_ID"]
5658
client_secret = os.environ["AURA_API_CLIENT_SECRET"]
@@ -83,11 +85,13 @@ delete the session ourselves.
8385
[source, python, role=no-test]
8486
----
8587
import os
86-
from graphdatascience.session import DbmsConnectionInfo, AlgorithmCategory, CloudLocation
87-
from datetime import timedelta
88+
89+
from graphdatascience.session import AlgorithmCategory, CloudLocation, DbmsConnectionInfo
8890
8991
# Identify the Neo4j DBMS
90-
db_connection = DbmsConnectionInfo(uri=os.environ["NEO4J_URI"], username=os.environ["NEO4J_USER"], password=os.environ["NEO4J_PASSWORD"])
92+
db_connection = DbmsConnectionInfo(
93+
uri=os.environ["NEO4J_URI"], username=os.environ["NEO4J_USER"], password=os.environ["NEO4J_PASSWORD"]
94+
)
9195
# Specify where to create the GDS session
9296
cloud_location = CloudLocation(provider="gcp", region="europe-west1")
9397

doc/modules/ROOT/pages/tutorials/gds-sessions.adoc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ is the main entry point for managing GDS Sessions.
5050
[source, python, role=no-test]
5151
----
5252
import os
53-
from graphdatascience.session import GdsSessions, AuraAPICredentials
53+
54+
from graphdatascience.session import AuraAPICredentials, GdsSessions
5455
5556
client_id = os.environ["AURA_API_CLIENT_ID"]
5657
client_secret = os.environ["AURA_API_CLIENT_SECRET"]
@@ -84,10 +85,13 @@ delete the session ourselves.
8485
----
8586
import os
8687
from datetime import timedelta
87-
from graphdatascience.session import DbmsConnectionInfo, AlgorithmCategory
88+
89+
from graphdatascience.session import AlgorithmCategory, DbmsConnectionInfo
8890
8991
# Identify the AuraDB instance
90-
db_connection = DbmsConnectionInfo(uri=os.environ["AURA_DB_ADDRESS"], username=os.environ["AURA_DB_USER"], password=os.environ["AURA_DB_PW"])
92+
db_connection = DbmsConnectionInfo(
93+
uri=os.environ["AURA_DB_ADDRESS"], username=os.environ["AURA_DB_USER"], password=os.environ["AURA_DB_PW"]
94+
)
9195
# Create a GDS session!
9296
memory = sessions.estimate(
9397
node_count=20,

doc/modules/ROOT/pages/tutorials/heterogeneous-node-classification-with-hashgnn.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ connection to the database.
4444
----
4545
# Import our dependencies
4646
import os
47+
4748
from graphdatascience import GraphDataScience
4849
----
4950

doc/modules/ROOT/pages/tutorials/import-sample-export-gnn.adoc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,16 @@ connection to the database.
5757
[source, python, role=no-test]
5858
----
5959
import os
60-
import pandas as pd
61-
from graphdatascience import GraphDataScience
60+
import random
61+
62+
import numpy as np
6263
import torch
63-
from torch_geometric.data import Data
6464
import torch.nn.functional as F
65+
from torch_geometric.data import Data
6566
from torch_geometric.nn import GCNConv
6667
from torch_geometric.transforms import RandomNodeSplit
67-
import random
68-
import numpy as np
68+
69+
from graphdatascience import GraphDataScience
6970
----
7071

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

doc/modules/ROOT/pages/tutorials/kge-predict-transe-pyg-train.adoc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,17 @@ connection to the database.
4848

4949
[source, python, role=no-test]
5050
----
51+
import collections
5152
import os
52-
from graphdatascience import GraphDataScience
53+
54+
import pandas as pd
5355
import torch
5456
import torch.optim as optim
5557
from torch_geometric.data import Data, download_url
5658
from torch_geometric.nn import TransE
57-
import collections
5859
from tqdm import tqdm
59-
import pandas as pd
60+
61+
from graphdatascience import GraphDataScience
6062
----
6163

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

doc/modules/ROOT/pages/tutorials/load-data-via-graph-construction.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ the `+graphdatascience+` package and import the client class.
3333
[source, python, role=no-test]
3434
----
3535
import os
36+
3637
from graphdatascience import GraphDataScience
3738
----
3839

doc/modules/ROOT/pages/tutorials/ml-pipelines-node-classification.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ install the `+graphdatascience+` package and import the client class.
3737
[source, python, role=no-test]
3838
----
3939
import os
40+
4041
from graphdatascience import GraphDataScience
4142
----
4243

0 commit comments

Comments
 (0)