Skip to content

Commit 8708dd0

Browse files
hkernbachaMahanna
andauthored
async by default + data transfer cfg (#21)
* async by default, cfg for batch size and parallelism level as parameter during graph init * lint * some param restructure - python convenient style now --------- Co-authored-by: Anthony Mahanna <[email protected]>
1 parent 27c7b2e commit 8708dd0

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

_nx_arangodb/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ def get_info():
7979
"username": None,
8080
"password": None,
8181
"db_name": None,
82-
"load_parallelism": None,
83-
"load_batch_size": None,
82+
"read_parallelism": None,
83+
"read_batch_size": None,
8484
}
8585

8686
return d

nx_arangodb/classes/function.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ def get_arangodb_graph(
8686
config = nx.config.backends.arangodb
8787

8888
kwargs = {}
89-
if parallelism := config.get("load_parallelism"):
89+
if parallelism := config.get("read_parallelism"):
9090
kwargs["parallelism"] = parallelism
91-
if batch_size := config.get("load_batch_size"):
91+
if batch_size := config.get("read_batch_size"):
9292
kwargs["batch_size"] = batch_size
9393

9494
assert config.db_name

nx_arangodb/classes/graph.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ def __init__(
4343
default_node_type: str | None = None,
4444
edge_type_func: Callable[[str, str], str] | None = None,
4545
db: StandardDatabase | None = None,
46+
read_parallelism: int = 10,
47+
read_batch_size: int = 100000,
48+
write_batch_size: int = 50000,
4649
*args: Any,
4750
**kwargs: Any,
4851
):
@@ -54,8 +57,10 @@ def __init__(
5457
if self._db is not None:
5558
self._set_graph_name(graph_name)
5659

57-
self.graph_loader_parallelism = 10
58-
self.graph_loader_batch_size = 100000
60+
# We need to store the data transfer properties as some functions will need them
61+
self.read_parallelism = read_parallelism
62+
self.read_batch_size = read_batch_size
63+
self.write_batch_size = write_batch_size
5964

6065
# NOTE: Need to revisit these...
6166
# self.maintain_node_dict_cache = False
@@ -109,6 +114,8 @@ def __init__(
109114
self._graph_name,
110115
incoming_graph_data,
111116
edge_definitions=edge_definitions,
117+
batch_size=self.write_batch_size,
118+
use_async=True,
112119
)
113120

114121
# No longer need this (we've already populated the graph)
@@ -140,8 +147,8 @@ def _set_arangodb_backend_config(self) -> None:
140147
config.username = self._username
141148
config.password = self._password
142149
config.db_name = self._db_name
143-
config.load_parallelism = self.graph_loader_parallelism
144-
config.load_batch_size = self.graph_loader_batch_size
150+
config.read_parallelism = self.read_parallelism
151+
config.read_batch_size = self.read_batch_size
145152

146153
def _set_factory_methods(self) -> None:
147154
"""Set the factory methods for the graph, _node, and _adj dictionaries.

0 commit comments

Comments
 (0)