GraFlag
Distributed benchmarking framework for Graph Anomaly Detection (GAD). Orchestrates experiments on Docker Swarm clusters with NFS-based shared storage.
Installation
pip install graflag
Or from source:
git clone https://github.com/lias-laboratory/graflag.git
cd graflag
pip install -e .
This installs the graflag command (includes CLI, web GUI, and devcluster).
Related Repositories
- graflag-shared -- Methods, datasets, and shared libraries (NFS-mounted storage)
- Documentation -- Full documentation (Sphinx)
Quick Start
1. Set up the shared directory
Clone the shared storage repository on your NFS mount:
cd /shared # or your NFS mount point
git clone https://github.com/lias-laboratory/graflag-shared.git .
# Dataset files are not committed; they download on demand when you run
# `graflag run` (via the graflag_data library). Optional prefetch:
# pip install graflag-shared/libs/graflag_data
# graflag-data fetch # all datasets
2. Configure
Run the interactive setup wizard:
graflag setup
This stores configuration in ~/.config/graflag/config.env. To reconfigure later:
graflag setup --reconfigure
Or place a .env file in the working directory:
MANAGER_IP=192.168.100.10
SSH_PORT=22
SSH_KEY=~/.ssh/id_ed25519
SHARED_DIR=/shared
HOSTS_FILE=hosts.yml
3. Run an experiment
graflag run -m bond_dominant -d bond_inj_cora --build
graflag run -m taddy -d uci --params MAX_EPOCH=100 LEARNING_RATE=0.001
4. Evaluate and verify
graflag evaluate -e exp__bond_dominant__bond_inj_cora__20260309_120000
graflag verify -e exp__bond_dominant__bond_inj_cora__20260309_120000
verify checks that the published scores reproduce the AUC the method reported
and exits 1 when they do not.
Commands
| Command | Description |
|---|---|
graflag setup |
Interactive cluster configuration |
graflag run -m METHOD -d DATASET |
Run an experiment |
graflag status |
Show cluster status |
graflag list methods|datasets|experiments|services |
List resources |
graflag logs -e EXP [-f] |
View experiment logs |
graflag stop -e EXP [--rm] |
Stop an experiment |
graflag evaluate -e EXP |
Evaluate experiment results |
graflag verify -e EXP [--json] |
Check the published result holds up (exit 1 on failure) |
graflag cleanup [--dry-run] |
Remove Swarm services for finished experiments |
graflag copy -s SRC --dest DST [-r] |
Copy files to/from remote |
graflag sync [--lib] [--path PATH] |
Sync method or library |
graflag gui [--port PORT] |
Start web dashboard (binds 0.0.0.0, no auth -- see note below) |
graflag mcp [--config FILE] |
Serve GraFlag to an AI agent over MCP (stdio) |
graflag devcluster --hosts FILE |
Deploy virtual cluster |
graflag devcluster --down |
Stop virtual cluster |
Note on the dashboard.
graflag guibinds0.0.0.0:5000by default and has no authentication. Everything it exposes runs on the swarm manager asroot, including deleting experiment directories. Run it on a trusted network or bind it explicitly withgraflag gui --host 127.0.0.1.
AI Agents (MCP)
graflag mcp exposes GraFlag to an MCP client -- Claude Code, Claude Desktop or
any other -- as tools to list methods and datasets, run, wait for, stop,
evaluate and verify experiments, and read their results and plots. It needs the
optional SDK (Python 3.10+):
pip install "graflag[mcp]"
claude mcp add graflag -- graflag mcp
Runs start in the background and wait_for_experiment waits for them, so no
tool call has to outlast a benchmark. Nothing that deletes data, sets up the
cluster or writes code to it is offered. See the
MCP page of the
documentation.
Development Cluster
For local development without a physical cluster, describe the virtual nodes in
a hosts.yml:
subnet: 192.168.100.0/24
manager: 192.168.100.10
workers:
- 192.168.100.11
- 192.168.100.12
then deploy it and point GraFlag at it:
graflag devcluster --hosts hosts.yml
graflag setup
Development
Install in editable mode and run the test suite (no cluster or network needed):
pip install -e .
python3 -m unittest discover -s tests -v
The suite covers remote-command construction, experiment naming, and the GUI's
input validation. tests/test_ssh.py puts a fake ssh on PATH that records
the command the swarm manager would receive, then runs that string through a
real shell -- so it asserts on the actual effect rather than on a string shape.
Use that harness for any change that builds a remote command.
Two rules the tests enforce, worth knowing before editing ssh.py:
execute()passes the command tosshas a single argv element with no local shell. Reintroducingshell=Trueor wrapping the command in quotes breaks heredocs and lets Docker build output execute on the manager.- The manager's shell still parses the command, so interpolated values are
quoted at the point of use --
remote_path()for paths,shlex.quote()for bare values.
The shared libraries have their own suites:
cd ../graflag-shared/libs
PYTHONPATH=. python3 -m unittest discover -s graflag_data/tests -v
PYTHONPATH=. python3 -m unittest discover -s graflag_runner/tests -v
The documentation sources are in docs/ (Sphinx, published at
https://lias-laboratory.github.io/graflag/):
pip install sphinx sphinx-rtd-theme myst-parser
cd docs && make html # output in docs/_build/html
Publishing a GitHub release runs .github/workflows/publish.yml: the test
suite, then a build whose version must match the release tag, then the upload
to PyPI through Trusted Publishing.
Dependencies
pyyaml-- hosts.yml parsing for cluster setupdocker-- Docker SDK for Python (service management via SSH tunnel)flask,flask-socketio-- Web GUI backend
Module Structure
graflag/
__init__.py Package exports
cli.py Argument parsing, command dispatch, output formatting
core.py GraFlag orchestration class (returns structured data)
models.py Dataclass models (ClusterInfo, MethodInfo, ExperimentInfo, ...)
config.py Configuration loading (~/.config/graflag/config.env or .env)
ssh.py SSH and rsync file operations
docker_ops.py Docker Swarm operations via Docker SDK (SSH tunnel)
api.py Python API for GUI integration (wraps core)
utils.py Shared utility functions
gui/ Web dashboard subpackage (Flask + Vue.js)
devcluster/ Virtual cluster subpackage (Docker Compose)
tests/ Unit tests (unittest, no cluster required)
Metadata
Release files for graflag 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| graflag-1.2.0.tar.gz | 287.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| graflag-1.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 521.7 kB
Release files / graflag-1.2.0.tar.gz
| Download URL | graflag-1.2.0.tar.gz |
|---|---|
| Size | 287.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f8a7a2a0ce779178edb65e950d690bdd6b19990b42b45eaf04ae0a9988458fee
|
|
BLAKE2b-256 checksum How to use checksums |
fb0b6864ba2e80334fdf764ee3a7e3d98ccec07630282e3f68b7697fa25f1e11
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency logRelease files / graflag-1.2.0-py3-none-any.whl
| Download URL | graflag-1.2.0-py3-none-any.whl |
|---|---|
| Size | 234.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0798a7e0c10e1d04d396f1d5e963edb1632c14214e202fde635b1679a68b01e7
|
|
BLAKE2b-256 checksum How to use checksums |
a5d314e7aee05b600bb2f5257427f19443ea2b55379acafb6a431790a312ad47
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency log