Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e06f2d0

Browse files
AvitalFineRedisswilly22
andauthored
API documentation
Co-authored-by: Roi Lipman <swilly22@users.noreply.github.com>
1 parent 92eba8d commit e06f2d0

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=None, host='localhost', port=6379, password=None):
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
if redis_con is not None:
@@ -63,6 +67,12 @@ def _refresh_attributes(self):
6367
self._properties[i] = p[0]
6468

6569
def get_label(self, idx):
70+
"""
71+
Returns a label by it's index
72+
73+
Args:
74+
idx: The index of the label
75+
"""
6676
try:
6777
label = self._labels[idx]
6878
except IndexError:
@@ -72,6 +82,12 @@ def get_label(self, idx):
7282
return label
7383

7484
def get_relation(self, idx):
85+
"""
86+
Returns a relationship type by it's index
87+
88+
Args:
89+
idx: The index of the relation
90+
"""
7591
try:
7692
relationshipType = self._relationshipTypes[idx]
7793
except IndexError:
@@ -81,6 +97,12 @@ def get_relation(self, idx):
8197
return relationshipType
8298

8399
def get_property(self, idx):
100+
"""
101+
Returns a property by it's index
102+
103+
Args:
104+
idx: The index of the property
105+
"""
84106
try:
85107
propertie = self._properties[idx]
86108
except IndexError:
@@ -134,7 +156,7 @@ def flush(self):
134156
self.nodes = {}
135157
self.edges = []
136158

137-
def build_params_header(self, params):
159+
def _build_params_header(self, params):
138160
if not isinstance(params, dict):
139161
raise TypeError("'params' must be a dict")
140162
# Header starts with "CYPHER"
@@ -152,14 +174,20 @@ def build_params_header(self, params):
152174
def query(self, q, params=None, timeout=None, read_only=False):
153175
"""
154176
Executes a query against the graph.
177+
178+
Args:
179+
q: the query
180+
params: query parameters
181+
timeout: maximum runtime for read queries in milliseconds
182+
read_only: executes a readonly query if set to True
155183
"""
156184

157185
# maintain original 'q'
158186
query = q
159187

160188
# handle query parameters
161189
if params is not None:
162-
query = self.build_params_header(params) + query
190+
query = self._build_params_header(params) + query
163191

164192
# construct query command
165193
# ask for compact result-set format
@@ -200,9 +228,13 @@ def execution_plan(self, query, params=None):
200228
"""
201229
Get the execution plan for given query,
202230
GRAPH.EXPLAIN returns an array of operations.
231+
232+
Args:
233+
query: the query that will be executed
234+
params: query parameters
203235
"""
204236
if params is not None:
205-
query = self.build_params_header(params) + query
237+
query = self._build_params_header(params) + query
206238

207239
plan = self.redis_con.execute_command("GRAPH.EXPLAIN", self.name, query, query)
208240
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)

AltStyle によって変換されたページ (->オリジナル) /