From 7bdd4ea2840c897548819078ee8a168b1fcf8e1c Mon Sep 17 00:00:00 2001 From: Jordan Matelsky Date: Mon, 11 Oct 2021 11:23:24 -0400 Subject: [PATCH 01/13] Delete requirements.txt --- requirements.txt | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 015a888..0000000 --- a/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -boto3 -networkx==2.4 -numpy==1.19.1 -pandas==1.1.0 -SQLAlchemy==1.3.18 \ No newline at end of file From 5d4e87440a737bb96ee1764212b43a1881532cbf Mon Sep 17 00:00:00 2001 From: Jordan Matelsky Date: Mon, 11 Oct 2021 11:28:46 -0400 Subject: [PATCH 02/13] Remove version requirements for numpy and pandas --- setup.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 197985d..7adffd6 100644 --- a/setup.py +++ b/setup.py @@ -16,11 +16,9 @@ url="https://github.com/aplbrain/grand", packages=setuptools.find_packages(), install_requires=[ - "boto3", - "networkx==2.4", - "numpy==1.19.1", - "pandas==1.1.0", - "SQLAlchemy==1.3.18", + "networkx>=2.4", + "numpy", + "pandas", ], classifiers=[ "Programming Language :: Python :: 3", From f51cdf150f7819ce03a402d3ad65f92c29c00342 Mon Sep 17 00:00:00 2001 From: Jordan Matelsky Date: Mon, 11 Oct 2021 11:35:41 -0400 Subject: [PATCH 03/13] add sql and dynamodb extra_requires --- setup.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/setup.py b/setup.py index 7adffd6..560fdbf 100644 --- a/setup.py +++ b/setup.py @@ -20,6 +20,10 @@ "numpy", "pandas", ], + extra_requires={ + "sql": ["SQLAlchemy>=1.3"], + "dynamodb": ["boto3"], + }, classifiers=[ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", From 84407b5ed89f2391873e411a2df591af3e8bdaca Mon Sep 17 00:00:00 2001 From: Jordan Matelsky Date: Mon, 11 Oct 2021 11:36:11 -0400 Subject: [PATCH 04/13] Update version marker in setup.py --- setup.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 560fdbf..4cf7659 100644 --- a/setup.py +++ b/setup.py @@ -3,11 +3,10 @@ with open("README.md", "r") as fh: long_description = fh.read() -["sqlalchemy"] setuptools.setup( name="grand-graph", - version="0.2.0", + version="0.2.1", author="Jordan Matelsky", author_email="opensource@matelsky.com", description="Graph database wrapper for non-graph datastores", From 3ca9e89b32cbdaaa4b08b66d0b5af0d499ef9ade Mon Sep 17 00:00:00 2001 From: Jordan Matelsky Date: Mon, 11 Oct 2021 11:39:03 -0400 Subject: [PATCH 05/13] Update version tag in main python code --- grand/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grand/__init__.py b/grand/__init__.py index e62be66..01a8f3e 100644 --- a/grand/__init__.py +++ b/grand/__init__.py @@ -10,7 +10,7 @@ _DEFAULT_BACKEND = NetworkXBackend -__version__ = "0.2.0" +__version__ = "0.2.1" class Graph: From 434ad9597974deb50d4c0df8e73c58b079a05a95 Mon Sep 17 00:00:00 2001 From: Jordan Matelsky Date: Mon, 11 Oct 2021 11:47:14 -0400 Subject: [PATCH 06/13] Update python-package.yml --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 661fb3f..f0edfff 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -27,7 +27,7 @@ jobs: run: | python -m pip install --upgrade pip pip install flake8 pytest - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + pip install -e . [sql] - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names From 283f91ad631e62d0733268d4283e34ec52f00951 Mon Sep 17 00:00:00 2001 From: Jordan Matelsky Date: Mon, 11 Oct 2021 11:52:21 -0400 Subject: [PATCH 07/13] Update python-package.yml --- .github/workflows/python-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index f0edfff..4c34f47 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.6, 3.7, 3.8] + python-version: [3.6, 3.7, 3.8, 3.9] steps: - uses: actions/checkout@v2 @@ -27,7 +27,7 @@ jobs: run: | python -m pip install --upgrade pip pip install flake8 pytest - pip install -e . [sql] + pip install -e ".[sql]" - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names From 5856a9b5831bfcdc2690fa4a38d4ff73ef36831d Mon Sep 17 00:00:00 2001 From: Jordan Matelsky Date: Fri, 22 Oct 2021 11:20:12 -0400 Subject: [PATCH 08/13] Make dynamo imports optional --- grand/backends/__init__.py | 6 +++++- grand/backends/test_backends.py | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/grand/backends/__init__.py b/grand/backends/__init__.py index e66c29c..e064418 100644 --- a/grand/backends/__init__.py +++ b/grand/backends/__init__.py @@ -1,5 +1,9 @@ from .backend import Backend -from .dynamodb import DynamoDBBackend + +try: + from .dynamodb import DynamoDBBackend +except ImportError: + pass from .networkx import NetworkXBackend from .sqlbackend import SQLBackend diff --git a/grand/backends/test_backends.py b/grand/backends/test_backends.py index a0e9612..f919543 100644 --- a/grand/backends/test_backends.py +++ b/grand/backends/test_backends.py @@ -3,7 +3,15 @@ import networkx as nx -from . import NetworkXBackend, SQLBackend, DynamoDBBackend +from . import NetworkXBackend, SQLBackend + +# DynamoDBBackend +try: + from .dynamodb import DynamoDBBackend + + _CAN_IMPORT_DYNAMODB = True +except ImportError: + _CAN_IMPORT_DYNAMODB = False from .. import Graph backend_test_params = [ @@ -24,8 +32,8 @@ pytest.param( DynamoDBBackend, marks=pytest.mark.skipif( - os.environ.get("TEST_DYNAMODBBACKEND") != "1", - reason="DynamoDB Backend skipped because $TEST_DYNAMODBBACKEND != 0.", + os.environ.get("TEST_DYNAMODBBACKEND") != "1" or not _CAN_IMPORT_DYNAMODB, + reason="DynamoDB Backend skipped either because boto3 wasn't installed, or $TEST_DYNAMODBBACKEND != 0.", ), ), ] @@ -93,7 +101,7 @@ def test_can_get_node(self, backend): def test_can_get_edge(self, backend): G = Graph(backend=backend()) nxG = nx.Graph() - md = {"k":"B"} + md = {"k": "B"} G.nx.add_edge("A", "B", **md) nxG.add_edge("A", "B", **md) assert G.nx.get_edge_data("A", "B") == nxG.get_edge_data("A", "B") From b5ef474fb0c653ecb775bdf8ff1c9ae0535db53a Mon Sep 17 00:00:00 2001 From: Jordan Matelsky Date: Fri, 22 Oct 2021 11:22:09 -0400 Subject: [PATCH 09/13] remove spurious boto import --- grand/backends/networkx.py | 1 - 1 file changed, 1 deletion(-) diff --git a/grand/backends/networkx.py b/grand/backends/networkx.py index 1368682..e2a9cf9 100644 --- a/grand/backends/networkx.py +++ b/grand/backends/networkx.py @@ -1,7 +1,6 @@ from typing import Hashable, Generator, Iterable import time -import boto3 import pandas as pd import networkx as nx From c00a42814690eb87072a0ae1d80a2615a6a9ac38 Mon Sep 17 00:00:00 2001 From: Jordan Matelsky Date: Fri, 22 Oct 2021 11:25:34 -0400 Subject: [PATCH 10/13] remov required sqlalchemy tests --- grand/backends/__init__.py | 11 +++++++++-- grand/backends/test_backends.py | 17 +++++++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/grand/backends/__init__.py b/grand/backends/__init__.py index e064418..25be9d8 100644 --- a/grand/backends/__init__.py +++ b/grand/backends/__init__.py @@ -5,6 +5,13 @@ except ImportError: pass from .networkx import NetworkXBackend -from .sqlbackend import SQLBackend -# from .networkit import NetworkitBackend +try: + from .sqlbackend import SQLBackend +except ImportError: + pass + +try: + from .networkit import NetworkitBackend +except ImportError: + pass diff --git a/grand/backends/test_backends.py b/grand/backends/test_backends.py index f919543..f516562 100644 --- a/grand/backends/test_backends.py +++ b/grand/backends/test_backends.py @@ -3,17 +3,25 @@ import networkx as nx -from . import NetworkXBackend, SQLBackend +from . import NetworkXBackend -# DynamoDBBackend try: from .dynamodb import DynamoDBBackend _CAN_IMPORT_DYNAMODB = True except ImportError: _CAN_IMPORT_DYNAMODB = False + +try: + from .sqlbackend import SQLBackend + + _CAN_IMPORT_SQL = True +except ImportError: + _CAN_IMPORT_SQL = False + from .. import Graph + backend_test_params = [ pytest.param( NetworkXBackend, @@ -25,8 +33,9 @@ pytest.param( SQLBackend, marks=pytest.mark.skipif( - os.environ.get("TEST_SQLBACKEND", default="1") != "1", - reason="SQL Backend skipped because $TEST_SQLBACKEND != 0.", + os.environ.get("TEST_SQLBACKEND", default="1") != "1" + or not _CAN_IMPORT_SQL, + reason="SQL Backend skipped because $TEST_SQLBACKEND != 0 or sqlalchemy is not installed.", ), ), pytest.param( From e8a999339964b0ddaf0e9de08912611a3da2cd4b Mon Sep 17 00:00:00 2001 From: Jordan Matelsky Date: Fri, 22 Oct 2021 11:28:00 -0400 Subject: [PATCH 11/13] fix test params imports --- grand/backends/test_backends.py | 36 ++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/grand/backends/test_backends.py b/grand/backends/test_backends.py index f516562..0e49494 100644 --- a/grand/backends/test_backends.py +++ b/grand/backends/test_backends.py @@ -30,22 +30,30 @@ reason="NetworkX Backend skipped because $TEST_NETWORKXBACKEND != 0.", ), ), - pytest.param( - SQLBackend, - marks=pytest.mark.skipif( - os.environ.get("TEST_SQLBACKEND", default="1") != "1" - or not _CAN_IMPORT_SQL, - reason="SQL Backend skipped because $TEST_SQLBACKEND != 0 or sqlalchemy is not installed.", +] + +if _CAN_IMPORT_DYNAMODB: + backend_test_params.append( + pytest.param( + DynamoDBBackend, + marks=pytest.mark.skipif( + os.environ.get("TEST_DYNAMODB", default="1") != "1", + reason="DynamoDB Backend skipped because $TEST_DYNAMODB != 0 or boto3 is not installed", + ), ), - ), - pytest.param( - DynamoDBBackend, - marks=pytest.mark.skipif( - os.environ.get("TEST_DYNAMODBBACKEND") != "1" or not _CAN_IMPORT_DYNAMODB, - reason="DynamoDB Backend skipped either because boto3 wasn't installed, or $TEST_DYNAMODBBACKEND != 0.", + ) + +if _CAN_IMPORT_SQL: + backend_test_params.append( + pytest.param( + SQLBackend, + marks=pytest.mark.skipif( + os.environ.get("TEST_SQLBACKEND", default="1") != "1" + or not _CAN_IMPORT_SQL, + reason="SQL Backend skipped because $TEST_SQLBACKEND != 0 or sqlalchemy is not installed.", + ), ), - ), -] + ) if os.environ.get("TEST_NETWORKITBACKEND") == "1": from .networkit import NetworkitBackend From defeb155b12275f406975c28d5304690bbd5591e Mon Sep 17 00:00:00 2001 From: Jordan Matelsky Date: Fri, 22 Oct 2021 11:30:05 -0400 Subject: [PATCH 12/13] remove hard-coded sql backend --- grand/backends/test_backends.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grand/backends/test_backends.py b/grand/backends/test_backends.py index 0e49494..f1217d7 100644 --- a/grand/backends/test_backends.py +++ b/grand/backends/test_backends.py @@ -155,7 +155,7 @@ def test_undirected_adj(self, backend): assert G.nx._adj == nxG._adj def test_directed_adj(self, backend): - G = Graph(backend=SQLBackend(directed=True)) + G = Graph(backend=backend(directed=True)) nxG = nx.DiGraph() assert G.nx._adj == nxG._adj G.nx.add_edge("A", "B") From 4a2e39d7d759bc85f9ccdf9179a0829eecbd5e44 Mon Sep 17 00:00:00 2001 From: Jordan Matelsky Date: Fri, 22 Oct 2021 11:35:51 -0400 Subject: [PATCH 13/13] Update changelog for split dependencies --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 983402c..7ee010a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,11 +2,13 @@ ## **0.3.0** -> This version adds support for Gremlin-compatible graph databases, such as AWS Neptune, TinkerPop, Janus, etc, through the `GremlinBackend`. +> This version adds support for Gremlin-compatible graph databases, such as AWS Neptune, TinkerPop, Janus, etc, through the `GremlinBackend`, and loosens the requirements for the base installation of `grand-graph`. You can now install `grand-graph[sql]` or `grand-graph[dynamodb]` to get additional functionality (with additional dependencies). - Improvements - Backends - Add `GremlinBackend` to the list of supported backends +- Housekeeping + - Removes sqlalchemy and boto3 from the list of requirements for the base install. You can now install these with `pip3 install grand-graph[sql]` or `[dyanmodb]`. ## **0.2.0**