Skip to content

Commit 9443ce6

Browse files
test
1 parent 63d3fe3 commit 9443ce6

File tree

3 files changed

+37
-5
lines changed

3 files changed

+37
-5
lines changed

redisgraph/edge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def __init__(self, src_node, relation, dest_node, edge_id=None,
1212
"""
1313
Create a new edge.
1414
"""
15-
if (src_node is None or dest_node is None):
15+
if src_node is None or dest_node is None:
1616
# NOTE(bors-42): It makes sense to change AssertionError to
1717
# ValueError here
1818
raise AssertionError("Both src_node & dest_node must be provided")

redisgraph/graph.py

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ class Graph:
1313
def __init__(self, name, redis_con):
1414
"""
1515
Create a new graph.
16+
17+
Args:
18+
name: string that represents the name of the graph
19+
redis_con: connection to Redis
1620
"""
1721
self.name = name # Graph key
1822
self.redis_con = redis_con
@@ -59,6 +63,12 @@ def _refresh_attributes(self):
5963
self._properties[i] = p[0]
6064

6165
def get_label(self, idx):
66+
"""
67+
Returns a label by it's index
68+
69+
Args:
70+
idx: The index of the label
71+
"""
6272
try:
6373
label = self._labels[idx]
6474
except IndexError:
@@ -68,6 +78,12 @@ def get_label(self, idx):
6878
return label
6979

7080
def get_relation(self, idx):
81+
"""
82+
Returns a relationship type by it's index
83+
84+
Args:
85+
idx: The index of the relation
86+
"""
7187
try:
7288
relationshipType = self._relationshipTypes[idx]
7389
except IndexError:
@@ -77,6 +93,12 @@ def get_relation(self, idx):
7793
return relationshipType
7894

7995
def get_property(self, idx):
96+
"""
97+
Returns a property by it's index
98+
99+
Args:
100+
idx: The index of the property
101+
"""
80102
try:
81103
propertie = self._properties[idx]
82104
except IndexError:
@@ -130,7 +152,7 @@ def flush(self):
130152
self.nodes = {}
131153
self.edges = []
132154

133-
def build_params_header(self, params):
155+
def _build_params_header(self, params):
134156
if not isinstance(params, dict):
135157
raise TypeError("'params' must be a dict")
136158
# Header starts with "CYPHER"
@@ -148,14 +170,20 @@ def build_params_header(self, params):
148170
def query(self, q, params=None, timeout=None, read_only=False):
149171
"""
150172
Executes a query against the graph.
173+
174+
Args:
175+
q: the query
176+
params: query parameters
177+
timeout: maximum runtime for read queries in milliseconds
178+
read_only: executes a readonly query if set to True
151179
"""
152180

153181
# maintain original 'q'
154182
query = q
155183

156184
# handle query parameters
157185
if params is not None:
158-
query = self.build_params_header(params) + query
186+
query = self._build_params_header(params) + query
159187

160188
# construct query command
161189
# ask for compact result-set format
@@ -196,9 +224,13 @@ def execution_plan(self, query, params=None):
196224
"""
197225
Get the execution plan for given query,
198226
GRAPH.EXPLAIN returns an array of operations.
227+
228+
Args:
229+
query: the query that will be executed
230+
params: query parameters
199231
"""
200232
if params is not None:
201-
query = self.build_params_header(params) + query
233+
query = self._build_params_header(params) + query
202234

203235
plan = self.redis_con.execute_command("GRAPH.EXPLAIN", self.name, query, query)
204236
return self._execution_plan_to_string(plan)

redisgraph/node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
class Node:
55
"""
6-
A node within the garph.
6+
A node within the graph.
77
"""
88
def __init__(self, node_id=None, alias=None, label=None, properties=None):
99
"""

0 commit comments

Comments
 (0)