From e8ad4f92c07f3a6c002433484b50a2527bc1ca1d Mon Sep 17 00:00:00 2001 From: Anthony Mahanna Date: Mon, 13 Nov 2023 16:16:01 -0500 Subject: [PATCH 1/7] initial commit --- pyproject.toml | 85 +++++++++++++++++++++++++++++++++++++++++++++----- setup.cfg | 12 ------- setup.py | 52 +----------------------------- 3 files changed, 79 insertions(+), 70 deletions(-) delete mode 100644 setup.cfg diff --git a/pyproject.toml b/pyproject.toml index 9b1fc18..df12205 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,17 +1,88 @@ [build-system] -requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2", "wheel"] +requires = ["setuptools>=45", "wheel", "setuptools_scm"] build-backend = "setuptools.build_meta" -[tool.coverage.run] -omit = [ - "adbdgl_adapter/version.py", - "setup.py", +[tool.setuptools_scm] +normalize = true + +[project] +name = "adbdgl_adapter" +description = "Convert ArangoDB graphs to DGL & vice-versa." +keywords=["arangodb", "dgl", "deep graph library", "adapter"] +readme = "README.md" +dynamic = ["version"] +license = {file = "LICENSE"} +requires-python = ">=3.8" + +authors = [{name = "Anthony Mahanna", email = "anthony.mahanna@arangodb.com"}] + +classifiers = [ + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Utilities", + "Typing :: Typed", +] + +dependencies = [ + "requests>=2.27.1", + "rich>=12.5.1", + "pandas>=1.3.5", + "dgl~=1.0", + "torch>=1.12.0", + "python-arango~=7.6", + "setuptools>=45", +] + +[project.optional-dependencies] +dev = [ + "black==23.3.0", + "flake8==6.0.0", + "isort==5.12.0", + "mypy==1.4.1", + "pytest>=6.0.0", + "pytest-cov>=2.0.0", + "coveralls>=3.3.1", + "types-setuptools", + "types-requests", ] +[project.urls] +"Homepage" = "https://github.com/arangoml/pyg-adapter" + +[tool.setuptools] +packages = ["adbpyg_adapter"] + [tool.pytest.ini_options] addopts = "-s -vv" minversion = "6.0" testpaths = ["tests"] -[tool.setuptools_scm] -write_to = "adbdgl_adapter/version.py" +[tool.coverage.report] +omit = ["*tests*"] + +[tool.coverage.run] +omit = ["*tests*"] + +[tool.isort] +profile = "black" + +[tool.flake8] +max-line-length = 88 +extend-ignore = ["E203", "W503", "E251"] +exclude = [".git", ".idea", ".*_cache", "dist", "venv"] + +[tool.mypy] +strict = true +ignore_missing_imports = true +implicit_reexport = true +scripts_are_modules = true +follow_imports = "skip" +disallow_subclassing_any = false +disallow_untyped_decorators = false \ No newline at end of file diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index a91261b..0000000 --- a/setup.cfg +++ /dev/null @@ -1,12 +0,0 @@ -[isort] -profile = black - -[flake8] -max-line-length = 88 -extend-ignore = E203, E741, W503, E731 -exclude =.git .idea .*_cache dist venv - -[mypy] -strict = True -ignore_missing_imports = True -implicit_reexport = True diff --git a/setup.py b/setup.py index 0b56dea..6068493 100644 --- a/setup.py +++ b/setup.py @@ -1,53 +1,3 @@ from setuptools import setup -with open("./README.md") as fp: - long_description = fp.read() - -setup( - name="adbdgl_adapter", - author="Anthony Mahanna", - author_email="anthony.mahanna@arangodb.com", - description="Convert ArangoDB graphs to DGL & vice-versa.", - long_description=long_description, - long_description_content_type="text/markdown", - url="https://github.com/arangoml/dgl-adapter", - keywords=["arangodb", "dgl", "deep graph library", "adapter"], - packages=["adbdgl_adapter"], - include_package_data=True, - python_requires=">=3.8", - license="Apache Software License", - install_requires=[ - "requests>=2.27.1", - "rich>=12.5.1", - "pandas>=1.3.5", - "dgl~=1.0", - "torch>=1.12.0", - "python-arango~=7.6", - "setuptools>=45", - ], - extras_require={ - "dev": [ - "black==23.3.0", - "flake8==6.0.0", - "isort==5.12.0", - "mypy==1.4.1", - "pytest>=6.0.0", - "pytest-cov>=2.0.0", - "coveralls>=3.3.1", - "types-setuptools", - "types-requests", - ], - }, - classifiers=[ - "Intended Audience :: Developers", - "License :: OSI Approved :: Apache Software License", - "Operating System :: OS Independent", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Topic :: Utilities", - "Typing :: Typed", - ], -) +setup() From 1f1a1a4beed04762e986a353e0b2ad7b667e4855 Mon Sep 17 00:00:00 2001 From: Anthony Mahanna Date: Mon, 13 Nov 2023 16:16:10 -0500 Subject: [PATCH 2/7] add 3.12 to build workflow --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bc3f9ff..2b5a0c5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python: ["3.8", "3.9", "3.10", "3.11"] + python: ["3.8", "3.9", "3.10", "3.11", "3.12"] name: Python ${{ matrix.python }} steps: - uses: actions/checkout@v4 From b230fe5a2a18ee49e3c1a8101e00faba13b11190 Mon Sep 17 00:00:00 2001 From: Anthony Mahanna Date: Mon, 13 Nov 2023 16:19:08 -0500 Subject: [PATCH 3/7] fix typos --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index df12205..345eee3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,10 +54,10 @@ dev = [ ] [project.urls] -"Homepage" = "https://github.com/arangoml/pyg-adapter" +"Homepage" = "https://github.com/arangoml/dgl-adapter" [tool.setuptools] -packages = ["adbpyg_adapter"] +packages = ["adbdgl_adapter"] [tool.pytest.ini_options] addopts = "-s -vv" From 5ae747a87a5334eae8bd26a6966f5930ab47f484 Mon Sep 17 00:00:00 2001 From: Anthony Mahanna Date: Mon, 13 Nov 2023 16:30:11 -0500 Subject: [PATCH 4/7] fix lint & dependencies --- adbdgl_adapter/utils.py | 4 +--- pyproject.toml | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/adbdgl_adapter/utils.py b/adbdgl_adapter/utils.py index b88dc73..1498a1a 100644 --- a/adbdgl_adapter/utils.py +++ b/adbdgl_adapter/utils.py @@ -23,9 +23,7 @@ logger.addHandler(handler) -def get_export_spinner_progress( - text: str, -) -> Progress: +def get_export_spinner_progress(text: str) -> Progress: return Progress( TextColumn(text), SpinnerColumn("aesthetic", "#5BC0DE"), diff --git a/pyproject.toml b/pyproject.toml index 345eee3..8b90fda 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,7 +34,7 @@ dependencies = [ "requests>=2.27.1", "rich>=12.5.1", "pandas>=1.3.5", - "dgl~=1.0", + "dgl~=1", "torch>=1.12.0", "python-arango~=7.6", "setuptools>=45", @@ -44,6 +44,7 @@ dependencies = [ dev = [ "black==23.3.0", "flake8==6.0.0", + "Flake8-pyproject", "isort==5.12.0", "mypy==1.4.1", "pytest>=6.0.0", From d9397bcc0a7b187e4a41d4ea1b53dcd43cccce79 Mon Sep 17 00:00:00 2001 From: Anthony Mahanna Date: Mon, 13 Nov 2023 16:31:34 -0500 Subject: [PATCH 5/7] Update pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 8b90fda..911bb59 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,7 +34,7 @@ dependencies = [ "requests>=2.27.1", "rich>=12.5.1", "pandas>=1.3.5", - "dgl~=1", + "dgl>=1.1.0", "torch>=1.12.0", "python-arango~=7.6", "setuptools>=45", From 7c70633e5641228ad6d59e5bc0974666e6e24092 Mon Sep 17 00:00:00 2001 From: Anthony Mahanna Date: Mon, 13 Nov 2023 16:34:33 -0500 Subject: [PATCH 6/7] disable python 3.12 --- .github/workflows/build.yml | 2 +- pyproject.toml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2b5a0c5..840478e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python: ["3.8", "3.9", "3.10", "3.11", "3.12"] + python: ["3.8", "3.9", "3.10", "3.11"] # "3.12" name: Python ${{ matrix.python }} steps: - uses: actions/checkout@v4 diff --git a/pyproject.toml b/pyproject.toml index 911bb59..b90d4fb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,7 +25,7 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", + # "Programming Language :: Python :: 3.12", "Topic :: Utilities", "Typing :: Typed", ] @@ -34,7 +34,7 @@ dependencies = [ "requests>=2.27.1", "rich>=12.5.1", "pandas>=1.3.5", - "dgl>=1.1.0", + "dgl>=1.0.0", "torch>=1.12.0", "python-arango~=7.6", "setuptools>=45", From 7266476412946bcee7fd7ff762ca5d527ea12c62 Mon Sep 17 00:00:00 2001 From: Anthony Mahanna Date: Mon, 13 Nov 2023 16:48:17 -0500 Subject: [PATCH 7/7] fix lint --- adbdgl_adapter/adapter.py | 18 ++++++++---------- tests/test_adapter.py | 12 ++++++------ 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/adbdgl_adapter/adapter.py b/adbdgl_adapter/adapter.py index 71a3092..601055d 100644 --- a/adbdgl_adapter/adapter.py +++ b/adbdgl_adapter/adapter.py @@ -374,8 +374,8 @@ def arangodb_graph_to_dgl( :raise adbdgl_adapter.exceptions.ADBMetagraphError: If invalid metagraph. """ graph = self.__db.graph(name) - v_cols: Set[str] = graph.vertex_collections() # type: ignore - edge_definitions: List[Json] = graph.edge_definitions() # type: ignore + v_cols: Set[str] = graph.vertex_collections() + edge_definitions: List[Json] = graph.edge_definitions() e_cols: Set[str] = {c["edge_collection"] for c in edge_definitions} return self.arangodb_collections_to_dgl( @@ -660,12 +660,12 @@ def get_aql_return_value( ) """ - col_size: int = self.__db.collection(col).count() # type: ignore + col_size: int = self.__db.collection(col).count() with get_export_spinner_progress(f"ADB Export: '{col}' ({col_size})") as p: p.add_task(col) - cursor: Cursor = self.__db.aql.execute( # type: ignore + cursor: Cursor = self.__db.aql.execute( f"FOR doc IN @@col RETURN {get_aql_return_value(meta)}", bind_vars={"@col": col}, **{**adb_export_kwargs, **{"stream": True}}, @@ -711,7 +711,7 @@ def __process_adb_cursor( with Live(Group(progress)): i = 0 while not cursor.empty(): - cursor_batch = len(cursor.batch()) # type: ignore + cursor_batch = len(cursor.batch()) df = DataFrame([cursor.pop() for _ in range(cursor_batch)]) i = process_adb_df(i, df, col, adb_map, meta, **kwargs) @@ -1133,7 +1133,7 @@ def __create_adb_graph( edge_definitions = self.__etypes_to_edefinitions(edge_types) orphan_collections = self.__ntypes_to_ocollections(node_types, edge_types) - return self.__db.create_graph( # type: ignore[return-value] + return self.__db.create_graph( name, edge_definitions, orphan_collections, @@ -1188,8 +1188,7 @@ def __process_dgl_node_batch( # 3. Apply the ArangoDB Node Controller (if provided) if is_custom_controller: - f = lambda n: self.__cntrl._prepare_dgl_node(n, n_type) - df = df.apply(f, axis=1) + df = df.apply(lambda n: self.__cntrl._prepare_dgl_node(n, n_type), axis=1) return df @@ -1262,8 +1261,7 @@ def __process_dgl_edge_batch( # 3. Apply the ArangoDB Edge Controller (if provided) if is_custom_controller: - f = lambda e: self.__cntrl._prepare_dgl_edge(e, e_type) - df = df.apply(f, axis=1) + df = df.apply(lambda e: self.__cntrl._prepare_dgl_edge(e, e_type), axis=1) return df diff --git a/tests/test_adapter.py b/tests/test_adapter.py index 4d913e4..7adc9d1 100644 --- a/tests/test_adapter.py +++ b/tests/test_adapter.py @@ -44,7 +44,7 @@ class Bad_ADBDGL_Controller: pass with pytest.raises(TypeError): - ADBDGL_Adapter(bad_db) # type: ignore + ADBDGL_Adapter(bad_db) with pytest.raises(TypeError): ADBDGL_Adapter(db, Bad_ADBDGL_Controller()) # type: ignore @@ -366,7 +366,7 @@ def test_dgl_to_adb( explicit_metagraph, overwrite_graph, batch_size, - **adb_import_kwargs + **adb_import_kwargs, ) assert_dgl_to_adb(name, dgl_g, metagraph, explicit_metagraph) db.delete_graph(name, drop_collections=True) @@ -379,11 +379,11 @@ def test_dgl_to_adb_with_controller() -> None: ADBDGL_Adapter(db, Custom_ADBDGL_Controller()).dgl_to_arangodb(name, data) - for doc in db.collection(name + "_N"): # type: ignore + for doc in db.collection(name + "_N"): assert "foo" in doc assert doc["foo"] == "bar" - for edge in db.collection(name + "_E"): # type: ignore + for edge in db.collection(name + "_E"): assert "bar" in edge assert edge["bar"] == "foo" @@ -659,8 +659,8 @@ def test_adb_graph_to_dgl( dgl_g_new = adapter.arangodb_graph_to_dgl(name) graph = db.graph(name) - v_cols: Set[str] = graph.vertex_collections() # type: ignore - edge_definitions: List[Dict[str, Any]] = graph.edge_definitions() # type: ignore + v_cols: Set[str] = graph.vertex_collections() + edge_definitions: List[Dict[str, Any]] = graph.edge_definitions() e_cols: Set[str] = {c["edge_collection"] for c in edge_definitions} assert_adb_to_dgl(