slurm-cli 1.1.2__tar.gz → 1.1.3__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.1.2 → slurm_cli-1.1.3}/PKG-INFO +1 -1
- {slurm_cli-1.1.2 → slurm_cli-1.1.3}/pyproject.toml +1 -1
- {slurm_cli-1.1.2 → slurm_cli-1.1.3}/src/slurm_cli/cli.py +8 -6
- {slurm_cli-1.1.2 → slurm_cli-1.1.3}/src/slurm_cli/utils/autocomplete_helpers.py +20 -16
- {slurm_cli-1.1.2 → slurm_cli-1.1.3}/src/slurm_cli/utils/events.py +2 -2
- {slurm_cli-1.1.2 → slurm_cli-1.1.3}/src/slurm_cli/utils/jobs.py +29 -15
- {slurm_cli-1.1.2 → slurm_cli-1.1.3}/src/slurm_cli/utils/profiles.py +12 -1
- {slurm_cli-1.1.2 → slurm_cli-1.1.3}/src/slurm_cli/utils/resources.py +2 -2
- slurm_cli-1.1.3/src/slurm_cli/utils/utils.py +43 -0
- slurm_cli-1.1.2/src/slurm_cli/utils/utils.py +0 -21
- {slurm_cli-1.1.2 → slurm_cli-1.1.3}/LICENSE +0 -0
- {slurm_cli-1.1.2 → slurm_cli-1.1.3}/README.md +0 -0
- {slurm_cli-1.1.2 → slurm_cli-1.1.3}/src/slurm_cli/__init__.py +0 -0
- {slurm_cli-1.1.2 → slurm_cli-1.1.3}/src/slurm_cli/py.typed +0 -0
- {slurm_cli-1.1.2 → slurm_cli-1.1.3}/src/slurm_cli/utils/__init__.py +0 -0
- {slurm_cli-1.1.2 → slurm_cli-1.1.3}/src/slurm_cli/utils/accounts.py +0 -0
- {slurm_cli-1.1.2 → slurm_cli-1.1.3}/src/slurm_cli/utils/associations.py +0 -0
- {slurm_cli-1.1.2 → slurm_cli-1.1.3}/src/slurm_cli/utils/base_resource.py +0 -0
- {slurm_cli-1.1.2 → slurm_cli-1.1.3}/src/slurm_cli/utils/config.py +0 -0
- {slurm_cli-1.1.2 → slurm_cli-1.1.3}/src/slurm_cli/utils/coordinators.py +0 -0
- {slurm_cli-1.1.2 → slurm_cli-1.1.3}/src/slurm_cli/utils/job_filter.py +0 -0
- {slurm_cli-1.1.2 → slurm_cli-1.1.3}/src/slurm_cli/utils/node_filter.py +0 -0
- {slurm_cli-1.1.2 → slurm_cli-1.1.3}/src/slurm_cli/utils/nodes.py +0 -0
- {slurm_cli-1.1.2 → slurm_cli-1.1.3}/src/slurm_cli/utils/partition_stats.py +0 -0
- {slurm_cli-1.1.2 → slurm_cli-1.1.3}/src/slurm_cli/utils/partitions.py +0 -0
- {slurm_cli-1.1.2 → slurm_cli-1.1.3}/src/slurm_cli/utils/prefix_utils.py +0 -0
- {slurm_cli-1.1.2 → slurm_cli-1.1.3}/src/slurm_cli/utils/qos.py +0 -0
- {slurm_cli-1.1.2 → slurm_cli-1.1.3}/src/slurm_cli/utils/reservations.py +0 -0
- {slurm_cli-1.1.2 → slurm_cli-1.1.3}/src/slurm_cli/utils/slurm_config.py +0 -0
- {slurm_cli-1.1.2 → slurm_cli-1.1.3}/src/slurm_cli/utils/titles.py +0 -0
- {slurm_cli-1.1.2 → slurm_cli-1.1.3}/src/slurm_cli/utils/users.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "slurm-cli"
|
|
3
|
-
version = "1.1.
|
|
3
|
+
version = "1.1.3"
|
|
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>"]
|
|
@@ -72,6 +72,7 @@ from .utils.prefix_utils import ( # get_all_resource_names,
|
|
|
72
72
|
get_resources_epilog,
|
|
73
73
|
)
|
|
74
74
|
from .utils.profiles import (
|
|
75
|
+
HEADER_MODES,
|
|
75
76
|
extract_fields_from_template,
|
|
76
77
|
get_header_config,
|
|
77
78
|
get_profile_config,
|
|
@@ -307,7 +308,7 @@ def common_options(func):
|
|
|
307
308
|
)(func)
|
|
308
309
|
func = click.option(
|
|
309
310
|
"--header",
|
|
310
|
-
type=click.Choice(
|
|
311
|
+
type=click.Choice(list(HEADER_MODES)),
|
|
311
312
|
default=None,
|
|
312
313
|
help="Header line for custom formats (full, short, trunc, none)",
|
|
313
314
|
)(func)
|
|
@@ -876,7 +877,7 @@ def show_command_help_with_resources(
|
|
|
876
877
|
)
|
|
877
878
|
@click.option(
|
|
878
879
|
"--header",
|
|
879
|
-
type=click.Choice(
|
|
880
|
+
type=click.Choice(list(HEADER_MODES)),
|
|
880
881
|
default=None,
|
|
881
882
|
help="Header line for custom formats: full titles, short titles, "
|
|
882
883
|
"titles truncated to the column width, or none (SLURM_CLI_HEADER)",
|
|
@@ -1418,7 +1419,7 @@ def show(
|
|
|
1418
1419
|
# One table from scontrol data; unlike squeue it keeps
|
|
1419
1420
|
# completed jobs that are still known to slurmctld
|
|
1420
1421
|
Job.show(
|
|
1421
|
-
field=
|
|
1422
|
+
field=list(field),
|
|
1422
1423
|
style=style,
|
|
1423
1424
|
force_cache_update=force_update,
|
|
1424
1425
|
delimiter=delimiter,
|
|
@@ -2303,6 +2304,7 @@ def autocomplete(word: str, max_cost: int, size: int) -> None:
|
|
|
2303
2304
|
|
|
2304
2305
|
# Generate resource case patterns from RESOURCES config
|
|
2305
2306
|
resource_case_patterns = generate_bash_resource_case()
|
|
2307
|
+
header_modes = " ".join(HEADER_MODES)
|
|
2306
2308
|
pstats_fields = " ".join(f for f in PSTATS_FIELDS if not f.startswith("<"))
|
|
2307
2309
|
# all_resources_str = get_all_resource_names()
|
|
2308
2310
|
|
|
@@ -2918,7 +2920,7 @@ _slurm_cli_initialize_autocomplete() {{
|
|
|
2918
2920
|
fi
|
|
2919
2921
|
case "$opt" in
|
|
2920
2922
|
--header)
|
|
2921
|
-
COMPREPLY=($(compgen -W "
|
|
2923
|
+
COMPREPLY=($(compgen -W "{header_modes}" -- "$val"))
|
|
2922
2924
|
return ;;
|
|
2923
2925
|
--style)
|
|
2924
2926
|
COMPREPLY=($(compgen -W "{' '.join(STYLE_OPTIONS)}" -- "$val"))
|
|
@@ -3015,7 +3017,7 @@ _slurm_cli_initialize_autocomplete() {{
|
|
|
3015
3017
|
if [[ ${{COMP_CWORD}} -ge 2 ]]; then
|
|
3016
3018
|
local opt="${{COMP_WORDS[COMP_CWORD-2]}}"
|
|
3017
3019
|
if [[ "$opt" == "--header" ]]; then
|
|
3018
|
-
COMPREPLY=($(compgen -W "
|
|
3020
|
+
COMPREPLY=($(compgen -W "{header_modes}" -- "$cur"))
|
|
3019
3021
|
return
|
|
3020
3022
|
fi
|
|
3021
3023
|
if [[ "$opt" == "--profile" || "$opt" == "-P" ]]; then
|
|
@@ -3035,7 +3037,7 @@ _slurm_cli_initialize_autocomplete() {{
|
|
|
3035
3037
|
;;
|
|
3036
3038
|
--header)
|
|
3037
3039
|
[[ "$cur" == "=" ]] && cur=""
|
|
3038
|
-
COMPREPLY=($(compgen -W "
|
|
3040
|
+
COMPREPLY=($(compgen -W "{header_modes}" -- "$cur"))
|
|
3039
3041
|
return
|
|
3040
3042
|
;;
|
|
3041
3043
|
--delimiter|-d|--cache-timeout|-t)
|
|
@@ -21,6 +21,9 @@ def get_common_autocomplete_functions() -> str:
|
|
|
21
21
|
# Cache timeout in seconds
|
|
22
22
|
_SLURM_CACHE_TIMEOUT={Resource.CACHE_TIMEOUT}
|
|
23
23
|
|
|
24
|
+
# Per-user cache directory (same as utils.cache_dir() in Python)
|
|
25
|
+
_SLURM_CACHE_DIR="${{TMPDIR:-/tmp}}/slurm_cli-$(id -u)"
|
|
26
|
+
|
|
24
27
|
# Check if cache update is disabled via environment variable
|
|
25
28
|
# Returns 0 if updates are disabled, 1 otherwise
|
|
26
29
|
_slurm_cache_updates_disabled() {{
|
|
@@ -30,7 +33,7 @@ _slurm_cache_updates_disabled() {{
|
|
|
30
33
|
}}
|
|
31
34
|
|
|
32
35
|
# Ensure cache file exists and is fresh, update if needed
|
|
33
|
-
# Usage: _slurm_ensure_cache "/
|
|
36
|
+
# Usage: _slurm_ensure_cache "$_SLURM_CACHE_DIR/slurm_cli_nodes.json" "nodes"
|
|
34
37
|
_slurm_ensure_cache() {{
|
|
35
38
|
local file="$1"
|
|
36
39
|
local resource="$2"
|
|
@@ -78,7 +81,8 @@ _slurm_complete() {{
|
|
|
78
81
|
_slurm_cache_get() {{
|
|
79
82
|
local file="$1"
|
|
80
83
|
local jq_expr="$2"
|
|
81
|
-
|
|
84
|
+
# only read files that are ours
|
|
85
|
+
if [ -f "$file" ] && [ -O "$file" ]; then
|
|
82
86
|
jq -r "$jq_expr" "$file" 2>/dev/null | tr '\\n' ' '
|
|
83
87
|
fi
|
|
84
88
|
}}
|
|
@@ -183,38 +187,38 @@ _slurm_complete_value() {{
|
|
|
183
187
|
# Cache accessor functions for common resources
|
|
184
188
|
# Each function ensures cache is fresh before reading
|
|
185
189
|
_slurm_cache_accounts() {{
|
|
186
|
-
_slurm_ensure_cache "/
|
|
187
|
-
_slurm_cache_get "/
|
|
190
|
+
_slurm_ensure_cache "$_SLURM_CACHE_DIR/slurm_cli_accounts.json" "accounts"
|
|
191
|
+
_slurm_cache_get "$_SLURM_CACHE_DIR/slurm_cli_accounts.json" '.accounts[].name'
|
|
188
192
|
}}
|
|
189
193
|
|
|
190
194
|
_slurm_cache_qos() {{
|
|
191
|
-
_slurm_ensure_cache "/
|
|
192
|
-
_slurm_cache_get "/
|
|
195
|
+
_slurm_ensure_cache "$_SLURM_CACHE_DIR/slurm_cli_qos.json" "qos"
|
|
196
|
+
_slurm_cache_get "$_SLURM_CACHE_DIR/slurm_cli_qos.json" '.qos[].name'
|
|
193
197
|
}}
|
|
194
198
|
|
|
195
199
|
_slurm_cache_partitions() {{
|
|
196
|
-
_slurm_ensure_cache "/
|
|
197
|
-
_slurm_cache_get "/
|
|
200
|
+
_slurm_ensure_cache "$_SLURM_CACHE_DIR/slurm_cli_partitions.json" "partitions"
|
|
201
|
+
_slurm_cache_get "$_SLURM_CACHE_DIR/slurm_cli_partitions.json" 'keys[]'
|
|
198
202
|
}}
|
|
199
203
|
|
|
200
204
|
_slurm_cache_nodes() {{
|
|
201
|
-
_slurm_ensure_cache "/
|
|
202
|
-
_slurm_cache_get "/
|
|
205
|
+
_slurm_ensure_cache "$_SLURM_CACHE_DIR/slurm_cli_nodes.json" "nodes"
|
|
206
|
+
_slurm_cache_get "$_SLURM_CACHE_DIR/slurm_cli_nodes.json" 'keys[]'
|
|
203
207
|
}}
|
|
204
208
|
|
|
205
209
|
_slurm_cache_users() {{
|
|
206
|
-
_slurm_ensure_cache "/
|
|
207
|
-
_slurm_cache_get "/
|
|
210
|
+
_slurm_ensure_cache "$_SLURM_CACHE_DIR/slurm_cli_users.json" "users"
|
|
211
|
+
_slurm_cache_get "$_SLURM_CACHE_DIR/slurm_cli_users.json" '.users[].name'
|
|
208
212
|
}}
|
|
209
213
|
|
|
210
214
|
_slurm_cache_reservations() {{
|
|
211
|
-
_slurm_ensure_cache "/
|
|
212
|
-
_slurm_cache_get "/
|
|
215
|
+
_slurm_ensure_cache "$_SLURM_CACHE_DIR/slurm_cli_reservations.json" "reservations"
|
|
216
|
+
_slurm_cache_get "$_SLURM_CACHE_DIR/slurm_cli_reservations.json" 'keys[]'
|
|
213
217
|
}}
|
|
214
218
|
|
|
215
219
|
_slurm_cache_jobs() {{
|
|
216
|
-
_slurm_ensure_cache "/
|
|
217
|
-
_slurm_cache_get "/
|
|
220
|
+
_slurm_ensure_cache "$_SLURM_CACHE_DIR/slurm_cli_jobs.json" "jobs"
|
|
221
|
+
_slurm_cache_get "$_SLURM_CACHE_DIR/slurm_cli_jobs.json" '.jobs[].job_id'
|
|
218
222
|
}}
|
|
219
223
|
|
|
220
224
|
# Node filter prefixes for nodes= parameter
|
|
@@ -12,7 +12,7 @@ from rich.table import Table # pyright: ignore[reportMissingImports]
|
|
|
12
12
|
from .base_resource import BaseSlurmResource
|
|
13
13
|
from .node_filter import is_node_filter, resolve_node_filter
|
|
14
14
|
from .profiles import get_profile_config, sort_data
|
|
15
|
-
from .utils import console
|
|
15
|
+
from .utils import cache_dir, console
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
def expand_node_ranges(node_spec: str) -> set:
|
|
@@ -47,7 +47,7 @@ def expand_node_ranges(node_spec: str) -> set:
|
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
# Cache file paths
|
|
50
|
-
CACHE_DIR =
|
|
50
|
+
CACHE_DIR = cache_dir()
|
|
51
51
|
EVENTS_CACHE_FILE = f"{CACHE_DIR}slurm_cli_events.txt"
|
|
52
52
|
EVENTS_JSON_CACHE_FILE = f"{CACHE_DIR}slurm_cli_events.json"
|
|
53
53
|
# Flag file to indicate JSON format is not supported
|
|
@@ -13,6 +13,16 @@ from .profiles import format_rows, get_profile_config, header_kwargs, sort_data
|
|
|
13
13
|
from .utils import console
|
|
14
14
|
|
|
15
15
|
|
|
16
|
+
# squeue's short state codes
|
|
17
|
+
_STATE_CODES = {
|
|
18
|
+
"PD": "pending", "R": "running", "CG": "completing", "CD": "completed",
|
|
19
|
+
"CA": "cancelled", "F": "failed", "TO": "timeout", "NF": "node_fail",
|
|
20
|
+
"S": "suspended", "PR": "preempted", "OOM": "out_of_memory",
|
|
21
|
+
"DL": "deadline", "BF": "boot_fail", "RQ": "requeued", "RH": "requeue_hold",
|
|
22
|
+
"CF": "configuring", "ST": "stopped", "SE": "special_exit",
|
|
23
|
+
} # fmt: skip
|
|
24
|
+
|
|
25
|
+
|
|
16
26
|
def _format_timestamp(epoch: int, default: str = "-") -> str:
|
|
17
27
|
"""Format Unix timestamp as YYYY-MM-DDTHH:MM:SS."""
|
|
18
28
|
if not epoch or epoch <= 0:
|
|
@@ -425,37 +435,40 @@ class Job(BaseSlurmResource):
|
|
|
425
435
|
|
|
426
436
|
for key, value in filters.items():
|
|
427
437
|
key_lower = key.lower()
|
|
428
|
-
|
|
438
|
+
# like squeue: comma lists, any value may match
|
|
439
|
+
values = [v.lower() for v in value.split(",") if v]
|
|
429
440
|
|
|
430
441
|
if key_lower == "job_id":
|
|
431
442
|
result = [j for j in result if str(j.get("job_id", "")) == value]
|
|
432
443
|
elif key_lower == "user":
|
|
433
|
-
result = [
|
|
434
|
-
j for j in result if value_lower == j.get("user_name", "").lower()
|
|
435
|
-
]
|
|
444
|
+
result = [j for j in result if j.get("user_name", "").lower() in values]
|
|
436
445
|
elif key_lower == "account":
|
|
437
|
-
result = [
|
|
438
|
-
j for j in result if value_lower == j.get("account", "").lower()
|
|
439
|
-
]
|
|
446
|
+
result = [j for j in result if j.get("account", "").lower() in values]
|
|
440
447
|
elif key_lower == "partition":
|
|
441
448
|
result = [
|
|
442
449
|
j
|
|
443
450
|
for j in result
|
|
444
|
-
if
|
|
451
|
+
if set(j.get("partition", "").lower().split(",")) & set(values)
|
|
445
452
|
]
|
|
446
453
|
elif key_lower == "state":
|
|
454
|
+
# squeue short codes (PD, R, ...) or (part of) the state name
|
|
455
|
+
wanted = [_STATE_CODES.get(v.upper(), v) for v in values]
|
|
447
456
|
result = [
|
|
448
|
-
j
|
|
457
|
+
j
|
|
458
|
+
for j in result
|
|
459
|
+
if any(w in j.get("job_state", "").lower() for w in wanted)
|
|
449
460
|
]
|
|
450
461
|
elif key_lower == "name":
|
|
451
|
-
result = [j for j in result if
|
|
462
|
+
result = [j for j in result if j.get("name", "").lower() in values]
|
|
452
463
|
elif key_lower == "nodes":
|
|
453
464
|
result = [
|
|
454
|
-
j for j in result if
|
|
465
|
+
j for j in result if value.lower() in j.get("nodes", "").lower()
|
|
455
466
|
]
|
|
456
467
|
elif key_lower == "reservation":
|
|
457
468
|
result = [
|
|
458
|
-
j
|
|
469
|
+
j
|
|
470
|
+
for j in result
|
|
471
|
+
if value.lower() in j.get("reservation", "").lower()
|
|
459
472
|
]
|
|
460
473
|
|
|
461
474
|
return result
|
|
@@ -463,7 +476,7 @@ class Job(BaseSlurmResource):
|
|
|
463
476
|
@classmethod
|
|
464
477
|
def show(
|
|
465
478
|
cls,
|
|
466
|
-
field: Union[str, None] = None,
|
|
479
|
+
field: Union[str, List[str], None] = None,
|
|
467
480
|
style: str = "pretty",
|
|
468
481
|
force_cache_update: bool = False,
|
|
469
482
|
delimiter: str = ";",
|
|
@@ -474,7 +487,8 @@ class Job(BaseSlurmResource):
|
|
|
474
487
|
"""Show job information.
|
|
475
488
|
|
|
476
489
|
Args:
|
|
477
|
-
field: Optional filter (e.g., user=john, state=running)
|
|
490
|
+
field: Optional filter (e.g., user=john, state=running); a string
|
|
491
|
+
is split on spaces, a list keeps values with spaces intact
|
|
478
492
|
style: Output style ("pretty", "json", or "csv")
|
|
479
493
|
force_cache_update: Whether to force cache update
|
|
480
494
|
delimiter: Delimiter for CSV output (default: ";")
|
|
@@ -505,7 +519,7 @@ class Job(BaseSlurmResource):
|
|
|
505
519
|
# Parse filters from field argument
|
|
506
520
|
filters: Dict[str, str] = {}
|
|
507
521
|
if field:
|
|
508
|
-
parts = field.split()
|
|
522
|
+
parts = field.split() if isinstance(field, str) else field
|
|
509
523
|
for part in parts:
|
|
510
524
|
if "=" in part:
|
|
511
525
|
key, value = part.split("=", 1)
|
|
@@ -38,6 +38,7 @@ Template syntax:
|
|
|
38
38
|
|
|
39
39
|
import os
|
|
40
40
|
import re
|
|
41
|
+
import sys
|
|
41
42
|
from pathlib import Path
|
|
42
43
|
from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Union
|
|
43
44
|
|
|
@@ -979,7 +980,10 @@ def _norm_mode(mode: Optional[str]) -> Optional[str]:
|
|
|
979
980
|
"no": "none", "false": "none", "0": "none", "off": "none"}.get(mode, mode) # fmt: skip
|
|
980
981
|
if mode in HEADER_MODES:
|
|
981
982
|
return mode
|
|
982
|
-
print(
|
|
983
|
+
print(
|
|
984
|
+
f"Warning: unknown header mode '{mode}' (use {', '.join(HEADER_MODES)})",
|
|
985
|
+
file=sys.stderr,
|
|
986
|
+
)
|
|
983
987
|
return None
|
|
984
988
|
|
|
985
989
|
|
|
@@ -1211,6 +1215,13 @@ def format_rows(
|
|
|
1211
1215
|
if mode:
|
|
1212
1216
|
template = _header_template(template)
|
|
1213
1217
|
widths: Dict[str, int] = {}
|
|
1218
|
+
# the first pass only matters for {f::} / {f:N+} fields (and the header)
|
|
1219
|
+
shared = any(
|
|
1220
|
+
m.group("min") or (m.group("w") is None and ":" in m.group(0))
|
|
1221
|
+
for m in FIELD_PATTERN.finditer(COND_PATTERN.sub("", template))
|
|
1222
|
+
)
|
|
1223
|
+
if not shared and not mode:
|
|
1224
|
+
return [format_with_template(template, row, **kwargs) for row in rows]
|
|
1214
1225
|
if mode in ("full", "short"):
|
|
1215
1226
|
for m in FIELD_PATTERN.finditer(COND_PATTERN.sub("", template)):
|
|
1216
1227
|
if ":" in m.group(0) and not m.group("cut"):
|
|
@@ -7,7 +7,7 @@ import time
|
|
|
7
7
|
# from enum import Enum
|
|
8
8
|
from typing import Any, Dict, List, Tuple, Union
|
|
9
9
|
|
|
10
|
-
from .utils import console
|
|
10
|
+
from .utils import cache_dir, console
|
|
11
11
|
|
|
12
12
|
SPINNER_STYLE = "dots2"
|
|
13
13
|
# moon, dots, simpleDots, dots2, dots12
|
|
@@ -17,7 +17,7 @@ SPINNER_SPEED = 1.0
|
|
|
17
17
|
|
|
18
18
|
class Resource:
|
|
19
19
|
CACHE_TIMEOUT = 600
|
|
20
|
-
CACHE_DIR =
|
|
20
|
+
CACHE_DIR = cache_dir()
|
|
21
21
|
CACHE_FILES = {
|
|
22
22
|
"nodes": f"{CACHE_DIR}slurm_cli_nodes.json",
|
|
23
23
|
"partitions": f"{CACHE_DIR}slurm_cli_partitions.json",
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import tempfile
|
|
3
|
+
|
|
4
|
+
from rich.console import Console
|
|
5
|
+
from rich.theme import Theme
|
|
6
|
+
|
|
7
|
+
theme = Theme(
|
|
8
|
+
{
|
|
9
|
+
"info": "dim cyan",
|
|
10
|
+
"warning": "dim yellow",
|
|
11
|
+
"danger": "dim red",
|
|
12
|
+
"success": "dim green",
|
|
13
|
+
"object": "b cyan",
|
|
14
|
+
"str": "bright_green",
|
|
15
|
+
"label": "bright_blue",
|
|
16
|
+
"partition": "b cyan",
|
|
17
|
+
"nodes": "b yellow",
|
|
18
|
+
"time": "b green",
|
|
19
|
+
"qos": "b red",
|
|
20
|
+
"allow": "b green",
|
|
21
|
+
"deny": "b red",
|
|
22
|
+
}
|
|
23
|
+
)
|
|
24
|
+
console = Console(theme=theme)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def cache_dir() -> str:
|
|
28
|
+
"""Per-user cache directory (with trailing slash): $TMPDIR/slurm_cli-UID, mode 0700.
|
|
29
|
+
|
|
30
|
+
Caches hold data of every user (all jobs), so they must not be shared in /tmp.
|
|
31
|
+
A directory somebody else created (or a symlink) is never used; a private
|
|
32
|
+
temporary one is used instead (the cache then lasts for this run only).
|
|
33
|
+
"""
|
|
34
|
+
path = os.path.join(tempfile.gettempdir(), f"slurm_cli-{os.getuid()}")
|
|
35
|
+
try:
|
|
36
|
+
os.makedirs(path, mode=0o700, exist_ok=True)
|
|
37
|
+
st = os.lstat(path)
|
|
38
|
+
if st.st_uid != os.getuid() or not os.path.isdir(path) or os.path.islink(path):
|
|
39
|
+
raise PermissionError(path)
|
|
40
|
+
os.chmod(path, 0o700)
|
|
41
|
+
except OSError:
|
|
42
|
+
path = tempfile.mkdtemp(prefix="slurm_cli-")
|
|
43
|
+
return path + "/"
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
from rich.console import Console
|
|
2
|
-
from rich.theme import Theme
|
|
3
|
-
|
|
4
|
-
theme = Theme(
|
|
5
|
-
{
|
|
6
|
-
"info": "dim cyan",
|
|
7
|
-
"warning": "dim yellow",
|
|
8
|
-
"danger": "dim red",
|
|
9
|
-
"success": "dim green",
|
|
10
|
-
"object": "b cyan",
|
|
11
|
-
"str": "bright_green",
|
|
12
|
-
"label": "bright_blue",
|
|
13
|
-
"partition": "b cyan",
|
|
14
|
-
"nodes": "b yellow",
|
|
15
|
-
"time": "b green",
|
|
16
|
-
"qos": "b red",
|
|
17
|
-
"allow": "b green",
|
|
18
|
-
"deny": "b red",
|
|
19
|
-
}
|
|
20
|
-
)
|
|
21
|
-
console = Console(theme=theme)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|