Cluster resource management bot for IM platforms
Project description
lockbot
Cluster resource management bot for IM platforms (e.g., Baidu InfoFlow).
Lock and unlock GPU devices, cluster nodes, and queue slots via chat commands. Supports both standalone Flask deployment and a full platform mode with FastAPI + Vue.js frontend.
Features
- Device Lock Bot — Lock/unlock individual GPUs or devices on a cluster
- Node Lock Bot — Lock/unlock entire cluster nodes
- Queue Bot — Manage a queue for resource allocation with booking and preemption
- Platform Mode — Web UI (Vue 3 + Element Plus) for managing multiple bots, user authentication (JWT), role-based access control, and real-time logs
- State Persistence — Bot state survives restarts (JSON file)
- Bilingual — English and Chinese UI and bot responses
Quick Start — Platform Mode (Recommended)
Full management platform with Web UI, multi-bot orchestration, user authentication, and admin panel.
- Install:
pip install lockbot
- Set environment variables:
export JWT_SECRET="your-jwt-secret"
export ENCRYPTION_KEY="your-fernet-key" # python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"
export DEV_MODE="true" # dev mode, auto-create admin user
- Start:
# Backend
uvicorn lockbot.backend.app.main:app --host 0.0.0.0 --port 8000 --reload
# Frontend (another terminal)
cd frontend && npm install && npm run dev
- Open
http://localhost:8000in your browser.
Docker
# 1. Generate ENCRYPTION_KEY and JWT_SECRET
python tools/gen_keys.py
# 2. Pull pre-built image (or build from source)
docker pull ghcr.io/dynamicheart/lockbot:latest
# docker build -f docker/Dockerfile -t lockbot .
# 3. Run (replace the keys with generated values)
docker run -d --name lockbot -p 8000:8000 \
-e JWT_SECRET=your-secret \
-e ENCRYPTION_KEY=your-fernet-key \
-v lockbot-data:/data \
ghcr.io/dynamicheart/lockbot:latest
# 4. Create super_admin (password auto-generated and printed)
docker exec -it lockbot python tools/create_super_admin.py --username admin --email admin@example.com
Data persistence: All data (SQLite DB, bot state files) stored under
/data. Override withDATA_DIRenv var.
Bot Configuration
| Key | Description | Default |
|---|---|---|
BOT_TYPE |
DEVICE, NODE, or QUEUE |
(required) |
BOT_NAME |
Bot instance name | demo_bot |
CLUSTER_CONFIGS |
Cluster layout (dict or list) | {} |
TOKEN |
Bot signature verification token | "" |
AESKEY |
Message decryption AES key | "" |
WEBHOOK_URL |
Message webhook URL | "" |
PORT |
Server listen port | 8090 |
DEFAULT_DURATION |
Default lock duration (seconds) | 7200 (2h) |
MAX_LOCK_DURATION |
Max lock duration (seconds) | -1 (unlimited) |
EARLY_NOTIFY |
Notify before lock expiry | false |
See python/lockbot/core/config.py for the full configuration reference.
Commands
| Command | Description |
|---|---|
lock <node> [duration] |
Exclusive lock (e.g., lock gpu0 3d, lock node1 30m) |
slock <node> [duration] |
Shared lock (multiple users) |
unlock <node> / free <node> |
Release a specific node |
unlock / free |
Release all your nodes |
kickout <node> |
Force release (admin) |
book <node> [duration] |
Queue: book a node for later |
take <node> |
Queue: take the current lock |
<node> |
Query current usage |
help |
Show usage |
Development
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Lint + format check
ruff check python/ tests/
ruff format --check python/ tests/
Standalone Mode
Single-bot deployment with a lightweight Flask webhook server.
Device Lock Bot (per-GPU locking):
from lockbot.core.bot_instance import BotInstance
from lockbot.core.entry import create_app
instance = BotInstance("DEVICE", {
"BOT_NAME": "my-gpu-bot",
"WEBHOOK_URL": "https://your-webhook-url",
"TOKEN": "your-bot-token",
"AESKEY": "your-aes-key",
"CLUSTER_CONFIGS": {
"node0": ["A800", "A800", "H100"],
"node1": ["A800", "H100"],
},
})
app = create_app(bot=instance.bot, bot_name="my-gpu-bot", port=8000)
app.run(host="0.0.0.0", port=8000)
Node Lock Bot / Queue Bot (per-node locking or queue scheduling):
from lockbot.core.bot_instance import BotInstance
from lockbot.core.entry import create_app
instance = BotInstance("NODE", { # or "QUEUE" for queue scheduling
"BOT_NAME": "my-node-bot",
"WEBHOOK_URL": "https://your-webhook-url",
"TOKEN": "your-bot-token",
"AESKEY": "your-aes-key",
"CLUSTER_CONFIGS": ["node0", "node1", "node2", "node3"],
})
app = create_app(bot=instance.bot, bot_name="my-node-bot", port=8000)
app.run(host="0.0.0.0", port=8000)
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lockbot-2.5.2.tar.gz.
File metadata
- Download URL: lockbot-2.5.2.tar.gz
- Upload date:
- Size: 72.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3153149ce509c3fb095873a99fc13de02de57984402aa73bf7295ba773b9dbe
|
|
| MD5 |
10187ce8cb3d99b6df128105fbd07d42
|
|
| BLAKE2b-256 |
68df3a000126f7a41b495a5e026a1078066398331c96ba2971e4a0fca2762e5f
|
Provenance
The following attestation bundles were made for lockbot-2.5.2.tar.gz:
Publisher:
publish.yml on dynamicheart/lockbot
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lockbot-2.5.2.tar.gz -
Subject digest:
f3153149ce509c3fb095873a99fc13de02de57984402aa73bf7295ba773b9dbe - Sigstore transparency entry: 1341728293
- Sigstore integration time:
-
Permalink:
dynamicheart/lockbot@f52053298a0636229ef13c3793cac70f3fe57fc8 -
Branch / Tag:
refs/tags/v2.5.2 - Owner: https://github.com/dynamicheart
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f52053298a0636229ef13c3793cac70f3fe57fc8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file lockbot-2.5.2-py3-none-any.whl.
File metadata
- Download URL: lockbot-2.5.2-py3-none-any.whl
- Upload date:
- Size: 85.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d113a8177c7770a7f9031e2d233fd6fdef083d275faa4824e2772dbcdd692c8
|
|
| MD5 |
6e97a37d1d40fad69341096729ca90a8
|
|
| BLAKE2b-256 |
d73cd82a0f075da0aba3c40ecbfda43d954a9266fff4104c65c6f904be0ed38a
|
Provenance
The following attestation bundles were made for lockbot-2.5.2-py3-none-any.whl:
Publisher:
publish.yml on dynamicheart/lockbot
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lockbot-2.5.2-py3-none-any.whl -
Subject digest:
1d113a8177c7770a7f9031e2d233fd6fdef083d275faa4824e2772dbcdd692c8 - Sigstore transparency entry: 1341728297
- Sigstore integration time:
-
Permalink:
dynamicheart/lockbot@f52053298a0636229ef13c3793cac70f3fe57fc8 -
Branch / Tag:
refs/tags/v2.5.2 - Owner: https://github.com/dynamicheart
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f52053298a0636229ef13c3793cac70f3fe57fc8 -
Trigger Event:
push
-
Statement type: