Skip to content

Commit 389611f

Browse files
committed
Merge branch 'master' of https://github.com/Dramwig/FlowLine
2 parents 7f1a86a + 0d17bb3 commit 389611f

File tree

14 files changed

+11023
-38
lines changed

14 files changed

+11023
-38
lines changed

docs/fig/logo.png

371 KB
Loading

readme_en.md renamed to docs/readme_en.md

Lines changed: 92 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
# FlowLine
1+
<div align="center">
2+
<img src="./fig/logo.png" width="50%" alt="FlowLine" />
3+
4+
<!-- [![LICENSE](https://badgen.net/static/LICENSE/Apache)](LICENSE) -->
5+
6+
[中文](../readme.md) | English
7+
</div>
8+
29

3-
[中文](./readme.md) | English
410

511
FlowLine is an automated system for **GPU resource management** and **concurrent command stream scheduling**, supporting both **Command Line Interface (CLI)** and **Web Graphical User Interface (GUI)** interaction modes. It is suitable for multi-task experiments, deep learning training, or high-concurrency computing environments.
612

@@ -38,14 +44,14 @@ pip install -e <path_to_flowline_repository>
3844

3945
> Note: Ensure you have installed basic dependencies from `requirements.txt` (`pandas`, `psutil`, `openpyxl`, etc.).
4046
41-
#### 2. Create Task Control Sheet `todo.xlsx`
47+
#### 2. Create Task Control Sheet
4248

43-
The system uses an Excel file (`.xlsx` format) to define task parameters. **This is the only input method for all tasks.** Each row represents an independent task, and each column corresponds to a parameter that will be automatically mapped to `--key value` CLI format.
49+
The system uses a list file (`.xlsx``.csv` or `.json` format) to define task parameters. **This is the only input method for all tasks.** Each row represents an independent task, and each column corresponds to a parameter that will be automatically mapped to `--key value` CLI format.
4450

4551
<details>
4652
<summary>Example and Explanation</summary>
4753

48-
Example file: [`test/todo.xlsx`](./test/todo.xlsx)
54+
Example files: [`test/todo.xlsx`](./test/todo.xlsx), [`test/todo.csv`](./test/todo.csv),[`test/todo.json`](./test/todo.json), which can be constructed using the example program [`test/task_builder.py`](./test/task_builder.py).
4955

5056
| *name* | lr | batch_size | *run_num* | *need_run_num* | *cmd* |
5157
| --------- | ----- | ---------- | --------- | -------------- | ----------- |
@@ -59,7 +65,7 @@ Field descriptions:
5965
* `cmd`: Reserved field (can be empty or specify main command like `train_main`). Can be used with custom `func` logic.
6066
* Other fields can be freely defined and will be passed to the command constructor.
6167

62-
> Note: If reserved fields are missing, **the system will auto-complete them during Excel loading** to ensure valid structure.
68+
> Note: If reserved fields are missing, **the system will auto-complete them during loading** to ensure valid structure.
6369
6470
The flexible task sheet structure supports everything from parameter tuning to complex grid search automation.
6571

@@ -112,6 +118,61 @@ Always use `-u` to ensure **real-time log writing** to these files.
112118
</details>
113119
</details>
114120

121+
#### 4. Enter `run` to start the task flow
122+
123+
<details>
124+
<summary>FlowLine CLI Command Reference Table</summary>
125+
126+
| Command | Parameter | Description |
127+
| -------------- | ------------------------- | ---------------------------------------------------------------------------------------------------------- |
128+
| `run` | None | Toggles the task processing loop state (start/stop) |
129+
| `gpu <id>` | `<id>`: GPU ID | Toggles the availability of the specified GPU (available/unavailable) |
130+
| `killgpu <id>` | `<id>`: GPU ID | Terminates all processes running on the specified GPU |
131+
| `kill <id>` | `<id>`: Process ID | Terminates the process with the specified process ID |
132+
| `ls` | None | Lists all running processes, showing process ID, PID, task ID, GPU ID, status, and command |
133+
| `gpus` | None | Displays the status of all GPUs, including utilization, memory usage, temperature, power consumption, etc. |
134+
| `min <num>` | `<num>`: Memory size (MB) | Sets the minimum required memory for processes |
135+
| `max <num>` | `<num>`: Process count | Sets the maximum number of concurrent processes |
136+
| `task` | None | Lists the pending task queue, showing task ID, name, run count, etc. |
137+
| `exit` | None | Exits the program (equivalent to `Ctrl+D`) |
138+
| `help` or `?` | None | Displays help information |
139+
140+
<details>
141+
<summary>Command Usage Examples</summary>
142+
143+
```bash
144+
# Start the task processing loop
145+
> run
146+
147+
# Check GPU status
148+
> gpus
149+
150+
# View running processes
151+
> ls
152+
153+
# Set the maximum number of concurrent processes to 4
154+
> max 4
155+
156+
# Set the minimum memory requirement to 2048 MB
157+
> min 2048
158+
159+
# Disable GPU 1
160+
> gpu 1
161+
162+
# Terminate all processes on GPU 0
163+
> killgpu 0
164+
165+
# View pending tasks
166+
> task
167+
168+
# Exit the program
169+
> exit
170+
```
171+
172+
</details>
173+
</details>
174+
175+
115176
### 🌐 Using Web Interface (Visual Task Management)
116177

117178
> **No extra configuration needed - Works directly in SSH environments**
@@ -150,10 +211,33 @@ This project provides **automated detection and utilization of idle GPUs** for r
150211
- **DO NOT misuse to monopolize shared resources or disrupt others' research.**
151212

152213
### 🚨 Risk Statement
153-
> **For learning/research purposes only. Users assume all responsibility.**
154214

155215
Potential risks include but not limited to:
156216
- Resource conflicts from concurrent scheduling
157217
- Violation of lab/platform policies if abused
158218

159-
Developers **shall not be liable** for any direct/indirect losses including resource conflicts, account restrictions, or data loss resulting from script usage.
219+
Developers **shall not be liable** for any direct/indirect losses including resource conflicts, account restrictions, or data loss resulting from script usage.
220+
221+
222+
## 💐 Contributions
223+
224+
We welcome everyone to contribute code, fix bugs, or improve the documentation for this template!
225+
226+
- If you have any suggestions or questions, please submit an issue.
227+
- Pull requests are welcome.
228+
229+
> [!TIP]
230+
> If this project is helpful to you, please give it a **Star**!
231+
232+
**Thanks to all contributors!**
233+
234+
[![Contributors](https://contrib.rocks/image?repo=dramwig/FlowLine)](https://github.com/dramwig/FlowLine/graphs/contributors)
235+
236+
<a href="https://www.star-history.com/#dramwig/FlowLine&Date">
237+
<picture>
238+
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=dramwig/FlowLine&type=Date&theme=dark" />
239+
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=dramwig/FlowLine&type=Date" />
240+
241+
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=dramwig/FlowLine&type=Date" />
242+
</picture>
243+
</a>

flowline/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
from .core import run_cli
2-
from .api import get_app
1+
from .api import get_app, run_cli

flowline/api/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
from .routes import get_app
1+
from .routes import get_app
2+
from .interface import run_cli

flowline/core/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
from .program import ProgramManager
2-
from .interface import run_cli
2+
from ..api.interface import run_cli

flowline/core/task.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ class TaskManager:
4040
"""
4141
excel的保留关键字(属性): run_num, need_run_num, name, cmd
4242
"""
43-
def __init__(self, excel_path):
43+
def __init__(self, task_dir):
4444
self._lock = threading.Lock()
45-
self.excel_path = excel_path
46-
logger.info(f"read excel: {excel_path}")
47-
self.df = pd.read_excel(excel_path)
45+
self.task_dir = task_dir
46+
logger.info(f"read excel: {task_dir}")
47+
self._read_df()
4848
self.format_tidy_df()
49-
self.df.to_excel(excel_path, index=False)
49+
self._save_df()
5050

5151
self.tasks = []
5252
self.task_ids = queue.PriorityQueue()
@@ -72,6 +72,26 @@ def wrapper(self, *args, **kwargs):
7272
return func(self, *args, **kwargs)
7373
return wrapper
7474

75+
def _read_df(self):
76+
if self.task_dir.endswith(".xlsx"):
77+
self.df = pd.read_excel(self.task_dir)
78+
elif self.task_dir.endswith(".csv"):
79+
self.df = pd.read_csv(self.task_dir)
80+
elif self.task_dir.endswith(".json"):
81+
self.df = pd.read_json(self.task_dir)
82+
else:
83+
raise ValueError("Invalid file extension. Please use .xlsx, .csv, or .json.")
84+
85+
def _save_df(self):
86+
if self.task_dir.endswith(".xlsx"):
87+
self.df.to_excel(self.task_dir, index=False)
88+
elif self.task_dir.endswith(".csv"):
89+
self.df.to_csv(self.task_dir, index=False)
90+
elif self.task_dir.endswith(".json"):
91+
self.df.to_json(self.task_dir, orient="records", force_ascii=False, indent=4)
92+
else:
93+
raise ValueError("Invalid file extension. Please use .xlsx, .csv, or .json.")
94+
7595
# -------------------------------
7696

7797
def get_task_dict(self):
@@ -99,7 +119,7 @@ def put_task_ids(self, id):
99119
def update_task_ids(self, id):
100120
self.tasks[id].run_num += 1
101121
self.df.loc[id, 'run_num'] += 1
102-
self.df.to_excel(self.excel_path, index=False)
122+
self._save_df()
103123
logger.info(f"update task {id} run times: {self.df.loc[id, 'run_num']}")
104124

105125
@synchronized

main_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
def func(dict, gpu_id):
77
return "CUDA_VISIBLE_DEVICES="+str(gpu_id)+" python -u test/test.py "+ " ".join([f"--{k} {v}" for k, v in dict.items()])
88

9-
run_cli(func, "test/todo.xlsx")
9+
run_cli(func, "test/todo.csv")
1010

1111
# pkill -9 python

readme.md

Lines changed: 84 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
# FlowLine
1+
<!-- # FlowLine -->
22

3-
中文 | [English](./readme_en.md)
3+
<div align="center">
4+
<img src="./docs/fig/logo.png" width="50%" alt="FlowLine" />
5+
6+
<!-- [![LICENSE](https://badgen.net/static/LICENSE/Apache)](LICENSE) -->
7+
8+
中文 | [English](./docs/readme_en.md)
9+
</div>
410

511
FlowLine 是一个用于 **GPU资源管理****并发指令流调度** 的自动化系统,支持 **命令行界面(CLI)****Web 图形界面(GUI)** 两种交互方式,适用于多任务实验、深度学习训练或高并发计算环境。
612

@@ -40,14 +46,14 @@ pip install -e <flowline库路径>
4046

4147
> 注:请确保你已安装 `pandas``psutil``openpyxl``requirements.txt`内的基本依赖。
4248
43-
#### 2. 编写任务控制表 `todo.xlsx`
49+
#### 2. 编写任务控制表
4450

45-
系统通过一个 Excel 文件`.xlsx` 格式)来定义任务参数,**这是所有任务的唯一输入方式**。文件中的每一行代表一个独立任务,每一列对应一个参数项,将自动映射为命令行中的 `--key value` 格式。
51+
系统通过一个列表文件`.xlsx``.csv``.json` 格式)来定义任务参数,**这是所有任务的唯一输入方式**。文件中的每一行代表一个独立任务,每一列对应一个参数项,将自动映射为命令行中的 `--key value` 格式。
4652

4753
<details>
4854
<summary>示例和说明</summary>
4955

50-
示例文件:[`test/todo.xlsx`](./test/todo.xlsx)
56+
示例文件:[`test/todo.xlsx`](./test/todo.xlsx)[`test/todo.csv`](./test/todo.csv)[`test/todo.json`](./test/todo.json), 可以通过运行[`test/task_builder.py`](./test/task_builder.py)示例构造程序构造。
5157

5258
| *name* | lr | batch\_size |*run\_num*|*need\_run\_num*| *cmd* |
5359
| --------- | ----- | ----------- | -------- | -------------- | ----------- |
@@ -62,7 +68,7 @@ pip install -e <flowline库路径>
6268
* `cmd`:保留字段,当前版本可预留为空或指定主命令(如 `train_main`),可结合 `func` 自定义逻辑使用。
6369
* 其余字段可自由定义,系统会将这些字段作为参数传入自定义命令构造函数中。
6470

65-
> 注意:如果缺失上述保留字段,**系统会在加载 Excel 时自动补全**,确保表结构合法。
71+
> 注意:如果缺失上述保留字段,**系统会在加载文件时自动补全**,确保表结构合法。
6672
6773
任务表结构灵活,可覆盖从参数微调到复杂网格搜索的自动并发调度。
6874

@@ -97,8 +103,6 @@ if __name__ == "__main__":
97103
<details>
98104
<summary>关于输出和python -u</summary>
99105

100-
💡 **关于 `python -u`**
101-
102106
在命令中加入 `-u` 参数(即 `python -u ...`)表示以 **非缓冲模式(unbuffered mode)** 启动 Python:
103107

104108
* 标准输出(`stdout`)和标准错误(`stderr`)会**立即刷新**
@@ -118,6 +122,59 @@ log/
118122
</details>
119123
</details>
120124

125+
#### 4. 输入`run`开始运行任务流
126+
127+
<details>
128+
<summary>FlowLine CLI 命令参考表</summary>
129+
130+
| 语法 | 参数 | 功能说明 |
131+
|------|------|----------|
132+
| `run` || 切换任务处理循环的运行状态(启动/停止) |
133+
| `gpu <id>` | `<id>`: GPU编号 | 切换指定GPU的可用状态(可用/不可用) |
134+
| `killgpu <id>` | `<id>`: GPU编号 | 终止指定GPU上的所有进程 |
135+
| `kill <id>` | `<id>`: 进程ID | 终止指定进程ID的进程 |
136+
| `ls` || 列出所有正在运行的进程,显示进程ID、PID、任务ID、GPU ID、状态和命令 |
137+
| `gpus` || 显示所有GPU的状态信息,包括利用率、内存使用、温度、功耗等 |
138+
| `min <num>` | `<num>`: 内存大小(MB) | 设置进程所需的最小内存限制 |
139+
| `max <num>` | `<num>`: 进程数量 | 设置最大并发进程数 |
140+
| `task` || 列出待处理任务队列,显示任务ID、名称、运行次数等信息 |
141+
| `exit` || 退出程序(等效`Ctrl+D`|
142+
| `help``?` || 显示帮助信息 |
143+
144+
145+
<details>
146+
<summary>命令使用示例</summary>
147+
148+
```bash
149+
# 启动任务处理循环
150+
> run
151+
152+
# 查看GPU状态
153+
> gpus
154+
155+
# 查看运行中的进程
156+
> ls
157+
158+
# 设置最大进程数为4
159+
> max 4
160+
161+
# 设置最小内存要求为2048MB
162+
> min 2048
163+
164+
# 禁用GPU 1
165+
> gpu 1
166+
167+
# 终止GPU 0上的所有进程
168+
> killgpu 0
169+
170+
# 查看待处理任务
171+
> task
172+
173+
# 退出程序
174+
> exit
175+
```
176+
</details>
177+
</details>
121178

122179
### 🌐 使用 Web 界面(可视化任务管理)
123180

@@ -164,13 +221,30 @@ python -m http.server 8000
164221

165222
### 🚨 风险声明
166223

167-
> **本工具仅供学习与研究使用,使用者须自行承担一切后果。**
168-
169224
使用本脚本可能带来的风险包括但不限于:
170225

171226
- 与他人并发调度产生冲突,影响公平使用;
172227
- 若滥用,可能违反实验室/平台管理规定;
173228

174229
开发者对因使用本脚本而导致的**资源冲突、账号受限、数据丢失或任何直接间接损失**概不负责。
175230

231+
## 💐 贡献
232+
233+
欢迎大家为本模板贡献代码、修正bug或完善文档!
234+
- 如有建议或问题,请提交Issue。
235+
- 欢迎提交Pull Request。
236+
237+
> [!TIP]
238+
> 若对您有帮助,请给这个项目点上 **Star**!
239+
240+
**感谢所有贡献者!**
241+
242+
[![贡献者](https://contrib.rocks/image?repo=dramwig/FlowLine)](https://github.com/dramwig/FlowLine/graphs/contributors)
176243

244+
<a href="https://www.star-history.com/#dramwig/FlowLine&Date">
245+
<picture>
246+
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=dramwig/FlowLine&type=Date&theme=dark" />
247+
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=dramwig/FlowLine&type=Date" />
248+
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=dramwig/FlowLine&type=Date" />
249+
</picture>
250+
</a>

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
else:
1010
version = base_version
1111

12-
with open("readme_en.md", "r", encoding="utf-8") as fh:
12+
with open("docs/readme_en.md", "r", encoding="utf-8") as fh:
1313
long_description = fh.read()
1414

1515
setup(

0 commit comments

Comments
 (0)