Skip to content
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

Fix teardown #1

Merged
merged 8 commits into from
Nov 8, 2024
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -U build pip twine
pip install -e .[doc,test,scrape]
pip install -e .[doc,test]

- name: Build and check package
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[test,scrape]
pip install -e .[test]

- name: Cache Test Data
uses: actions/cache@v4
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,7 @@ downloaded_pdfs/
results/*

# html
html/*
html/*

# envs
env/*
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ clean_local:
@find . -name "__pycache__" -type d -delete
@rm -f .coverage coverage.xml
@ruff clean
@rm -rf .mypy_cache .pytest_cache build dist nxbench.egg-info htmlcov .benchmarks
@rm -rf .mypy_cache .pytest_cache build dist nxbench.egg-info htmlcov .benchmarks env

install: clean_local
pip uninstall nxbench -y
Expand Down
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# nxbench

**nxbench** is a comprehensive benchmarking suite designed to facilitate comparative profiling of graph analytic algorithms across NetworkX and compatible backends. Built with an emphasis on reproducibility, extensibility, and detailed performance analysis, nxbench enables developers and researchers to optimize their graph analysis workflows efficiently.
**nxbench** is a comprehensive benchmarking suite designed to facilitate comparative profiling of graph analytic algorithms across NetworkX and compatible backends. Built with an emphasis on extensibility and detailed performance analysis, nxbench aims to enable developers and researchers to optimize their graph analysis workflows efficiently and reproducibly.

## Features
## Key Features

- **Cross-Backend Benchmarking**: Leverage NetworkX's backend system to profile algorithms across multiple implementations (NetworkX, nx-parallel, GraphBLAS, and CuGraph)
- **Configurable Suite**: YAML-based configuration for algorithms, datasets, and benchmarking parameters
- **Real-World Datasets**: Automated downloading and caching of networks from NetworkRepository
- **Synthetic Graph Generation**: Support for generating benchmark graphs using NetworkX's built-in generators
- **Real-World Datasets**: Automated downloading and caching of networks and their metadata from NetworkRepository
- **Synthetic Graph Generation**: Support for generating benchmark graphs using any of NetworkX's built-in generators
- **Validation Framework**: Comprehensive result validation for correctness across implementations
- **Performance Monitoring**: Track execution time and memory usage with detailed metrics
- **Interactive Visualization**: Dynamic dashboard for exploring benchmark results using Plotly Dash
Expand Down Expand Up @@ -54,7 +54,7 @@ nxbench --config 'configs/example.yaml' benchmark run
3. Export results:

```bash
nxbench benchmark export 'results/benchmarks.csv' --output-format csv # Convert benchmarked results into csv format.
nxbench benchmark export 'results/results.csv' --output-format csv # Convert benchmarked results into csv format.
```


Expand All @@ -69,6 +69,9 @@ nxbench viz serve # Launch interactive dashboard
The CLI provides comprehensive management of benchmarks, datasets, and visualization:

```bash
# Validating asv configuration
asv check

# Data Management
nxbench data download karate # Download specific dataset
nxbench data list --category social # List available datasets
Expand All @@ -78,7 +81,6 @@ nxbench --config 'configs/example.yaml' -vvv benchmark run # Debug benchmark ru
nxbench benchmark export 'results/benchmarks.sqlite' --output-format sql # Export the results into a sql database
nxbench benchmark compare HEAD HEAD~1 # Compare with previous commit


# Visualization
nxbench viz serve # Launch parallel categories dashboard
nxbench viz publish # Generate static asv report
Expand Down Expand Up @@ -107,14 +109,14 @@ datasets:

- NetworkX (default)
- CuGraph (requires separate CUDA installation and supported GPU hardware)
- GraphBLAS (optional)
- GraphBLAS Algorithms (optional)
- nx-parallel (optional)

## Development

```bash
# Install development dependencies
pip install -e .[test,scrape,doc] # testing, scraping of real-world graph data, and documentation
pip install -e .[test,doc] # testing and documentation

# Run tests
make test
Expand Down
29 changes: 1 addition & 28 deletions _nxbench/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
from collections.abc import Callable
from dataclasses import dataclass, field
from typing import Any
Expand All @@ -18,25 +17,19 @@ class NxBenchConfig(Config):

active: bool = False

num_thread: int = 8
num_gpu: int = 0
verbosity_level: int = 0
backend_name: str = "nxbench"
backend_params: dict = field(default_factory=dict)

logging_config: LoggingConfig = field(default_factory=LoggingConfig)

_NUM_THREAD = "NUM_THREAD"
_NUM_GPU = "NUM_GPU"

_observers: list[Callable[[str, Any], None]] = field(
default_factory=list, init=False, repr=False
)

def __post_init__(self):
"""Set environment variables based on initialized fields."""
self.set_num_thread(self.num_thread)
self.set_num_gpu(self.num_gpu)
self.set_verbosity_level(self.verbosity_level)

def register_observer(self, callback: Callable[[str, Any], None]) -> None:
"""Register an observer callback to be notified on configuration changes.
Expand All @@ -63,26 +56,6 @@ def notify_observers(self, name: str, value: Any) -> None:
for callback in self._observers:
callback(name, value)

def set_num_thread(self, threads: int) -> None:
"""Set the number of threads."""
os.environ[self._NUM_THREAD] = str(threads)
self.num_thread = threads
self.notify_observers("num_thread", threads)

def get_num_thread(self) -> int:
"""Get the number of threads."""
return self.num_thread

def set_num_gpu(self, gpus: int) -> None:
"""Set the number of GPUs."""
os.environ[self._NUM_GPU] = str(gpus)
self.num_gpu = gpus
self.notify_observers("num_gpu", gpus)

def get_num_gpu(self) -> int:
"""Get the number of GPUs."""
return self.num_gpu

def set_verbosity_level(self, level: int) -> None:
"""Set the verbosity level (0-2). 2=DEBUG, 1=INFO, 0=NO logging."""
if level not in [0, 1, 2]:
Expand Down
25 changes: 10 additions & 15 deletions asv.conf.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": 1,
"project": "nxbench",
"timeout": 120,
"timeout": 3000,
"project_url": "https://github.com/dpys/nxbench",
"repo": ".",
"branches": [
Expand All @@ -10,19 +10,14 @@
"environment_type": "existing",
"show_commit_url": "https://github.com/dpys/nxbench/commit/",
"pythons": [
"3.10"
"3.11"
],
"matrix": {
"networkx": [
"3.3"
],
"nx-parallel": [
"0.3rc0.dev0"
],
"python-graphblas": [
"2024.2.0"
]
},
"req": [
"networkx==3.4.2",
"nx_parallel==0.3",
"graphblas_algorithms==2023.10.0"
],
"matrix": {},
"benchmark_dir": "nxbench/benchmarks",
"env_dir": "env",
"results_dir": "results",
Expand All @@ -32,12 +27,12 @@
"asv_runner"
],
"build_command": [
"python -m pip install ."
"PIP_NO_BUILD_ISOLATION=false python -m pip install ."
],
"install_command": [
"python -m pip install {wheel_file}"
],
"uninstall_command": [
"return-code=any python -m pip uninstall -y {project}"
]
}
}
18 changes: 10 additions & 8 deletions configs/example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,10 @@ datasets:
source: "networkrepository"
params: {}

- name: "IMDB"
source: "networkrepository"
params: {}

- name: "citeseer"
source: "networkrepository"
params: {}

- name: "enron"
source: "networkrepository"
params: {}

- name: "twitter"
source: "networkrepository"
params: {}
Expand Down Expand Up @@ -217,3 +209,13 @@ validation:
validate_all: true
error_on_fail: true
report_memory: true

matrix:
backend:
- "networkx"
- "parallel"
- "graphblas"
num_threads:
- "1"
- "4"
- "8"
Loading
Loading