Skip to content

Commit 1cc9dae

Browse files
author
Lars T Hansen
committed
Fix #244 - Remove CSV and old-format JSON formatting
1 parent 6081dea commit 1cc9dae

19 files changed

+47
-1440
lines changed

README.md

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,8 @@ are known to work for both. Also see comments in `gpuapi/Makefile`.
5959

6060
## Output format options
6161

62-
There are two output formats, [the old format](doc/OLD-FORMAT.md) and [the new
63-
format](doc/NEW-FORMAT.md), currently coexisting but the old format will be phased out.
64-
65-
The recommended (and default as of v0.16) output format is the "new" JSON format. There are command
66-
line switches to force the older formats, CSV or an older JSON format.
62+
As of v0.17 there is only one output format, known as [the new format](doc/NEW-FORMAT.md), a JSON
63+
encoding. Support for the older CSV format and an older JSON encoding have been removed.
6764

6865
## Examples
6966

@@ -75,34 +72,19 @@ cluster", below. For a full description of the output formats and fields, see t
7572
It's sensible to run `sonar ps` every 5 minutes on every compute node if you care mostly about
7673
long-running jobs, or at higher frequency if sbrief jobs are of interest to you.
7774

78-
Here is an example output (with the older CSV output format):
75+
Here is an example output:
7976
```console
8077
$ sonar ps --exclude-system-jobs --min-cpu-time=10
81-
82-
v=0.7.0,time=2023-08-10T11:09:41+02:00,host=somehost,cores=8,user=someone,job=0,cmd=fish,cpu%=2.1,cpukib=64400,gpus=none,gpu%=0,gpumem%=0,gpukib=0,cputime_sec=138
83-
v=0.7.0,time=2023-08-10T11:09:41+02:00,host=somehost,cores=8,user=someone,job=0,cmd=sonar,cpu%=761,cpukib=372,gpus=none,gpu%=0,gpumem%=0,gpukib=0,cputime_sec=137
84-
v=0.7.0,time=2023-08-10T11:09:41+02:00,host=somehost,cores=8,user=someone,job=0,cmd=brave,cpu%=14.6,cpukib=2907168,gpus=none,gpu%=0,gpumem%=0,gpukib=0,cputime_sec=3532
85-
v=0.7.0,time=2023-08-10T11:09:41+02:00,host=somehost,cores=8,user=someone,job=0,cmd=alacritty,cpu%=0.8,cpukib=126700,gpus=none,gpu%=0,gpumem%=0,gpukib=0,cputime_sec=51
86-
v=0.7.0,time=2023-08-10T11:09:41+02:00,host=somehost,cores=8,user=someone,job=0,cmd=pulseaudio,cpu%=0.7,cpukib=90640,gpus=none,gpu%=0,gpumem%=0,gpukib=0,cputime_sec=399
87-
v=0.7.0,time=2023-08-10T11:09:41+02:00,host=somehost,cores=8,user=someone,job=0,cmd=slack,cpu%=3.9,cpukib=716924,gpus=none,gpu%=0,gpumem%=0,gpukib=0,cputime_sec=266
78+
...
8879
```
8980

9081
### Collect system information with `sonar sysinfo`
9182

92-
The `sysinfo` subcommand collects information about the system and prints it in JSON form on stdout
93-
(this is the older JSON format):
83+
The `sysinfo` subcommand collects information about the system and prints it on stdout.
9484

9585
```console
9686
$ sonar sysinfo
97-
{
98-
"timestamp": "2024-02-26T00:00:02+01:00",
99-
"hostname": "ml1.hpc.uio.no",
100-
"description": "2x14 (hyperthreaded) Intel(R) Xeon(R) Gold 5120 CPU @ 2.20GHz, 125 GB, 3x NVIDIA GeForce RTX 2080 Ti @ 11GB",
101-
"cpu_cores": 56,
102-
"mem_gb": 125,
103-
"gpu_cards": 3,
104-
"gpumem_gb": 33
105-
}
87+
...
10688
```
10789

