Skip to content

Commit

Permalink
Merge branch 'main' into mirror-crud-to-nxcg
Browse files Browse the repository at this point in the history
  • Loading branch information
aMahanna authored Jan 14, 2025
2 parents 423a7b2 + 48b4bfe commit 37ac07d
Show file tree
Hide file tree
Showing 20 changed files with 396 additions and 166 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ workflows:
- test:
matrix:
parameters:
python_version: ["3.10", "3.11", "3.12.2"]
python_version: ["3.10", "3.11", "3.12"]
- test-gpu:
requires:
- lint
Expand Down
89 changes: 89 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,92 @@
1.3.0 (2025-01-10)
------------------

New
~~~
- Fully support parameterized `db` object (#70) [Anthony Mahanna]
* new: fully support parameterized `db` object
* fix: `hosts`
* fix: docstring
* new: support `use_gpu` algorithm parameter
* new: `test_multiple_graph_sessions`
Fix
~~~
- Readme img. [Anthony Mahanna]

Other
~~~~~
- Bump: version. [Anthony Mahanna]
- Rm: scarf. [Anthony Mahanna]
- Cleanup: `overwrite_graph` and `chat` (#69) [Anthony Mahanna]
* cleanup: `overwrite_graph`
* fix: typo
* fix: `chat`
* temp: disable `chat`
- Temp: lock adb. [Anthony Mahanna]
need to investigate issues with 3.12.3
- Update README.md. [Anthony Mahanna]
- Update README.md. [Anthony Mahanna]
- !gitchangelog (#67) [aMahanna, github-actions[bot]]
1.2.0 (2024-10-21)
------------------
New
~~~
- Use `_graphs` instead of `nxadb_graphs` (#66) [Anthony Mahanna]
* new: use `_graphs` instead of `nxadb_graphs`
* fix: lint
* fix: typo
* cleanup
* cleanup: use `GRAPH_FIELD`
* fix: env var
* fix: lint
* bump version
Other
~~~~~
- Bump: networkx dep (#64) [Anthony Mahanna]

* bump: networkx dep

* fix: `mypy`

* new: `_should_backend_run`

overriding https://github.com/networkx/networkx/blob/networkx-3.4.1/networkx/utils/backends.py#L1514-L1535 to support backwards compatibility

* Update VERSION

* fix: use `from_networkx` if graph does not exist in db

* remove demo.py

* new: `_should_backend_run`, `_can_backend_run`

* fix: lint
- !gitchangelog (#62) [aMahanna, github-actions[bot]]


1.1.0 (2024-10-08)
------------------

Expand Down
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<img src="https://rapids.ai/images/RAPIDS-logo.png" alt="RAPIDS" height="60">
</a>
<a href="https://www.nvidia.com/en-us/startups/">
<img src="https://www.serversimply.com/media/20181218-Nvidia-Inception.png" alt="NVIDIA" height="60">
<img src="https://www.nvidia.com/content/dam/en-zz/Solutions/about-nvidia/logo-and-brand/02-nvidia-logo-color-grn-500x200-4c25-p@2x.png" alt="NVIDIA" height="60">
</a>

<br>
Expand Down Expand Up @@ -44,7 +44,7 @@ This is a [backend to NetworkX](https://networkx.org/documentation/stable/refere

Benefits of having ArangoDB as a backend to NetworkX include:
1. No need to re-create the graph every time you start a new session.
2. Access to GPU-accelerated graph analytics ([nx-cugraph](https://docs.rapids.ai/api/cugraph/nightly/nx_cugraph/nx_cugraph/)).
2. Access to GPU-accelerated graph analytics ([nx-cugraph](https://rapids.ai/nx-cugraph/)).
3. Access to a database query language ([Arango Query Language](https://arangodb.com/sql-aql-comparison/)).
4. Access to a visual interface for graph exploration ([ArangoDB Web UI](https://docs.arangodb.com/stable/components/web-interface/graphs/)).
5. Access to cross-collaboration on the same graph ([ArangoDB Cloud](https://docs.arangodb.com/stable/get-started/set-up-a-cloud-instance/)).
Expand Down Expand Up @@ -153,7 +153,7 @@ os.environ["DATABASE_NAME"] = credentials["dbName"]

## How does algorithm dispatching work?

`nx-arangodb` will automatically dispatch algorithm calls to either CPU or GPU based on if `nx-cugraph` is installed. We rely on a rust-based library called [phenolrs](https://github.com/arangoml/phenolrs) to retrieve ArangoDB Graphs as fast as possible.
`nx-arangodb` will automatically dispatch algorithm calls to either CPU or GPU based on if [nx-cugraph](https://rapids.ai/nx-cugraph/) is installed. We rely on a rust-based library called [phenolrs](https://github.com/arangoml/phenolrs) to retrieve ArangoDB Graphs as fast as possible.

You can also force-run algorithms on CPU even if `nx-cugraph` is installed:

Expand All @@ -166,13 +166,16 @@ import nx_arangodb as nxadb

G = nxadb.Graph(name="MyGraph")

# Option 1: Use Global Config
nx.config.backends.arangodb.use_gpu = False

nx.pagerank(G)
nx.betweenness_centrality(G)
# ...

nx.config.backends.arangodb.use_gpu = True

# Option 2: Use Local Config
nx.pagerank(G, use_gpu=False)
nx.betweenness_centrality(G, use_gpu=False)
```

<p align="center">
Expand Down
2 changes: 1 addition & 1 deletion _nx_arangodb/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.0
1.3.0
10 changes: 1 addition & 9 deletions _nx_arangodb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,7 @@ def get_info():
for key in info_keys:
del d[key]

d["default_config"] = {
"host": None,
"username": None,
"password": None,
"db_name": None,
"read_parallelism": None,
"read_batch_size": None,
"use_gpu": True,
}
d["default_config"] = {"use_gpu": True}

return d

Expand Down
7 changes: 5 additions & 2 deletions doc/algorithms/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,17 @@ You can also force-run algorithms on CPU even if ``nx-cugraph`` is installed:
G = nxadb.Graph(name="MyGraph")
# Option 1: Use Global Config
nx.config.backends.arangodb.use_gpu = False
nx.pagerank(G)
nx.betweenness_centrality(G)
# ...
nx.config.backends.arangodb.use_gpu = True
# Option 2: Use Local Config
nx.pagerank(G, use_gpu=False)
nx.betweenness_centrality(G, use_gpu=False)
.. image:: ../_static/dispatch.png
:align: center
Expand Down
6 changes: 1 addition & 5 deletions doc/nx_arangodb.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,7 @@
"outputs": [],
"source": [
"# 5. Run an algorithm (CPU)\n",
"nx.config.backends.arangodb.use_gpu = False # Optional\n",
"\n",
"res = nx.pagerank(G)"
"res = nx.pagerank(G, use_gpu=False)"
]
},
{
Expand Down Expand Up @@ -357,8 +355,6 @@
"source": [
"# 4. Run an algorithm (GPU)\n",
"# See *Package Installation* to install nx-cugraph ^\n",
"nx.config.backends.arangodb.use_gpu = True\n",
"\n",
"res = nx.pagerank(G)"
]
},
Expand Down
16 changes: 16 additions & 0 deletions nx_arangodb/classes/dict/adj.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ def adjlist_outer_dict_factory(
db: StandardDatabase,
graph: Graph,
default_node_type: str,
read_parallelism: int,
read_batch_size: int,
edge_type_key: str,
edge_type_func: Callable[[str, str], str],
graph_type: str,
Expand All @@ -115,6 +117,8 @@ def adjlist_outer_dict_factory(
db,
graph,
default_node_type,
read_parallelism,
read_batch_size,
edge_type_key,
edge_type_func,
graph_type,
Expand Down Expand Up @@ -1454,6 +1458,12 @@ class AdjListOuterDict(UserDict[str, AdjListInnerDict]):
symmetrize_edges_if_directed : bool
Whether to add the reverse edge if the graph is directed.
read_parallelism : int
The number of parallel threads to use for reading data in _fetch_all.
read_batch_size : int
The number of documents to read in each batch in _fetch_all.
Example
-------
>>> g = nxadb.Graph(name="MyGraph")
Expand All @@ -1467,6 +1477,8 @@ def __init__(
db: StandardDatabase,
graph: Graph,
default_node_type: str,
read_parallelism: int,
read_batch_size: int,
edge_type_key: str,
edge_type_func: Callable[[str, str], str],
graph_type: str,
Expand All @@ -1489,6 +1501,8 @@ def __init__(
self.edge_type_key = edge_type_key
self.edge_type_func = edge_type_func
self.default_node_type = default_node_type
self.read_parallelism = read_parallelism
self.read_batch_size = read_batch_size
self.adjlist_inner_dict_factory = adjlist_inner_dict_factory(
db,
graph,
Expand Down Expand Up @@ -1853,6 +1867,8 @@ def _fetch_all(self) -> None:
is_directed=True,
is_multigraph=self.is_multigraph,
symmetrize_edges_if_directed=self.symmetrize_edges_if_directed,
read_parallelism=self.read_parallelism,
read_batch_size=self.read_batch_size,
)

# Even if the Graph is undirected,
Expand Down
Loading

0 comments on commit 37ac07d

Please sign in to comment.