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
graflag evaluate -e exp__bond_dominant__bond_inj_cora__20260309_120000
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 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 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.
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.1.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.1.0.tar.gz | 257.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| graflag-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 473.0 kB
Release files / graflag-1.1.0.tar.gz
| Download URL | graflag-1.1.0.tar.gz |
|---|---|
| Size | 257.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
827eb08e350b933344a80112ae5a10aa7c6507bc674b4bfbd1e44e8fc6eab019
|
|
BLAKE2b-256 checksum How to use checksums |
1ca5c4e85bb40133fb6c86f055e877bd2c555733263acd74d46201cef1d25786
|
| 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.1.0-py3-none-any.whl
| Download URL | graflag-1.1.0-py3-none-any.whl |
|---|---|
| Size | 216.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0d09546a86f36870986f6a3d1219edcd7373bac692c31cbaaf5a15a7646ef3cc
|
|
BLAKE2b-256 checksum How to use checksums |
df646f020d90951b167217be661aed6365e36b825ca6566a36c3b068b839d048
|
| 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