more preset formats, improve help texts

This commit is contained in:
2026-06-30 15:25:52 +02:00
parent 5c4b516e33
commit f028aea536
+58 -14
View File
@@ -118,6 +118,45 @@ PRESET_COLUMNS = {
"Mem_Eff",
"Time_Eff",
"jobname",],
"time": [
"username",
"JobID",
"state",
"Count",
"NTasks",
"CPUs",
"Nodes",
"ReqWalltime",
"Walltime",
"Walltime_max",
"Time_Eff",
"jobname",],
"cpu": [
"username",
"JobID",
"state",
"Count",
"NTasks",
"CPUs",
"Nodes",
"CPU_Eff",
"waste_CPU",
"jobname",],
"mem": [
"username",
"JobID",
"state",
"Count",
"NTasks",
"CPUs",
"Nodes",
"AllocMem",
"UsedMem",
"MaxRSS_max",
"MemPerCPU",
"Mem_Eff",
"waste_Mem",
"jobname",],
}
# One-character aliases for sorting and output format specifications.
@@ -801,8 +840,8 @@ def aggregate_records(records: list[JobRecord], args: argparse.Namespace) -> lis
"""Aggregate records according to given grouping instructions."""
global default_mempercpu_gb
if args.deflt_mpcpu:
default_mempercpu_gb = float(args.deflt_mpcpu)
if args.dflt_mpcpu:
default_mempercpu_gb = float(args.dflt_mpcpu)
if args.aggr_regexp:
compiled = [(pat, re.compile(pat)) for pat in args.aggr_regexp]
@@ -1112,32 +1151,32 @@ def parse_args(argv: list[str]) -> argparse.Namespace:
default=None,
help="sacct state filter, e.g. COMPLETED,FAILED,TIMEOUT")
p.add_argument("-O", "--output-raw", help="write raw sacct output cache to this file")
p.add_argument("-F", "--from-raw", help="read raw sacct output cache from this file instead of running sacct")
p.add_argument("-B", "--write-binary-cache", help="write a binary cache file in msgpack format")
p.add_argument("-L", "--load-binary-cache", help="load a binary cache file in msgpack format")
p.add_argument("-i", "--info", help="show information for the given binary cache file")
p.add_argument("-O", "--output-raw", help="write raw sacct output cache to this file (text format, large).")
p.add_argument("-F", "--from-raw", help="read raw sacct output cache from this file.")
p.add_argument("-B", "--write-binary-cache", help="write a binary cache file in gzipped msgpack format")
p.add_argument("-L", "--load-binary-cache", help="load a binary cache file in gzipped msgpack format")
p.add_argument("-i", "--info", help="show metadata information for the given binary cache file")
p.add_argument("-U", "--aggr-user", action="store_true", help="aggregate jobs by user, CPUs, nodes, ReqMem, and timelimit")
p.add_argument(
"-R",
"--aggr-regexp",
action="append",
help="aggregate jobs matching regexp by regexp, CPUs, nodes, ReqMem, and timelimit; may be repeated",
help="aggregate jobs based on a regexp applied to the jobnames. Option may be repeated multiple times.",
)
p.add_argument("--deflt-mpcpu", help=f"Default memory to CPU ratio of cluster ({default_mempercpu_gb} GB/cpu)")
p.add_argument("--dflt-mpcpu", help=f"Default memory/CPU ratio of cluster [{default_mempercpu_gb} GB/cpu]. Used in memory waste calculation.")
p.add_argument("--sdev", action="store_true", help="after each efficiency average, add sdev, max, and min columns")
p.add_argument("--json", action="store_true", help="emit JSON instead of an ASCII table")
p.add_argument("-s", "--sort", help="comma-separated numeric sort columns or aliases; prefix with - for descending")
p.add_argument("-s", "--sort", help="comma-separated numeric sort columns or short aliases; prefix with - for descending")
fmthelp = ", ".join([f"{k}:{ALIASES[k]}" for k in ALIASES])
p.add_argument(
"-o",
"--format",
help= f"String of comma separated column names or short names defining the output format:\n{fmthelp}",
help= f"String of comma separated column names or short aliases defining the output format [{fmthelp}]",
)
p.add_argument("--expr", help="arithmetic expression using column names",
p.add_argument("--expr", help="filter using an arithmetic expression using column names as variables (case insensitive)",
default=None)
p.add_argument("-p", "--preset", help=f"use one of several preset output column formats ({','.join(PRESET_COLUMNS.keys())})",
p.add_argument("-p", "--preset", help=f"use one of several preset output column formats [{','.join(PRESET_COLUMNS.keys())}]",
default=None)
args = p.parse_args(argv)
@@ -1160,7 +1199,12 @@ def main(argv: list[str] | None = None) -> int:
output_columns = PRESET_COLUMNS["default"]
if args.preset:
output_columns = PRESET_COLUMNS[args.preset]
try:
output_columns = PRESET_COLUMNS[args.preset]
except KeyError:
sys.stderr.write(f"ERROR: no such preset format ({args.preset})\n")
sys.exit(1)
if args.format:
output_columns = columns_from_fmtstr(args.format)