Skip to content

Commit

Permalink
Migrate to pyproject.toml (#33)
Browse files Browse the repository at this point in the history
* initial commit

* add 3.12 to build workflow

* fix typos

* fix lint & dependencies

* Update pyproject.toml

* disable python 3.12

* fix lint
  • Loading branch information
aMahanna authored Nov 15, 2023
1 parent 7b7c378 commit 8cd989e
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 90 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 8 additions & 10 deletions adbdgl_adapter/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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}},
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
4 changes: 1 addition & 3 deletions adbdgl_adapter/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
86 changes: 79 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,89 @@
[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 = "[email protected]"}]

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.0",
"torch>=1.12.0",
"python-arango~=7.6",
"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",
"types-requests",
]

[project.urls]
"Homepage" = "https://github.com/arangoml/dgl-adapter"

[tool.setuptools]
packages = ["adbdgl_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
12 changes: 0 additions & 12 deletions setup.cfg

This file was deleted.

52 changes: 1 addition & 51 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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="[email protected]",
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()
12 changes: 6 additions & 6 deletions tests/test_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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"

Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 8cd989e

Please sign in to comment.