slurm-cli 1.0.5__tar.gz → 1.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {slurm_cli-1.0.5 → slurm_cli-1.1.2}/PKG-INFO +1 -1
- {slurm_cli-1.0.5 → slurm_cli-1.1.2}/pyproject.toml +1 -1
- {slurm_cli-1.0.5 → slurm_cli-1.1.2}/src/slurm_cli/cli.py +242 -2
- {slurm_cli-1.0.5 → slurm_cli-1.1.2}/src/slurm_cli/utils/accounts.py +5 -1
- {slurm_cli-1.0.5 → slurm_cli-1.1.2}/src/slurm_cli/utils/associations.py +5 -1
- {slurm_cli-1.0.5 → slurm_cli-1.1.2}/src/slurm_cli/utils/autocomplete_helpers.py +10 -3
- {slurm_cli-1.0.5 → slurm_cli-1.1.2}/src/slurm_cli/utils/jobs.py +12 -6
- {slurm_cli-1.0.5 → slurm_cli-1.1.2}/src/slurm_cli/utils/nodes.py +7 -2
- slurm_cli-1.1.2/src/slurm_cli/utils/partition_stats.py +461 -0
- {slurm_cli-1.0.5 → slurm_cli-1.1.2}/src/slurm_cli/utils/partitions.py +7 -2
- {slurm_cli-1.0.5 → slurm_cli-1.1.2}/src/slurm_cli/utils/prefix_utils.py +4 -0
- {slurm_cli-1.0.5 → slurm_cli-1.1.2}/src/slurm_cli/utils/profiles.py +190 -16
- {slurm_cli-1.0.5 → slurm_cli-1.1.2}/src/slurm_cli/utils/qos.py +7 -2
- {slurm_cli-1.0.5 → slurm_cli-1.1.2}/src/slurm_cli/utils/reservations.py +11 -2
- slurm_cli-1.1.2/src/slurm_cli/utils/titles.py +170 -0
- {slurm_cli-1.0.5 → slurm_cli-1.1.2}/LICENSE +0 -0
- {slurm_cli-1.0.5 → slurm_cli-1.1.2}/README.md +0 -0
- {slurm_cli-1.0.5 → slurm_cli-1.1.2}/src/slurm_cli/__init__.py +0 -0
- {slurm_cli-1.0.5 → slurm_cli-1.1.2}/src/slurm_cli/py.typed +0 -0
- {slurm_cli-1.0.5 → slurm_cli-1.1.2}/src/slurm_cli/utils/__init__.py +0 -0
- {slurm_cli-1.0.5 → slurm_cli-1.1.2}/src/slurm_cli/utils/base_resource.py +0 -0
- {slurm_cli-1.0.5 → slurm_cli-1.1.2}/src/slurm_cli/utils/config.py +0 -0
- {slurm_cli-1.0.5 → slurm_cli-1.1.2}/src/slurm_cli/utils/coordinators.py +0 -0
- {slurm_cli-1.0.5 → slurm_cli-1.1.2}/src/slurm_cli/utils/events.py +0 -0
- {slurm_cli-1.0.5 → slurm_cli-1.1.2}/src/slurm_cli/utils/job_filter.py +0 -0
- {slurm_cli-1.0.5 → slurm_cli-1.1.2}/src/slurm_cli/utils/node_filter.py +0 -0
- {slurm_cli-1.0.5 → slurm_cli-1.1.2}/src/slurm_cli/utils/resources.py +0 -0
- {slurm_cli-1.0.5 → slurm_cli-1.1.2}/src/slurm_cli/utils/slurm_config.py +0 -0
- {slurm_cli-1.0.5 → slurm_cli-1.1.2}/src/slurm_cli/utils/users.py +0 -0
- {slurm_cli-1.0.5 → slurm_cli-1.1.2}/src/slurm_cli/utils/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "slurm-cli"
|
|
3
|
-
version = "1.
|
|
3
|
+
version = "1.1.2"
|
|
4
4
|
description = "A CLI tool for Slurm cluster management with autocomplete functionality"
|
|
5
5
|
authors = ["Sergey Zhumatiy <szhumatiy@gmail.com>"]
|
|
6
6
|
maintainers = ["Sergey Zhumatiy <szhumatiy@gmail.com>"]
|
|
@@ -43,6 +43,22 @@ from .utils.job_filter import is_job_filter, resolve_job_filters, resolve_job_id
|
|
|
43
43
|
from .utils.jobs import Job
|
|
44
44
|
from .utils.node_filter import is_node_filter, resolve_node_filters, resolve_nodes_value
|
|
45
45
|
from .utils.nodes import Node
|
|
46
|
+
from .utils.partition_stats import (
|
|
47
|
+
DEFAULT_COLUMNS as DEFAULT_PSTATS_COLUMNS,
|
|
48
|
+
FIELDS,
|
|
49
|
+
FIELDS as PSTATS_FIELDS,
|
|
50
|
+
HEADERS as PSTATS_HEADERS,
|
|
51
|
+
USER_HEADERS,
|
|
52
|
+
compute_stats,
|
|
53
|
+
csv_lines,
|
|
54
|
+
flat_rows,
|
|
55
|
+
print_stats,
|
|
56
|
+
print_user_stats,
|
|
57
|
+
user_columns,
|
|
58
|
+
user_rows,
|
|
59
|
+
to_plain,
|
|
60
|
+
user_stats,
|
|
61
|
+
)
|
|
46
62
|
from .utils.partitions import Partition
|
|
47
63
|
from .utils.prefix_utils import ( # get_all_resource_names,
|
|
48
64
|
COMMANDS,
|
|
@@ -55,7 +71,16 @@ from .utils.prefix_utils import ( # get_all_resource_names,
|
|
|
55
71
|
get_resource_help,
|
|
56
72
|
get_resources_epilog,
|
|
57
73
|
)
|
|
58
|
-
from .utils.profiles import
|
|
74
|
+
from .utils.profiles import (
|
|
75
|
+
extract_fields_from_template,
|
|
76
|
+
get_header_config,
|
|
77
|
+
get_profile_config,
|
|
78
|
+
is_profile_help,
|
|
79
|
+
set_header_override,
|
|
80
|
+
show_all_profile_fields,
|
|
81
|
+
show_profile_help,
|
|
82
|
+
sort_data,
|
|
83
|
+
)
|
|
59
84
|
from .utils.qos import Qos
|
|
60
85
|
from .utils.reservations import Reservation
|
|
61
86
|
from .utils.resources import Resource
|
|
@@ -218,6 +243,13 @@ def resolve_command_alias(command: str) -> str:
|
|
|
218
243
|
return canonical
|
|
219
244
|
|
|
220
245
|
|
|
246
|
+
def apply_header_option(
|
|
247
|
+
header: Optional[str], header_flag: bool = False, no_header: bool = False
|
|
248
|
+
) -> None:
|
|
249
|
+
"""Set the command-line header mode (None leaves profiles/env in charge)."""
|
|
250
|
+
set_header_override("none" if no_header else header or ("full" if header_flag else None))
|
|
251
|
+
|
|
252
|
+
|
|
221
253
|
def common_options(func):
|
|
222
254
|
"""Decorator to add common options to commands.
|
|
223
255
|
|
|
@@ -267,6 +299,18 @@ def common_options(func):
|
|
|
267
299
|
is_flag=True,
|
|
268
300
|
help="Use pretty output format (overrides global)",
|
|
269
301
|
)(func)
|
|
302
|
+
func = click.option(
|
|
303
|
+
"--no-header", "no_header", is_flag=True, help="Same as --header=none"
|
|
304
|
+
)(func)
|
|
305
|
+
func = click.option(
|
|
306
|
+
"-H", "header_flag", is_flag=True, help="Same as --header=full"
|
|
307
|
+
)(func)
|
|
308
|
+
func = click.option(
|
|
309
|
+
"--header",
|
|
310
|
+
type=click.Choice(["none", "full", "short", "trunc"]),
|
|
311
|
+
default=None,
|
|
312
|
+
help="Header line for custom formats (full, short, trunc, none)",
|
|
313
|
+
)(func)
|
|
270
314
|
func = click.option(
|
|
271
315
|
"--style",
|
|
272
316
|
type=click.Choice(["pretty", "json", "csv"]),
|
|
@@ -830,6 +874,25 @@ def show_command_help_with_resources(
|
|
|
830
874
|
help="Inline profile string (overrides --profile). "
|
|
831
875
|
"Format: resource.columns=col1,col2;resource.styles.field=style",
|
|
832
876
|
)
|
|
877
|
+
@click.option(
|
|
878
|
+
"--header",
|
|
879
|
+
type=click.Choice(["none", "full", "short", "trunc"]),
|
|
880
|
+
default=None,
|
|
881
|
+
help="Header line for custom formats: full titles, short titles, "
|
|
882
|
+
"titles truncated to the column width, or none (SLURM_CLI_HEADER)",
|
|
883
|
+
)
|
|
884
|
+
@click.option(
|
|
885
|
+
"-H",
|
|
886
|
+
"header_flag",
|
|
887
|
+
is_flag=True,
|
|
888
|
+
help="Same as --header=full",
|
|
889
|
+
)
|
|
890
|
+
@click.option(
|
|
891
|
+
"--no-header",
|
|
892
|
+
"no_header",
|
|
893
|
+
is_flag=True,
|
|
894
|
+
help="Same as --header=none",
|
|
895
|
+
)
|
|
833
896
|
@click.option(
|
|
834
897
|
"--list-fields",
|
|
835
898
|
default=None,
|
|
@@ -857,8 +920,12 @@ def main(
|
|
|
857
920
|
cache_timeout: int,
|
|
858
921
|
profile: str,
|
|
859
922
|
profile_str: str,
|
|
923
|
+
header: Optional[str] = None,
|
|
924
|
+
header_flag: bool = False,
|
|
925
|
+
no_header: bool = False,
|
|
860
926
|
) -> None:
|
|
861
927
|
"""Slurm CLI - A tool for Slurm cluster management."""
|
|
928
|
+
apply_header_option(header, header_flag, no_header) # also resets it
|
|
862
929
|
# Handle convenience flags
|
|
863
930
|
if pretty:
|
|
864
931
|
style = "pretty"
|
|
@@ -961,6 +1028,7 @@ def register_commands() -> None:
|
|
|
961
1028
|
main.add_command(top, name="top")
|
|
962
1029
|
main.add_command(requeue, name="requeue")
|
|
963
1030
|
main.add_command(suspend, name="suspend")
|
|
1031
|
+
main.add_command(pstats, name="pstats")
|
|
964
1032
|
|
|
965
1033
|
# Modify help text to show aliases inline
|
|
966
1034
|
show.help = "Show information about Slurm resources (aliases: get, list, ls)"
|
|
@@ -990,6 +1058,7 @@ def register_commands() -> None:
|
|
|
990
1058
|
dwstat.help = "Show DataWarp/burst buffer status"
|
|
991
1059
|
topology.help = "Show network topology information"
|
|
992
1060
|
suspend.help = "Suspend running jobs (aliases: sus)"
|
|
1061
|
+
pstats.help = "Show partition statistics: nodes, jobs, users, resources"
|
|
993
1062
|
help.help = "Show help information"
|
|
994
1063
|
|
|
995
1064
|
|
|
@@ -1082,6 +1151,10 @@ def show(
|
|
|
1082
1151
|
force_update = get_force_update(ctx)
|
|
1083
1152
|
profile = get_profile(ctx, profile)
|
|
1084
1153
|
profile_str = get_profile_str(ctx, profile_str)
|
|
1154
|
+
if kwargs.get("header") or kwargs.get("header_flag") or kwargs.get("no_header"):
|
|
1155
|
+
apply_header_option(
|
|
1156
|
+
kwargs.get("header"), kwargs.get("header_flag"), kwargs.get("no_header")
|
|
1157
|
+
)
|
|
1085
1158
|
if isinstance(field, str):
|
|
1086
1159
|
field = (field,)
|
|
1087
1160
|
canonical_resource, field_result, data = ensure_resource_name(
|
|
@@ -1338,7 +1411,22 @@ def show(
|
|
|
1338
1411
|
# Jobs support job filters
|
|
1339
1412
|
if field:
|
|
1340
1413
|
has_filters = any(is_job_filter(f) for f in field)
|
|
1341
|
-
|
|
1414
|
+
simple = {"user", "account", "partition", "state", "name"}
|
|
1415
|
+
if has_filters and all(
|
|
1416
|
+
f.partition("=")[0].lower() in simple and "=" in f for f in field
|
|
1417
|
+
):
|
|
1418
|
+
# One table from scontrol data; unlike squeue it keeps
|
|
1419
|
+
# completed jobs that are still known to slurmctld
|
|
1420
|
+
Job.show(
|
|
1421
|
+
field=" ".join(field),
|
|
1422
|
+
style=style,
|
|
1423
|
+
force_cache_update=force_update,
|
|
1424
|
+
delimiter=delimiter,
|
|
1425
|
+
zebra=zebra,
|
|
1426
|
+
profile=profile,
|
|
1427
|
+
profile_str=profile_str,
|
|
1428
|
+
)
|
|
1429
|
+
elif has_filters:
|
|
1342
1430
|
resolved_jobs, _ = resolve_job_ids(list(field), verbose)
|
|
1343
1431
|
if not resolved_jobs:
|
|
1344
1432
|
console.print("[yellow]No jobs matched filters[/yellow]")
|
|
@@ -2215,6 +2303,7 @@ def autocomplete(word: str, max_cost: int, size: int) -> None:
|
|
|
2215
2303
|
|
|
2216
2304
|
# Generate resource case patterns from RESOURCES config
|
|
2217
2305
|
resource_case_patterns = generate_bash_resource_case()
|
|
2306
|
+
pstats_fields = " ".join(f for f in PSTATS_FIELDS if not f.startswith("<"))
|
|
2218
2307
|
# all_resources_str = get_all_resource_names()
|
|
2219
2308
|
|
|
2220
2309
|
# Print the script with proper escaping for bash variables
|
|
@@ -2819,6 +2908,46 @@ _slurm_cli_initialize_autocomplete() {{
|
|
|
2819
2908
|
COMPREPLY=($(compgen -W "--dry-run -v --verbose -h --help" -- "$cur"))
|
|
2820
2909
|
return
|
|
2821
2910
|
;;
|
|
2911
|
+
pstats)
|
|
2912
|
+
# "--opt=<TAB>" makes "=" its own word: the option is the previous word
|
|
2913
|
+
local opt="$prev" val="$cur"
|
|
2914
|
+
if [[ "$cur" == "=" ]]; then
|
|
2915
|
+
val=""
|
|
2916
|
+
elif [[ "$prev" == "=" ]]; then
|
|
2917
|
+
opt="${{COMP_WORDS[COMP_CWORD-2]}}"
|
|
2918
|
+
fi
|
|
2919
|
+
case "$opt" in
|
|
2920
|
+
--header)
|
|
2921
|
+
COMPREPLY=($(compgen -W "none full short trunc" -- "$val"))
|
|
2922
|
+
return ;;
|
|
2923
|
+
--style)
|
|
2924
|
+
COMPREPLY=($(compgen -W "{' '.join(STYLE_OPTIONS)}" -- "$val"))
|
|
2925
|
+
return ;;
|
|
2926
|
+
--profile|-P|--delimiter|-d)
|
|
2927
|
+
return ;;
|
|
2928
|
+
--profile-str|--format|-o)
|
|
2929
|
+
# comma-separated field names (sort marks and templates are not completed)
|
|
2930
|
+
local prefix="" partial="$val" selected=""
|
|
2931
|
+
if [[ "$val" == *,* ]]; then
|
|
2932
|
+
prefix="${{val%,*}},"
|
|
2933
|
+
partial="${{val##*,}}"
|
|
2934
|
+
selected=",${{val%,*}},"
|
|
2935
|
+
fi
|
|
2936
|
+
local remaining=""
|
|
2937
|
+
for f in {pstats_fields}; do
|
|
2938
|
+
[[ "$selected" != *",$f,"* ]] && remaining="$remaining $f"
|
|
2939
|
+
done
|
|
2940
|
+
COMPREPLY=($(compgen -W "$remaining" -- "$partial"))
|
|
2941
|
+
[[ -n "$prefix" && ${{#COMPREPLY[@]}} -gt 0 ]] && COMPREPLY=("${{COMPREPLY[@]/#/$prefix}}")
|
|
2942
|
+
return ;;
|
|
2943
|
+
esac
|
|
2944
|
+
if [[ "$cur" == -* ]]; then
|
|
2945
|
+
COMPREPLY=($(compgen -W "-u --users -a --accounts -s --states -U --by-user --header -H --no-header -o --format --profile-str -P --profile -j --json --csv -p --pretty -z --zebra -d --delimiter --style -h --help" -- "$cur"))
|
|
2946
|
+
else
|
|
2947
|
+
COMPREPLY=($(compgen -W "$(_slurm_cache_partitions)" -- "$cur"))
|
|
2948
|
+
fi
|
|
2949
|
+
return
|
|
2950
|
+
;;
|
|
2822
2951
|
autocomplete|help|resources)
|
|
2823
2952
|
# These commands take -h/--help option
|
|
2824
2953
|
COMPREPLY=($(compgen -W "-h --help" -- "$cur"))
|
|
@@ -2885,6 +3014,10 @@ _slurm_cli_initialize_autocomplete() {{
|
|
|
2885
3014
|
# Handle --profile=value format (when = is a separate word)
|
|
2886
3015
|
if [[ ${{COMP_CWORD}} -ge 2 ]]; then
|
|
2887
3016
|
local opt="${{COMP_WORDS[COMP_CWORD-2]}}"
|
|
3017
|
+
if [[ "$opt" == "--header" ]]; then
|
|
3018
|
+
COMPREPLY=($(compgen -W "none full short trunc" -- "$cur"))
|
|
3019
|
+
return
|
|
3020
|
+
fi
|
|
2888
3021
|
if [[ "$opt" == "--profile" || "$opt" == "-P" ]]; then
|
|
2889
3022
|
local profiles="default compact minimal oneline detailed"
|
|
2890
3023
|
if [ -f "$HOME/.config/slurm-cli.profiles" ]; then
|
|
@@ -2900,6 +3033,11 @@ _slurm_cli_initialize_autocomplete() {{
|
|
|
2900
3033
|
fi
|
|
2901
3034
|
fi
|
|
2902
3035
|
;;
|
|
3036
|
+
--header)
|
|
3037
|
+
[[ "$cur" == "=" ]] && cur=""
|
|
3038
|
+
COMPREPLY=($(compgen -W "none full short trunc" -- "$cur"))
|
|
3039
|
+
return
|
|
3040
|
+
;;
|
|
2903
3041
|
--delimiter|-d|--cache-timeout|-t)
|
|
2904
3042
|
# These options need a value, no completion
|
|
2905
3043
|
return
|
|
@@ -3621,6 +3759,108 @@ def _scontrol_simple(cmd_name: str, verbose: bool, dry_run: bool) -> None:
|
|
|
3621
3759
|
console.print("[red]Error: scontrol not found[/red]")
|
|
3622
3760
|
|
|
3623
3761
|
|
|
3762
|
+
@click.command(context_settings=CONTEXT_SETTINGS)
|
|
3763
|
+
@click.argument("partitions", nargs=-1)
|
|
3764
|
+
@click.option("--users", "-u", is_flag=True, help="Per-user job counts")
|
|
3765
|
+
@click.option("--accounts", "-a", is_flag=True, help="Per-account job counts")
|
|
3766
|
+
@click.option("--states", "-s", is_flag=True, help="Detailed node/job states")
|
|
3767
|
+
@click.option(
|
|
3768
|
+
"--by-user",
|
|
3769
|
+
"-U",
|
|
3770
|
+
is_flag=True,
|
|
3771
|
+
help="User-centric view: jobs by state group per user, split by partition",
|
|
3772
|
+
)
|
|
3773
|
+
@common_options
|
|
3774
|
+
@click.pass_context
|
|
3775
|
+
def pstats(
|
|
3776
|
+
ctx: click.Context,
|
|
3777
|
+
partitions: Tuple[str, ...],
|
|
3778
|
+
users: bool = False,
|
|
3779
|
+
accounts: bool = False,
|
|
3780
|
+
states: bool = False,
|
|
3781
|
+
by_user: bool = False,
|
|
3782
|
+
profile_str: Optional[str] = None,
|
|
3783
|
+
profile: Optional[str] = None,
|
|
3784
|
+
delimiter: Optional[str] = None,
|
|
3785
|
+
zebra: Optional[bool] = None,
|
|
3786
|
+
csv: bool = False,
|
|
3787
|
+
json: bool = False,
|
|
3788
|
+
pretty: bool = False,
|
|
3789
|
+
style: Optional[str] = None,
|
|
3790
|
+
header: Optional[str] = None,
|
|
3791
|
+
header_flag: bool = False,
|
|
3792
|
+
no_header: bool = False,
|
|
3793
|
+
) -> None:
|
|
3794
|
+
"""Partition statistics: node states, jobs, users, CPU/GPU/memory usage.
|
|
3795
|
+
|
|
3796
|
+
Optionally restrict to the given PARTITIONS. Data is always fetched live.
|
|
3797
|
+
"""
|
|
3798
|
+
style = style or ("json" if json else "csv" if csv else None)
|
|
3799
|
+
style = get_output_style(ctx, style)
|
|
3800
|
+
profile_str = get_profile_str(ctx, profile_str)
|
|
3801
|
+
if is_profile_help(profile_str):
|
|
3802
|
+
show_profile_help("pstats")
|
|
3803
|
+
return
|
|
3804
|
+
if header or header_flag or no_header:
|
|
3805
|
+
apply_header_option(header, header_flag, no_header)
|
|
3806
|
+
columns, styles, template, sort_field, sort_asc = get_profile_config(
|
|
3807
|
+
get_profile(ctx, profile), "pstats", profile_str
|
|
3808
|
+
)
|
|
3809
|
+
mode, titles = get_header_config(
|
|
3810
|
+
get_profile(ctx, profile),
|
|
3811
|
+
"pstats",
|
|
3812
|
+
profile_str,
|
|
3813
|
+
USER_HEADERS if by_user else PSTATS_HEADERS,
|
|
3814
|
+
)
|
|
3815
|
+
nodes = Resource.cached_resource("nodes", True) or {}
|
|
3816
|
+
jobs = (Resource.cached_resource("jobs", True) or {}).get("jobs", [])
|
|
3817
|
+
parts = Resource.cached_resource("partitions", True) or {}
|
|
3818
|
+
if by_user:
|
|
3819
|
+
ustats = user_stats(jobs, list(partitions))
|
|
3820
|
+
if style == "json":
|
|
3821
|
+
import json as jsonlib
|
|
3822
|
+
|
|
3823
|
+
console.print_json(jsonlib.dumps(ustats, indent=2))
|
|
3824
|
+
return
|
|
3825
|
+
# a "partition" field asks for one row per partition+user pair
|
|
3826
|
+
used = columns if isinstance(columns, list) else []
|
|
3827
|
+
used = used + (extract_fields_from_template(template) if template else [])
|
|
3828
|
+
urows = sort_data(
|
|
3829
|
+
user_rows(ustats, "partition" in used), sort_field, sort_asc
|
|
3830
|
+
)
|
|
3831
|
+
ucols = user_columns(urows) if columns in (None, "*") else columns
|
|
3832
|
+
# partition names are fields too; their title is the name itself
|
|
3833
|
+
known = set(USER_HEADERS) | set(PSTATS_HEADERS) | set(FIELDS)
|
|
3834
|
+
titles = {**{c: f"{c}|{c}" for c in ucols if c not in known}, **titles}
|
|
3835
|
+
if style == "csv":
|
|
3836
|
+
for line in csv_lines(
|
|
3837
|
+
urows, ucols, get_delimiter(ctx, delimiter), titles, mode
|
|
3838
|
+
):
|
|
3839
|
+
print(line)
|
|
3840
|
+
else:
|
|
3841
|
+
print_user_stats(
|
|
3842
|
+
urows, ucols, template, styles, get_zebra(ctx, zebra), mode, titles
|
|
3843
|
+
)
|
|
3844
|
+
return
|
|
3845
|
+
stats = compute_stats(nodes, jobs, parts, list(partitions))
|
|
3846
|
+
columns = DEFAULT_PSTATS_COLUMNS if columns in (None, "*") else columns
|
|
3847
|
+
rows = sort_data(flat_rows(stats), sort_field, sort_asc)
|
|
3848
|
+
if style == "json":
|
|
3849
|
+
import json as jsonlib
|
|
3850
|
+
|
|
3851
|
+
console.print_json(jsonlib.dumps(to_plain(stats), indent=2, default=list))
|
|
3852
|
+
elif style == "csv":
|
|
3853
|
+
for line in csv_lines(
|
|
3854
|
+
rows, columns, get_delimiter(ctx, delimiter), titles, mode
|
|
3855
|
+
):
|
|
3856
|
+
print(line)
|
|
3857
|
+
else:
|
|
3858
|
+
print_stats(
|
|
3859
|
+
stats, rows, columns, template, styles, users, accounts, states,
|
|
3860
|
+
get_zebra(ctx, zebra), mode, titles,
|
|
3861
|
+
) # fmt: skip
|
|
3862
|
+
|
|
3863
|
+
|
|
3624
3864
|
@click.command(context_settings=CONTEXT_SETTINGS)
|
|
3625
3865
|
@click.option("--verbose", "-v", is_flag=True, help="Enable verbose output")
|
|
3626
3866
|
@click.option("--dry-run", is_flag=True, help="Show command without executing")
|
|
@@ -10,6 +10,7 @@ from rich.table import Table
|
|
|
10
10
|
from .base_resource import BaseSlurmResource
|
|
11
11
|
from .profiles import (
|
|
12
12
|
format_rows,
|
|
13
|
+
header_kwargs,
|
|
13
14
|
get_profile_config,
|
|
14
15
|
sort_data,
|
|
15
16
|
sort_hierarchical_data,
|
|
@@ -462,7 +463,10 @@ _slurm_cli_accounts_autocomplete() {{
|
|
|
462
463
|
# If template is specified, use template-based output
|
|
463
464
|
if template:
|
|
464
465
|
for output in format_rows(
|
|
465
|
-
template,
|
|
466
|
+
template,
|
|
467
|
+
accounts,
|
|
468
|
+
resource="accounts",
|
|
469
|
+
**header_kwargs(profile, "accounts", profile_str),
|
|
466
470
|
):
|
|
467
471
|
console.print(output)
|
|
468
472
|
else:
|
|
@@ -12,6 +12,7 @@ from rich.table import Table
|
|
|
12
12
|
from .base_resource import BaseSlurmResource
|
|
13
13
|
from .profiles import (
|
|
14
14
|
format_rows,
|
|
15
|
+
header_kwargs,
|
|
15
16
|
get_profile_config,
|
|
16
17
|
sort_data,
|
|
17
18
|
sort_hierarchical_data,
|
|
@@ -620,7 +621,10 @@ _slurm_cli_associations_autocomplete() {{
|
|
|
620
621
|
# If template is specified, use template-based output
|
|
621
622
|
if template:
|
|
622
623
|
for output in format_rows(
|
|
623
|
-
template,
|
|
624
|
+
template,
|
|
625
|
+
associations,
|
|
626
|
+
resource="associations",
|
|
627
|
+
**header_kwargs(profile, "associations", profile_str),
|
|
624
628
|
):
|
|
625
629
|
console.print(output)
|
|
626
630
|
else:
|
|
@@ -125,8 +125,14 @@ _slurm_parse_keyval_ext() {{
|
|
|
125
125
|
_val=""
|
|
126
126
|
_op=""
|
|
127
127
|
|
|
128
|
+
# "key=<TAB>": bash makes the operator its own word, key is the previous word
|
|
129
|
+
if [[ $cur == "=" ]]; then
|
|
130
|
+
_key="${{prev,,}}"
|
|
131
|
+
_key="${{_key%[-+]}}"
|
|
132
|
+
_op="="
|
|
133
|
+
return 0
|
|
128
134
|
# Check cur for key+=val, key-=val, or key=val
|
|
129
|
-
|
|
135
|
+
elif [[ $cur == *[-+]=* ]] || [[ $cur == *=* ]]; then
|
|
130
136
|
_key="${{cur%%[-+]*=*}}"
|
|
131
137
|
_key="${{_key%%=*}}"
|
|
132
138
|
_key="${{_key,,}}"
|
|
@@ -167,8 +173,9 @@ _slurm_complete_value() {{
|
|
|
167
173
|
COMPREPLY=($(compgen -W "$words" -- "$val"))
|
|
168
174
|
|
|
169
175
|
# Only add key+op prefix when cur contains = (bash didn't split)
|
|
170
|
-
# If bash split on =, the key= is already on command line
|
|
171
|
-
|
|
176
|
+
# If bash split on =, the key= is already on command line; a cur that is
|
|
177
|
+
# just an operator ("key=<TAB>" makes "=" its own word) is such a case
|
|
178
|
+
if [[ $cur == *=* && $cur != [-+]= && $cur != "=" && ${{#COMPREPLY[@]}} -gt 0 ]]; then
|
|
172
179
|
COMPREPLY=("${{COMPREPLY[@]/#/$key$op}}")
|
|
173
180
|
fi
|
|
174
181
|
}}
|
|
@@ -9,7 +9,7 @@ from rich.box import SIMPLE_HEAVY
|
|
|
9
9
|
from rich.table import Table
|
|
10
10
|
|
|
11
11
|
from .base_resource import BaseSlurmResource
|
|
12
|
-
from .profiles import format_rows, get_profile_config, sort_data
|
|
12
|
+
from .profiles import format_rows, get_profile_config, header_kwargs, sort_data
|
|
13
13
|
from .utils import console
|
|
14
14
|
|
|
15
15
|
|
|
@@ -431,22 +431,24 @@ class Job(BaseSlurmResource):
|
|
|
431
431
|
result = [j for j in result if str(j.get("job_id", "")) == value]
|
|
432
432
|
elif key_lower == "user":
|
|
433
433
|
result = [
|
|
434
|
-
j for j in result if value_lower
|
|
434
|
+
j for j in result if value_lower == j.get("user_name", "").lower()
|
|
435
435
|
]
|
|
436
436
|
elif key_lower == "account":
|
|
437
437
|
result = [
|
|
438
|
-
j for j in result if value_lower
|
|
438
|
+
j for j in result if value_lower == j.get("account", "").lower()
|
|
439
439
|
]
|
|
440
440
|
elif key_lower == "partition":
|
|
441
441
|
result = [
|
|
442
|
-
j
|
|
442
|
+
j
|
|
443
|
+
for j in result
|
|
444
|
+
if value_lower in j.get("partition", "").lower().split(",")
|
|
443
445
|
]
|
|
444
446
|
elif key_lower == "state":
|
|
445
447
|
result = [
|
|
446
448
|
j for j in result if value_lower in j.get("job_state", "").lower()
|
|
447
449
|
]
|
|
448
450
|
elif key_lower == "name":
|
|
449
|
-
result = [j for j in result if value_lower
|
|
451
|
+
result = [j for j in result if value_lower == j.get("name", "").lower()]
|
|
450
452
|
elif key_lower == "nodes":
|
|
451
453
|
result = [
|
|
452
454
|
j for j in result if value_lower in j.get("nodes", "").lower()
|
|
@@ -546,7 +548,11 @@ class Job(BaseSlurmResource):
|
|
|
546
548
|
print(delimiter.join(row))
|
|
547
549
|
elif template:
|
|
548
550
|
# Template-based output
|
|
549
|
-
for output in format_rows(
|
|
551
|
+
for output in format_rows(
|
|
552
|
+
template,
|
|
553
|
+
jobs,
|
|
554
|
+
**header_kwargs(profile, "jobs", profile_str),
|
|
555
|
+
):
|
|
550
556
|
console.print(output)
|
|
551
557
|
else:
|
|
552
558
|
# Pretty table output
|
|
@@ -9,7 +9,7 @@ from rich.markup import escape
|
|
|
9
9
|
from rich.table import Table
|
|
10
10
|
|
|
11
11
|
from .base_resource import BaseSlurmResource
|
|
12
|
-
from .profiles import format_rows, get_profile_config, sort_data
|
|
12
|
+
from .profiles import format_rows, get_profile_config, header_kwargs, sort_data
|
|
13
13
|
from .utils import console
|
|
14
14
|
|
|
15
15
|
|
|
@@ -419,7 +419,12 @@ _slurm_cli_nodes_autocomplete() {{
|
|
|
419
419
|
prepared = [
|
|
420
420
|
{"name": n, **d} for n, d in sorted(nodes_to_show.items())
|
|
421
421
|
]
|
|
422
|
-
for output in format_rows(
|
|
422
|
+
for output in format_rows(
|
|
423
|
+
template_cfg,
|
|
424
|
+
prepared,
|
|
425
|
+
resource="nodes",
|
|
426
|
+
**header_kwargs(profile, "nodes", profile_str),
|
|
427
|
+
):
|
|
423
428
|
console.print(output)
|
|
424
429
|
elif columns_cfg and columns_cfg != "*" and style == "pretty":
|
|
425
430
|
# Use column-based table output (e.g., compact, minimal)
|