Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions .github/workflows/docker-in-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: docker

on:
pull_request:
branches:
- main
push:
branches:
- main
Expand All @@ -11,18 +13,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v7

- name: Build docker basic image
run: |
docker build -t abcd-graph .
docker build --pull -t abcd-graph .

- name: Inspect basic docker image
run: |
docker image inspect abcd-graph

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@0.31.0
uses: aquasecurity/trivy-action@v0.36.0
with:
image-ref: 'abcd-graph'
format: 'table'
Expand All @@ -41,18 +43,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v7

- name: Build docker full image
run: |
docker build -t abcd-graph-full --build-arg INSTALL_TYPE=all .
docker build --pull -t abcd-graph-full --build-arg INSTALL_TYPE=all .

- name: Inspect full docker image
run: |
docker image inspect abcd-graph-full

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@0.31.0
uses: aquasecurity/trivy-action@v0.36.0
with:
image-ref: 'abcd-graph-full'
format: 'table'
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ repos:
- id: flake8
args: [ --max-line-length, "120" ]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.4.1
rev: v2.3.1
hooks:
- id: mypy
args: [ --config-file, pyproject.toml ]
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
FROM python:3.12-alpine AS build

# Install build tools + curl
RUN apk add --no-cache \
RUN apk update && apk add --no-cache --upgrade \
bash \
curl \
libffi-dev \
build-base \
linux-headers
linux-headers \
libuuid>=2.42.3-r1

# Install uv and upgrade pip/setuptools
RUN pip install --upgrade pip setuptools && pip install uv
Expand Down
4 changes: 2 additions & 2 deletions src/abcd_graph/callbacks/visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def after_build(self, graph: GraphImpl, context: BuildContext, exporter: GraphEx

@require("matplotlib")
def draw_community_cdf(self) -> None:
import matplotlib.pyplot as plt # type: ignore[import]
import matplotlib.pyplot as plt # type: ignore[import-not-found]

assert self._graph is not None

Expand Down Expand Up @@ -104,7 +104,7 @@ def draw_communities(self) -> None:
if self._model_used is not None and self._model_used.__name__ != "configuration_model":
raise NotImplementedError("Drawing communities is only supported for the configuration model")

import networkx as nx # type: ignore[import]
import networkx as nx
from matplotlib import pyplot as plt

assert self._exporter is not None
Expand Down
11 changes: 6 additions & 5 deletions src/abcd_graph/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
from abcd_graph.utils import require

if TYPE_CHECKING: # pragma: no cover
from igraph import Graph as IGraph # type: ignore[import]
from networkx import Graph as NetworkXGraph # type: ignore[import]
from scipy.sparse import csr_matrix # type: ignore[import]
from igraph import Graph as IGraph # type: ignore[import-not-found]
from networkx import Graph as NetworkXGraph
from scipy.sparse import csr_matrix


class GraphExporter:
Expand All @@ -49,7 +49,7 @@ def to_adjacency_matrix(self) -> NDArray[np.bool_]:
return self._graph.to_adj_matrix()

@require("scipy")
def to_sparse_adjacency_matrix(self) -> "csr_matrix": # type: ignore[no-any-unimported]
def to_sparse_adjacency_matrix(self) -> "csr_matrix":
from scipy.sparse import csr_matrix

if not self.is_proper_abcd:
Expand All @@ -69,9 +69,10 @@ def to_igraph(self) -> "IGraph": # type: ignore[no-any-unimported]
return graph

@require("networkx")
def to_networkx(self) -> "NetworkXGraph": # type: ignore[no-any-unimported]
def to_networkx(self) -> "NetworkXGraph":
import networkx as nx

graph: nx.Graph = nx.Graph()
graph = nx.Graph()

graph.add_nodes_from(range(self._graph._params.vcount))
Expand Down
2 changes: 1 addition & 1 deletion src/abcd_graph/graph/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def powerlaw_distribution(choices: NDArray[np.float64], intensity: float) -> NDA


def get_community_color_map(communities: list["Community"]) -> list[str]:
import matplotlib.colors as colors # type: ignore[import]
import matplotlib.colors as colors # type: ignore[import-not-found]

colors_list = list(colors.BASE_COLORS.values())[: len(communities)]

Expand Down
Loading