1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
use clap::Parser;
use clap_complete::Shell;
use std::path::PathBuf;
#[derive(Debug, Parser)]
#[command(
name = "gctl",
author,
version = gflow::build_info::version(),
about = "Control gflow scheduler at runtime"
)]
#[command(styles = gflow::utils::STYLES)]
pub struct GCtl {
#[command(subcommand)]
pub command: Commands,
/// Path to the config file
#[arg(long, global = true, hide = true)]
pub config: Option<PathBuf>,
}
#[derive(Debug, Parser)]
pub enum Commands {
/// Set which GPUs the scheduler can use
SetGpus {
/// GPU indices (e.g., "0,2" or "0-2"), or "all" for all GPUs
gpu_spec: String,
},
/// Show current GPU configuration
ShowGpus,
/// Manage runtime GPU process ignore overrides
GpuProcess {
#[command(subcommand)]
command: GpuProcessCommands,
},
/// Set concurrency limit for a job group
SetLimit {
/// Job ID (any job in the group) or Group ID (UUID)
job_or_group_id: String,
/// Maximum number of concurrent jobs in the group
limit: usize,
},
/// Manage GPU reservations
Reserve {
#[command(subcommand)]
command: ReserveCommands,
},
/// Manage per-user / per-project resource quotas
Quota {
#[command(subcommand)]
command: QuotaCommands,
},
/// Generate shell completion scripts
Completion {
/// The shell to generate completions for
#[arg(value_enum)]
shell: Shell,
},
}
#[derive(Debug, Parser)]
pub enum GpuProcessCommands {
/// Ignore a running GPU process for scheduling decisions
Ignore {
/// GPU index where the process is attached
#[arg(long)]
gpu: u32,
/// Process ID to ignore
#[arg(long)]
pid: u32,
},
/// Remove a previously-added ignore override
Unignore {
/// GPU index where the process is attached
#[arg(long)]
gpu: u32,
/// Process ID to stop ignoring
#[arg(long)]
pid: u32,
},
/// List active runtime ignore overrides
List,
}
#[derive(Debug, Parser)]
pub enum QuotaCommands {
/// Show quota subjects with effective limits and current usage
List,
/// Set (merge) runtime quota limits; persisted across daemon restarts.
/// Select exactly one subject: --user, --project, --default-user or
/// --default-project. Provide at least one --max-* flag.
Set {
/// Username
#[arg(long, group = "subject")]
user: Option<String>,
/// Project code
#[arg(long, group = "subject")]
project: Option<String>,
/// Apply to the fallback limits for all users
#[arg(long, group = "subject")]
default_user: bool,
/// Apply to the fallback limits for all projects
#[arg(long, group = "subject")]
default_project: bool,
/// Max concurrently running jobs
#[arg(long)]
max_running_jobs: Option<usize>,
/// Max concurrently allocated GPUs
#[arg(long)]
max_running_gpus: Option<u32>,
/// Max pending jobs (enforced at submission)
#[arg(long)]
max_queued_jobs: Option<usize>,
},
/// Remove a runtime quota override (falls back to gflow.toml baseline)
Remove {
/// Username
#[arg(long, group = "subject")]
user: Option<String>,
/// Project code
#[arg(long, group = "subject")]
project: Option<String>,
/// Reset the fallback limits for all users
#[arg(long, group = "subject")]
default_user: bool,
/// Reset the fallback limits for all projects
#[arg(long, group = "subject")]
default_project: bool,
},
}
#[derive(Debug, Parser)]
pub enum ReserveCommands {
/// Create a GPU reservation
Create {
/// Username for the reservation
#[arg(long)]
user: String,
/// Number of GPUs to reserve (mutually exclusive with --gpu-spec)
#[arg(long, conflicts_with = "gpu_spec")]
gpus: Option<u32>,
/// GPU specification (e.g., "0,2" or "0-3" or "0-1,3,5-6")
/// Mutually exclusive with --gpus
#[arg(long, conflicts_with = "gpus")]
gpu_spec: Option<String>,
/// Start time (ISO8601 format or "YYYY-MM-DD HH:MM")
#[arg(long)]
start: String,
/// Duration (e.g., "1h", "30m", "2h30m")
#[arg(long)]
duration: String,
/// Timezone for interpreting start time (e.g., "Asia/Shanghai", "UTC")
/// Overrides config file timezone setting
#[arg(long)]
timezone: Option<String>,
},
/// List GPU reservations
List {
/// Filter by username
#[arg(long)]
user: Option<String>,
/// Filter by status (pending, active, completed, cancelled)
#[arg(long)]
status: Option<String>,
/// Show only active reservations
#[arg(long)]
active: bool,
/// Display as timeline visualization
#[arg(long)]
timeline: bool,
/// Timeline time range (relative to now). Formats:
/// - "48h" (now..now+48h)
/// - "-24h" (now-24h..now)
/// - "-24h:+24h" (now-24h..now+24h)
#[arg(
long,
value_name = "RANGE",
requires = "timeline",
conflicts_with_all = ["from", "to"]
)]
range: Option<String>,
/// Timeline range start time (ISO8601 or "YYYY-MM-DD HH:MM").
#[arg(
long,
value_name = "TIME",
requires_all = ["timeline", "to"],
conflicts_with = "range"
)]
from: Option<String>,
/// Timeline range end time (ISO8601 or "YYYY-MM-DD HH:MM").
#[arg(
long,
value_name = "TIME",
requires_all = ["timeline", "from"],
conflicts_with = "range"
)]
to: Option<String>,
},
/// Get details of a specific reservation
Get {
/// Reservation ID
id: u32,
},
/// Cancel a GPU reservation
Cancel {
/// Reservation ID
id: u32,
},
}