diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4e027fc..8b2dbce 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 @@ -32,7 +32,7 @@ jobs: - name: Install packages run: | - pip install torch + pip install torch==2.1.0 pip install torch-scatter torch-sparse -f https://data.pyg.org/whl/torch-$(python -c 'import torch; print(torch.__version__.split("+")[0])')+cpu.html pip install -e .[dev] diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 73b81f3..ac040fc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -68,12 +68,12 @@ jobs: run: gitchangelog ${{env.VERSION}} > CHANGELOG.md - name: Make commit for auto-generated changelog - uses: EndBug/add-and-commit@v7 + uses: EndBug/add-and-commit@v9 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: add: "CHANGELOG.md" - branch: actions/changelog + new_branch: actions/changelog message: "!gitchangelog" - name: Create pull request for the auto generated changelog diff --git a/adbpyg_adapter/adapter.py b/adbpyg_adapter/adapter.py index 7593eb4..1c86515 100644 --- a/adbpyg_adapter/adapter.py +++ b/adbpyg_adapter/adapter.py @@ -437,8 +437,8 @@ def arangodb_graph_to_pyg( :raise adbpyg_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_pyg( @@ -731,12 +731,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}}, @@ -785,7 +785,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, preserve_key, **kwargs) @@ -1180,7 +1180,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, @@ -1239,8 +1239,7 @@ def __process_pyg_node_batch( # 3. Apply the ArangoDB Node Controller (if provided) if is_custom_controller: - f = lambda n: self.__cntrl._prepare_pyg_node(n, n_type) - df = df.apply(f, axis=1) + df = df.apply(lambda n: self.__cntrl._prepare_pyg_node(n, n_type), axis=1) return df @@ -1313,8 +1312,7 @@ def __process_pyg_edge_batch( # 5. Apply the ArangoDB Edge Controller (if provided) if is_custom_controller: - f = lambda e: self.__cntrl._prepare_pyg_edge(e, e_type) - df = df.apply(f, axis=1) + df = df.apply(lambda e: self.__cntrl._prepare_pyg_edge(e, e_type), axis=1) return df diff --git a/adbpyg_adapter/utils.py b/adbpyg_adapter/utils.py index 200bea7..126677c 100644 --- a/adbpyg_adapter/utils.py +++ b/adbpyg_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 8d93036..9552e8a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,17 +1,92 @@ [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 = [ - "adbpyg_adapter/version.py", - "setup.py", +[tool.setuptools_scm] +normalize = true + +[project] +name = "adbpyg_adapter" +description = "Convert ArangoDB graphs to PyG & vice-versa." +keywords = ["arangodb", "pyg", "pytorch", "pytorch geometric", "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", + "python-arango~=7.6", + "torch>=1.12.0", + "torch-sparse>=0.6.14", + "torch-scatter>=2.0.9", + "torch-geometric>=2.0.4", + "setuptools>=45" +] + +[project.optional-dependencies] +dev = [ + "black==23.3.0", + "flake8==6.0.0", + "Flake8-pyproject", + "isort==5.12.0", + "mypy==1.4.1", + "pytest>=6.0.0", + "pytest-cov>=2.0.0", + "coveralls>=3.3.1", + "types-setuptools>=57.4.9", + "types-requests>=2.27.11", + "networkx>=2.5.1", ] +[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 = "adbpyg_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 1170e3c..0000000 --- a/setup.cfg +++ /dev/null @@ -1,12 +0,0 @@ -[isort] -profile = black - -[flake8] -max-line-length = 88 -extend-ignore = E203, E741, W503, E731, E721 -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 8fabf94..6068493 100644 --- a/setup.py +++ b/setup.py @@ -1,56 +1,3 @@ from setuptools import setup -with open("./README.md") as fp: - long_description = fp.read() - -setup( - name="adbpyg_adapter", - author="Anthony Mahanna", - author_email="anthony.mahanna@arangodb.com", - description="Convert ArangoDB graphs to PyG & vice-versa.", - long_description=long_description, - long_description_content_type="text/markdown", - url="https://github.com/arangoml/pyg-adapter", - keywords=["arangodb", "pyg", "pytorch", "pytorch geometric", "adapter"], - packages=["adbpyg_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", - "python-arango~=7.6", - "torch>=1.12.0", - "torch-sparse>=0.6.14", - "torch-scatter>=2.0.9", - "torch-geometric>=2.0.4", - "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>=57.4.9", - "types-requests>=2.27.11", - "networkx>=2.5.1", - ], - }, - 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() diff --git a/tests/test_adapter.py b/tests/test_adapter.py index 45aefdb..3042a8d 100644 --- a/tests/test_adapter.py +++ b/tests/test_adapter.py @@ -50,10 +50,10 @@ class Bad_ADBPyG_Controller: pass with pytest.raises(TypeError): - ADBPyG_Adapter(bad_db) # type: ignore + ADBPyG_Adapter(bad_db) with pytest.raises(TypeError): - ADBPyG_Adapter(db, Bad_ADBPyG_Controller()) # type: ignore + ADBPyG_Adapter(db, Bad_ADBPyG_Controller()) # type:ignore[arg-type] @pytest.mark.parametrize( @@ -395,11 +395,11 @@ def test_pyg_to_arangodb_with_controller() -> None: ADBPyG_Adapter(db, Custom_ADBPyG_Controller()).pyg_to_arangodb(name, data) - for doc in db.collection(f"{name}_N"): # type: ignore + for doc in db.collection(f"{name}_N"): assert "foo" in doc assert doc["foo"] == "bar" - for edge in db.collection(f"{name}_E"): # type: ignore + for edge in db.collection(f"{name}_E"): assert "bar" in edge assert edge["bar"] == "foo" @@ -649,8 +649,8 @@ def test_adb_graph_to_pyg( pyg_g_new = adapter.arangodb_graph_to_pyg(name) graph = 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} # Manually set the number of nodes (since nodes are feature-less) @@ -683,8 +683,8 @@ def test_adb_graph_to_pyg_to_arangodb_with_missing_document_and_strict( ADBPyG_Adapter(db).pyg_to_arangodb(name, data) graph = 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} for v_col in v_cols: @@ -713,8 +713,8 @@ def test_adb_graph_to_pyg_to_arangodb_with_missing_document_and_permissive( ADBPyG_Adapter(db).pyg_to_arangodb(name, data) graph = 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} for v_col in v_cols: @@ -728,7 +728,7 @@ def test_adb_graph_to_pyg_to_arangodb_with_missing_document_and_permissive( data = adapter.arangodb_to_pyg(name, metagraph=metagraph, strict=False) - collection_count: int = db.collection(list(e_cols)[0]).count() # type: ignore + collection_count: int = db.collection(list(e_cols)[0]).count() assert len(data.edge_index[0]) < collection_count db.delete_graph(name, drop_collections=True) @@ -799,8 +799,8 @@ def test_full_cycle_homogeneous_with_preserve_adb_keys() -> None: pyg_g = adbpyg_adapter.arangodb_graph_to_pyg(name, preserve_adb_keys=True) graph = 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} metagraph: ADBMetagraph = {