From 3169aa4645a8ee2fc5f72f00151eff3b5a83e772 Mon Sep 17 00:00:00 2001 From: Anthony Mahanna <43019056+aMahanna@users.noreply.github.com> Date: Wed, 29 Jun 2022 10:43:10 -0400 Subject: [PATCH] new: 4.1.0 release prep (#84) * #83: initial commit * Update README.md * fix: flake8 * bump: python-arango version * update notebook version --- README.md | 26 +++++++++--------------- adbnx_adapter/adapter.py | 13 +++++++----- examples/ArangoDB_NetworkX_Adapter.ipynb | 18 +++++++++------- setup.py | 2 +- 4 files changed, 30 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index afdcae73..e0d00e05 100644 --- a/README.md +++ b/README.md @@ -45,33 +45,27 @@ pip install git+https://github.com/arangoml/networkx-adapter.git Also available as an ArangoDB Lunch & Learn session: [Graph & Beyond Course #2.9](https://www.arangodb.com/resources/lunch-sessions/graph-beyond-lunch-break-2-9-introducing-the-arangodb-networkx-adapter/) ```py -# Import the ArangoDB-NetworkX Adapter -from adbnx_adapter import ADBNX_Adapter - -# Import the Python-Arango driver -from arango import ArangoClient +from arango import ArangoClient # Python-Arango driver +from networkx import grid_2d_graph # Sample graph from NetworkX -# Import a sample graph from NetworkX -from networkx import grid_2d_graph +from adbnx_adapter import ADBNX_Adapter -# Instantiate driver client based on user preference -# Let's assume that the ArangoDB "fraud detection" dataset is imported to this endpoint for example purposes +# Let's assume that the ArangoDB "fraud detection" dataset is imported to this endpoint db = ArangoClient(hosts="http://localhost:8529").db("_system", username="root", password="") -# Instantiate your ADBNX Adapter with driver client adbnx_adapter = ADBNX_Adapter(db) -# Convert ArangoDB to NetworkX via Graph Name +# Use Case 1.1: ArangoDB to NetworkX via Graph name nx_fraud_graph = adbnx_adapter.arangodb_graph_to_networkx("fraud-detection") -# Convert ArangoDB to NetworkX via Collection Names +# Use Case 1.2: ArangoDB to NetworkX via Collection names nx_fraud_graph_2 = adbnx_adapter.arangodb_collections_to_networkx( "fraud-detection", - {"account", "bank", "branch", "Class", "customer"}, # Specify vertex collections - {"accountHolder", "Relationship", "transaction"} # Specify edge collections + {"account", "bank", "branch", "Class", "customer"}, # Vertex collections + {"accountHolder", "Relationship", "transaction"} # Edge collections ) -# Convert ArangoDB to NetworkX via a Metagraph +# Use Case 1.3: ArangoDB to NetworkX via Metagraph metagraph = { "vertexCollections": { "account": {"Balance", "account_type", "customer_id", "rank"}, @@ -84,7 +78,7 @@ metagraph = { } nx_fraud_graph_3 = adbnx_adapter.arangodb_to_networkx("fraud-detection", metagraph) -# Convert NetworkX to ArangoDB +# Use Case 2: NetworkX to ArangoDB nx_grid_graph = grid_2d_graph(5, 5) adb_grid_edge_definitions = [ { diff --git a/adbnx_adapter/adapter.py b/adbnx_adapter/adapter.py index cf789e85..921db38b 100644 --- a/adbnx_adapter/adapter.py +++ b/adbnx_adapter/adapter.py @@ -83,7 +83,8 @@ def arangodb_to_networkx( attributes are included. :type is_keep: bool :param query_options: Keyword arguments to specify AQL query options when - fetching documents from the ArangoDB instance. + fetching documents from the ArangoDB instance. Full parameter list: + https://docs.python-arango.com/en/main/specs.html#arango.aql.AQL.execute :type query_options: Any :return: A Multi-Directed NetworkX Graph. :rtype: networkx.classes.multidigraph.MultiDiGraph @@ -159,7 +160,8 @@ def arangodb_collections_to_networkx( :param e_cols: A set of edge collections to import to NetworkX. :type e_cols: Set[str] :param query_options: Keyword arguments to specify AQL query options when - fetching documents from the ArangoDB instance. + fetching documents from the ArangoDB instance. Full parameter list: + https://docs.python-arango.com/en/main/specs.html#arango.aql.AQL.execute :type query_options: Any :return: A Multi-Directed NetworkX Graph. :rtype: networkx.classes.multidigraph.MultiDiGraph @@ -181,7 +183,8 @@ def arangodb_graph_to_networkx( :param name: The ArangoDB graph name. :type name: str :param query_options: Keyword arguments to specify AQL query options when - fetching documents from the ArangoDB instance. + fetching documents from the ArangoDB instance. Full parameter list: + https://docs.python-arango.com/en/main/specs.html#arango.aql.AQL.execute :type query_options: Any :return: A Multi-Directed NetworkX Graph. :rtype: networkx.classes.multidigraph.MultiDiGraph @@ -230,8 +233,8 @@ def networkx_to_arangodb( Does not drop associated collections. :type overwrite_graph: bool :param import_options: Keyword arguments to specify additional - parameters for ArangoDB document insertion. See - arango.collection.Collection.import_bulk for all options. + parameters for ArangoDB document insertion. Full parameter list: + https://docs.python-arango.com/en/main/specs.html#arango.collection.Collection.import_bulk :type import_options: Any :return: The ArangoDB Graph API wrapper. :rtype: arango.graph.Graph diff --git a/examples/ArangoDB_NetworkX_Adapter.ipynb b/examples/ArangoDB_NetworkX_Adapter.ipynb index 897561e3..57666b2f 100644 --- a/examples/ArangoDB_NetworkX_Adapter.ipynb +++ b/examples/ArangoDB_NetworkX_Adapter.ipynb @@ -15,7 +15,7 @@ "id": "U1d45V4OeG89" }, "source": [ - "\"Open" + "\"Open" ] }, { @@ -34,7 +34,7 @@ "id": "bpvZS-1aeG89" }, "source": [ - "Version: 4.0.0\n", + "Version: 4.1.0\n", "\n", "Objective: Export Graphs from [ArangoDB](https://www.arangodb.com/), a multi-model Graph Database, to [NetworkX](https://networkx.github.io/), the swiss army knife for graph analysis in python, and vice-versa." ] @@ -57,8 +57,8 @@ "outputs": [], "source": [ "%%capture\n", - "!git clone -b 4.0.0 --single-branch https://github.com/arangoml/networkx-adapter.git\n", - "!pip install adbnx-adapter==4.0.0\n", + "!git clone -b 4.1.0 --single-branch https://github.com/arangoml/networkx-adapter.git\n", + "!pip install adbnx-adapter==4.1.0\n", "!pip install adb-cloud-connector\n", "\n", "# For drawing purposes\n", @@ -478,7 +478,7 @@ "\n", "# You can also provide valid Python-Arango AQL query options to the command above, like such:\n", "# nx_g = adbnx_adapter.arangodb_graph_to_networkx(graph_name, ttl=1000, stream=True)\n", - "# See more here: https://docs.python-arango.com/en/main/specs.html#arango.aql.AQL.execute\n", + "# See the full parameter list at https://docs.python-arango.com/en/main/specs.html#arango.aql.AQL.execute\n", "\n", "# Show graph data\n", "print('\\n--------------------')\n", @@ -537,7 +537,7 @@ "\n", "# You can also provide valid Python-Arango AQL query options to the command above, like such:\n", "# nx_g = adbnx_adapter.arangodb_collections_to_networkx(\"fraud-detection\", vertex_collections, edge_collections, ttl=1000, stream=True)\n", - "# See more here: https://docs.python-arango.com/en/main/specs.html#arango.aql.AQL.execute\n", + "# See the full parameter list at https://docs.python-arango.com/en/main/specs.html#arango.aql.AQL.execute\n", "\n", "# Show graph data\n", "print('\\n--------------------')\n", @@ -608,7 +608,7 @@ "\n", "# You can also provide valid Python-Arango AQL query options to the command above, like such:\n", "# nx_g = adbnx_adapter.arangodb_to_networkx('fraud-detection', fraud_detection_metagraph, ttl=1000, stream=True)\n", - "# See more here: https://docs.python-arango.com/en/main/specs.html#arango.aql.AQL.execute\n", + "# See the full parameter list at https://docs.python-arango.com/en/main/specs.html#arango.aql.AQL.execute\n", "\n", "# Show graph data\n", "print('\\n--------------------')\n", @@ -785,6 +785,10 @@ "# Create the ArangoDB graph\n", "grid_adb_g = adbnx_adapter.networkx_to_arangodb(name, grid_nx_g, edge_definitions)\n", "\n", + "# You can also provide valid Python-Arango Import Bulk options to the command above, like such:\n", + "# grid_adb_g = adbnx_adapter.networkx_to_arangodb(name, grid_nx_g, edge_definitions, batch_size=5, on_duplicate=\"replace\")\n", + "# See the full parameter list at https://docs.python-arango.com/en/main/specs.html#arango.collection.Collection.import_bulk\n", + "\n", "print('\\n--------------------')\n", "print(\"URL: \" + con[\"url\"])\n", "print(\"Username: \" + con[\"username\"])\n", diff --git a/setup.py b/setup.py index 126a0ddb..9852f67e 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ license="Apache Software License", install_requires=[ "requests>=2.27.1", - "python-arango>=7.4.0", + "python-arango>=7.4.1", "networkx>=2.5.1", "setuptools>=45", ],