Skip to content

new: enable black, isort, flake8, mypy #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jun 11, 2024
Merged
53 changes: 36 additions & 17 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,49 @@ on:
pull_request:
push:
branches: [ main ]

env:
PACKAGE_DIR: nx_arangodb
TESTS_DIR: tests

jobs:
build:
lint:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v4

- name: Setup Python 3.10
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: 'pip'
cache-dependency-path: setup.py

- name: Setup pip
run: python -m pip install --upgrade pip setuptools wheel

- name: Install packages
run: pip install .[dev]

- name: Run black
run: black --check --verbose --diff --color ${{env.PACKAGE_DIR}} ${{env.TESTS_DIR}}

- name: Run flake8
run: flake8 ${{env.PACKAGE_DIR}} ${{env.TESTS_DIR}}

- name: Run isort
run: isort --check --profile=black ${{env.PACKAGE_DIR}} ${{env.TESTS_DIR}}

- name: Run mypy
run: mypy ${{env.PACKAGE_DIR}} ${{env.TESTS_DIR}}

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: 'pip'
Expand All @@ -30,22 +61,10 @@ jobs:
run: python -m pip install --upgrade pip setuptools wheel

- name: Install packages
run: pip install .[test]

# - name: Run black
# run: black --check --verbose --diff --color ${{env.PACKAGE_DIR}} ${{env.TESTS_DIR}}

# - name: Run flake8
# run: flake8 ${{env.PACKAGE_DIR}} ${{env.TESTS_DIR}}

# - name: Run isort
# run: isort --check --profile=black ${{env.PACKAGE_DIR}} ${{env.TESTS_DIR}}

# - name: Run mypy
# run: mypy ${{env.PACKAGE_DIR}} ${{env.TESTS_DIR}}
run: pip install .[dev]

- name: Run local tests
run: pytest tests/test.py

- name: Run NetworkX tests
run: ./run_nx_tests.sh
run: ./run_nx_tests.sh
7 changes: 5 additions & 2 deletions nx_arangodb/algorithms/centrality/betweenness.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# type: ignore
# NOTE: NetworkX algorithms are not typed

import networkx as nx

from nx_arangodb.convert import _to_nxadb_graph, _to_nxcg_graph
from nx_arangodb.convert import _to_nx_graph, _to_nxcg_graph
from nx_arangodb.logger import logger
from nx_arangodb.utils import networkx_algorithm

Expand Down Expand Up @@ -40,7 +43,7 @@ def betweenness_centrality(
print("Running nxcg.betweenness_centrality()")
return nxcg.betweenness_centrality(G, k=k, normalized=normalized, weight=weight)

G = _to_nxadb_graph(G, pull_graph=pull_graph_on_cpu)
G = _to_nx_graph(G, pull_graph=pull_graph_on_cpu)

logger.debug("using nx.betweenness_centrality")
return nx.betweenness_centrality.orig_func(
Expand Down
7 changes: 5 additions & 2 deletions nx_arangodb/algorithms/community/louvain.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# type: ignore
# NOTE: NetworkX algorithms are not typed

from collections import deque

import networkx as nx

from nx_arangodb.convert import _to_nxadb_graph, _to_nxcg_graph
from nx_arangodb.convert import _to_nx_graph, _to_nxcg_graph
from nx_arangodb.logger import logger
from nx_arangodb.utils import _dtype_param, networkx_algorithm

Expand Down Expand Up @@ -50,7 +53,7 @@ def louvain_communities(
seed=seed,
)

G = _to_nxadb_graph(G, pull_graph=pull_graph_on_cpu)
G = _to_nx_graph(G, pull_graph=pull_graph_on_cpu)

logger.debug("using nx.louvain_communities")
return nx.community.louvain_communities.orig_func(
Expand Down
7 changes: 5 additions & 2 deletions nx_arangodb/algorithms/link_analysis/pagerank_alg.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# type: ignore
# NOTE: NetworkX algorithms are not typed

import networkx as nx

from nx_arangodb.convert import _to_nxadb_graph, _to_nxcg_graph
from nx_arangodb.convert import _to_nx_graph, _to_nxcg_graph
from nx_arangodb.logger import logger
from nx_arangodb.utils import _dtype_param, networkx_algorithm

Expand Down Expand Up @@ -51,7 +54,7 @@ def pagerank(
dtype=dtype,
)

G = _to_nxadb_graph(G, pull_graph=pull_graph_on_cpu)
G = _to_nx_graph(G, pull_graph=pull_graph_on_cpu)

logger.debug("using nx.pagerank")
return nx.algorithms.pagerank.orig_func(
Expand Down
3 changes: 3 additions & 0 deletions nx_arangodb/algorithms/shortest_paths/generic.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# type: ignore
# NOTE: NetworkX algorithms are not typed

import networkx as nx

import nx_arangodb as nxadb
Expand Down
Loading