10890
Typical usage for `sysinfo` is to run the command after reboot and (for hot-swappable systems and

doc/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ should ask for that format.
1717

1818
## Changes in v0.17.0 (on `main`)
1919

20+
* Bug 244 - **REMOVED FUNCTIONALITY.** Remove all code related to producing CSV and the "old"
21+
JSON format, asking for those formats will now cause errors. The --json switch is still
22+
accepted but has no effect.
2023
* Bug 434 - **IMPORTANT FUNCTIONALITY.** Introduce the batch-size setting to allow very large
2124
slurm job lists to be split into multiple messages.
2225

doc/OLD-FORMAT.md

Lines changed: 0 additions & 398 deletions
This file was deleted.

src/daemon.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ pub fn daemon_mode(
294294
exclude_commands: ini.sample.exclude_commands.clone(),
295295
lockdir: ini.global.lockdir.clone(),
296296
token: api_token.clone(),
297-
fmt: ps::Format::NewJSON,
297+
fmt: ps::Format::JSON,
298298
cpu_util: true,
299299
min_cpu_percent: None, // Nonmonotonic, considered obsolete
300300
min_mem_percent: None, // Nonmonotonic, considered obsolete

src/main.rs

Lines changed: 7 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ mod output;
1818
mod output_test;
1919
mod ps;
2020
mod ps_newfmt;
21-
mod ps_oldfmt;
2221
#[cfg(test)]
2322
mod ps_test;
2423
mod slurmjobs;
@@ -77,9 +76,6 @@ enum Commands {
7776
/// the per-cpu usage since boot.
7877
load: bool,
7978

80-
/// Output old CSV, not new JSON
81-
csv: bool,
82-
8379
/// Cluster name
8480
cluster: Option<String>,
8581
},
@@ -90,12 +86,6 @@ enum Commands {
9086
},
9187
/// Extract node information
9288
Sysinfo {
93-
/// Output CSV, not old JSON
94-
csv: bool,
95-
96-
/// Output old JSON, not new JSON
97-
oldjson: bool,
98-
9989
/// Cluster name
10090
cluster: Option<String>,
10191

@@ -116,9 +106,6 @@ enum Commands {
116106
/// to is exclusive. Precludes -window.
117107
span: Option<String>,
118108

119-
/// Output old CSV, not new JSON
120-
csv: bool,
121-
122109
/// Include PENDING and RUNNING jobs
123110
deluge: bool,
124111

@@ -169,7 +156,6 @@ fn main() {
169156
exclude_commands,
170157
lockdir,
171158
load,
172-
csv,
173159
cluster,
174160
} => {
175161
let opts = ps::PsOptions {
@@ -190,11 +176,7 @@ fn main() {
190176
vec![]
191177
},
192178
lockdir: lockdir.clone(),
193-
fmt: if *csv {
194-
ps::Format::CSV
195-
} else {
196-
ps::Format::NewJSON
197-
},
179+
fmt: ps::Format::JSON,
198180
cpu_util: true,
199181
token,
200182
};
@@ -212,8 +194,6 @@ fn main() {
212194
);
213195
}
214196
Commands::Sysinfo {
215-
csv,
216-
oldjson,
217197
cluster,
218198
topo_svg_cmd,
219199
topo_text_cmd,
@@ -227,21 +207,14 @@ fn main() {
227207
writer,
228208
&system.freeze().expect("System initialization"),
229209
token,
230-
if *csv {
231-
sysinfo::Format::CSV
232-
} else if *oldjson {
233-
sysinfo::Format::OldJSON
234-
} else {
235-
sysinfo::Format::NewJSON
236-
},
210+
sysinfo::Format::JSON,
237211
topo_svg_cmd.clone(),
238212
topo_text_cmd.clone(),
239213
);
240214
}
241215
Commands::Slurmjobs {
242216
window,
243217
span,
244-
csv,
245218
deluge,
246219
batch_size,
247220
cluster,
@@ -259,11 +232,7 @@ fn main() {
259232
*batch_size,
260233
&system.freeze().expect("System initialization"),
261234
token,
262-
if *csv {
263-
slurmjobs::Format::CSV
264-
} else {
265-
slurmjobs::Format::NewJSON
266-
},
235+
slurmjobs::Format::JSON,
267236
);
268237
}
269238
Commands::Cluster { cluster } => {
@@ -288,10 +257,7 @@ fn main() {
288257
// For the sake of simplicity:
289258
// - allow repeated options to overwrite earlier values
290259
// - all error reporting is via a generic "usage" message, without specificity as to what was wrong
291-
// - both --json and --csv are accepted to all commands
292-
//
293-
// Note that --json means "new json" everywhere, so --json for `sonar sysinfo` changes the output
294-
// format from the default old JSON encoding.
260+
// - --json does nothing, while --csv and --oldfmt cause errors
295261

296262
fn command_line() -> Commands {
297263
let args = std::env::args().collect::<Vec<String>>();
@@ -322,8 +288,6 @@ fn command_line() -> Commands {
322288
let mut exclude_commands = None;
323289
let mut lockdir = None;
324290
let mut load = false;
325-
let mut json = false;
326-
let mut csv = false;
327291
let mut cluster = None;
328292
while next < args.len() {
329293
let arg = args[next].as_ref();
@@ -336,11 +300,7 @@ fn command_line() -> Commands {
336300
} else if let Some(new_next) = bool_arg(arg, &args, next, "--load") {
337301
(next, load) = (new_next, true);
338302
} else if let Some(new_next) = bool_arg(arg, &args, next, "--json") {
339-
(next, json) = (new_next, true);
340-
} else if let Some(new_next) = bool_arg(arg, &args, next, "--csv") {
341-
(next, csv) = (new_next, true);
342-
} else if let Some(new_next) = bool_arg(arg, &args, next, "--oldfmt") {
343-
(next, csv) = (new_next, true);
303+
next = new_next;
344304
} else if let Some(new_next) =
345305
bool_arg(arg, &args, next, "--exclude-system-jobs")
346306
{
@@ -377,10 +337,6 @@ fn command_line() -> Commands {
377337
usage(true);
378338
}
379339
}
380-
if json && csv {
381-
eprintln!("--csv and --json are incompatible");
382-
std::process::exit(USAGE_ERROR);
383-
}
384340
Commands::PS {
385341
rollup,
386342
min_cpu_percent,
@@ -391,26 +347,18 @@ fn command_line() -> Commands {
391347
exclude_commands,
392348
lockdir,
393349
load,
394-
csv,
395350
cluster,
396351
}
397352
}
398353
"sysinfo" => {
399-
let mut json = false;
400-
let mut oldjson = false;
401-
let mut csv = false;
402354
let mut cluster = None;
403355
let mut topo_svg_cmd = None;
404356
let mut topo_text_cmd = None;
405357
while next < args.len() {
406358
let arg = args[next].as_ref();
407359
next += 1;
408360
if let Some(new_next) = bool_arg(arg, &args, next, "--json") {
409-
(next, json) = (new_next, true);
410-
} else if let Some(new_next) = bool_arg(arg, &args, next, "--oldfmt") {
411-
(next, oldjson) = (new_next, true);
412-
} else if let Some(new_next) = bool_arg(arg, &args, next, "--csv") {
413-
(next, csv) = (new_next, true);
361+
next = new_next;
414362
} else if let Some((new_next, value)) =
415363
string_arg(arg, &args, next, "--cluster")
416364
{
@@ -427,17 +375,7 @@ fn command_line() -> Commands {
427375
usage(true);
428376
}
429377
}
430-
if (json || oldjson) && csv {
431-
eprintln!("--csv is incompatible with --json and --oldfmt");
432-
std::process::exit(USAGE_ERROR);
433-
}
434-
if json && oldjson {
435-
eprintln!("--json and --oldfmt are incompatible");
436-
std::process::exit(USAGE_ERROR);
437-
}
438378
Commands::Sysinfo {
439-
csv,
440-
oldjson,
441379
cluster,
442380
topo_svg_cmd,
443381
topo_text_cmd,
@@ -446,8 +384,6 @@ fn command_line() -> Commands {
446384
"slurm" => {
447385
let mut window = None;
448386
let mut span = None;
449-
let mut json = false;
450-
let mut csv = false;
451387
let mut deluge = false;
452388
let mut batch_size = None;
453389
let mut cluster = None;
@@ -461,11 +397,7 @@ fn command_line() -> Commands {
461397
} else if let Some((new_next, value)) = string_arg(arg, &args, next, "--span") {
462398
(next, span) = (new_next, Some(value));
463399
} else if let Some(new_next) = bool_arg(arg, &args, next, "--json") {
464-
(next, json) = (new_next, true);
465-
} else if let Some(new_next) = bool_arg(arg, &args, next, "--oldfmt") {
466-
(next, csv) = (new_next, true);
467-
} else if let Some(new_next) = bool_arg(arg, &args, next, "--csv") {
468-
(next, csv) = (new_next, true);
400+
next = new_next;
469401
} else if let Some(new_next) = bool_arg(arg, &args, next, "--deluge") {
470402
(next, deluge) = (new_next, true);
471403
} else if let Some((new_next, value)) =
@@ -483,14 +415,9 @@ fn command_line() -> Commands {
483415
if window.is_some() && span.is_some() {
484416
usage(true);
485417
}
486-
if json && csv {
487-
eprintln!("--csv and --json are incompatible");
488-
std::process::exit(USAGE_ERROR);
489-
}
490418
Commands::Slurmjobs {
491419
window,
492420
span,
493-
csv,
494421
cluster,
495422
deluge,
496423
batch_size,
@@ -504,9 +431,6 @@ fn command_line() -> Commands {
504431
if let Some(new_next) = bool_arg(arg, &args, next, "--json") {
505432
// Ignore, there is only one format
506433
next = new_next;
507-
} else if let Some(new_next) = bool_arg(arg, &args, next, "--oldfmt") {
508-
// Ignore, there is only one format
509-
next = new_next;
510434
} else if let Some((new_next, value)) =
511435
string_arg(arg, &args, next, "--cluster")
512436
{
@@ -623,18 +547,10 @@ Options for `ps`:
623547
exists on startup [default: none]
624548
--load
625549
Print per-cpu and per-gpu load data
626-
--csv
627-
Format output as old CSV, not JSON
628-
--oldfmt
629-
Synonym for --csv
630550
--cluster name
631551
Optional cluster name with which to tag output
632552
633553
Options for `sysinfo`:
634-
--csv
635-
Format output as CSV, not JSON
636-
--oldfmt
637-
Format output as the old JSON, not the new JSON
638554
--cluster name
639555
Optional cluster name with which to tag output
640556
--topo-svg-cmd
@@ -655,10 +571,6 @@ Options for `slurm`:
655571
Include PENDING and RUNNING jobs in the output, not just completed jobs.
656572
--batch-size
657573
Split into multiple JSON messages after this many job records.
658-
--csv
659-
Format output as CSV, not new JSON
660-
--oldfmt
661-
Synonym for --csv
662574
--cluster name
663575
Optional cluster name with which to tag output
664576

0 commit comments

Comments
 (0)