slurmscope 2.2.0.dev1__tar.gz → 2.3.0__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.
Files changed (41) hide show
  1. slurmscope-2.3.0/.gitignore +2 -0
  2. {slurmscope-2.2.0.dev1 → slurmscope-2.3.0}/CHANGELOG.md +23 -0
  3. {slurmscope-2.2.0.dev1 → slurmscope-2.3.0}/Cargo.lock +1 -1
  4. {slurmscope-2.2.0.dev1 → slurmscope-2.3.0}/Cargo.toml +1 -1
  5. slurmscope-2.3.0/PKG-INFO +60 -0
  6. slurmscope-2.3.0/PYPI.md +37 -0
  7. {slurmscope-2.2.0.dev1 → slurmscope-2.3.0}/README.md +73 -18
  8. {slurmscope-2.2.0.dev1 → slurmscope-2.3.0}/pyproject.toml +3 -3
  9. {slurmscope-2.2.0.dev1 → slurmscope-2.3.0}/src/app.rs +15 -11
  10. {slurmscope-2.2.0.dev1 → slurmscope-2.3.0}/src/main.rs +126 -2
  11. {slurmscope-2.2.0.dev1 → slurmscope-2.3.0}/src/render.rs +2 -2
  12. slurmscope-2.3.0/src/sprite_anim.rs +522 -0
  13. slurmscope-2.3.0/src/sprite_fetch.rs +404 -0
  14. slurmscope-2.3.0/src/sprites.rs +928 -0
  15. {slurmscope-2.2.0.dev1 → slurmscope-2.3.0}/src/style.rs +1 -1
  16. {slurmscope-2.2.0.dev1 → slurmscope-2.3.0}/tests/difftest.sh +1 -1
  17. {slurmscope-2.2.0.dev1 → slurmscope-2.3.0}/tests/parity_app.py +1 -0
  18. slurmscope-2.3.0/tests/pyref.py +62 -0
  19. {slurmscope-2.2.0.dev1 → slurmscope-2.3.0}/tests/test_process_parity.py +2 -1
  20. slurmscope-2.3.0/tools/fetch_sprites.py +202 -0
  21. slurmscope-2.2.0.dev1/PKG-INFO +0 -66
  22. slurmscope-2.2.0.dev1/PYPI.md +0 -43
  23. slurmscope-2.2.0.dev1/patches/slurmscope-2.0.0.dev1-runner.diff +0 -938
  24. {slurmscope-2.2.0.dev1 → slurmscope-2.3.0}/LICENSE +0 -0
  25. {slurmscope-2.2.0.dev1 → slurmscope-2.3.0}/build.rs +0 -0
  26. {slurmscope-2.2.0.dev1 → slurmscope-2.3.0}/src/coord.rs +0 -0
  27. {slurmscope-2.2.0.dev1 → slurmscope-2.3.0}/src/data.rs +0 -0
  28. {slurmscope-2.2.0.dev1 → slurmscope-2.3.0}/src/hooks.rs +0 -0
  29. {slurmscope-2.2.0.dev1 → slurmscope-2.3.0}/src/killers.rs +0 -0
  30. {slurmscope-2.2.0.dev1 → slurmscope-2.3.0}/src/probe.rs +0 -0
  31. {slurmscope-2.2.0.dev1 → slurmscope-2.3.0}/src/pyuni.rs +0 -0
  32. {slurmscope-2.2.0.dev1 → slurmscope-2.3.0}/src/share.rs +0 -0
  33. {slurmscope-2.2.0.dev1 → slurmscope-2.3.0}/src/slurm.rs +0 -0
  34. {slurmscope-2.2.0.dev1 → slurmscope-2.3.0}/src/storage.rs +0 -0
  35. {slurmscope-2.2.0.dev1 → slurmscope-2.3.0}/src/surfer.rs +0 -0
  36. {slurmscope-2.2.0.dev1 → slurmscope-2.3.0}/src/util.rs +0 -0
  37. {slurmscope-2.2.0.dev1 → slurmscope-2.3.0}/tests/bench.sh +0 -0
  38. {slurmscope-2.2.0.dev1 → slurmscope-2.3.0}/tests/gen_pyuni.py +0 -0
  39. {slurmscope-2.2.0.dev1 → slurmscope-2.3.0}/tests/parity_funcs.py +0 -0
  40. {slurmscope-2.2.0.dev1 → slurmscope-2.3.0}/tests/run_all.sh +0 -0
  41. {slurmscope-2.2.0.dev1 → slurmscope-2.3.0}/tests/test_harness_regressions.py +0 -0
@@ -0,0 +1,2 @@
1
+ target/
2
+ patches/
@@ -1,5 +1,28 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.3.0 — 2026-11-11 (stable)
4
+
5
+ The Rust implementation becomes the stable release: `pip install slurmscope` installs it (wheels for Linux
6
+ x86_64 and aarch64, glibc >= 2.17). The Python implementation stays available as 1.6.x
7
+ (`pip install "slurmscope<2"`).
8
+
9
+ ### Changed
10
+ - **`p` toggles the Pokémon thumbnails**; refresh pause removed (`p` and Space no longer pause). Help and footer
11
+ updated. The parity tests apply these deliberate differences to the Python reference (`tests/pyref.py`).
12
+
13
+ ### Added
14
+ - **Pokémon thumbnails next to job names** that are a Pokémon species (shiny names: same sprite), in terminals
15
+ with an image protocol only, detected automatically: iTerm2/WezTerm (OSC 1337), kitty/Ghostty (Unicode
16
+ placeholders), also inside tmux (passthrough). The sprites hop like party icons (2-frame animation played by
17
+ the terminal; each image is sent once, not at every refresh). They are not shipped: the first start downloads
18
+ them in the background with `curl` into one zip in `~/.cache/slurmscope/` (no internet: no thumbnails, retry
19
+ after 24 h; `tools/fetch_sprites.py` does the same by hand); `--sprites-file ZIP`, `--no-sprites`. Frames are
20
+ unchanged when off. Static Sixel sprites in terminals that report Sixel in DA1 (and tmux >= 3.4). Sprites are
21
+ drawn on the terminal's default background; `--sprite-bg` / `SLURMSCOPE_SPRITE_BG` set it where the terminal
22
+ cannot be asked (tmux < 3.3). Stable inside tmux (lines are rewritten
23
+ only after the sprite). Thumbnails are 3 columns wide, cropped to the sprite and standing on the bottom.
24
+ `SLURMSCOPE_SPRITES=iterm|kitty|sixel|off` forces a protocol (e.g. VS Code inside tmux).
25
+
3
26
  ## 2.2.0.dev1 — 2026-11-05 (pre-release)
4
27
 
5
28
  ### Added
@@ -484,7 +484,7 @@ checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
484
484
 
485
485
  [[package]]
486
486
  name = "slurmscope"
487
- version = "2.2.0-dev.1"
487
+ version = "2.3.0"
488
488
  dependencies = [
489
489
  "chrono",
490
490
  "clap",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "slurmscope"
3
- version = "2.2.0-dev.1"
3
+ version = "2.3.0"
4
4
  edition = "2021"
5
5
  rust-version = "1.80"
6
6
  description = "Live terminal dashboard for Slurm clusters (Rust port, protocol-compatible with the Python version)"
@@ -0,0 +1,60 @@
1
+ Metadata-Version: 2.4
2
+ Name: slurmscope
3
+ Version: 2.3.0
4
+ Classifier: Development Status :: 4 - Beta
5
+ Classifier: Environment :: Console
6
+ Classifier: Intended Audience :: Science/Research
7
+ Classifier: Intended Audience :: System Administrators
8
+ Classifier: Operating System :: POSIX :: Linux
9
+ Classifier: Programming Language :: Rust
10
+ Classifier: Topic :: System :: Clustering
11
+ Classifier: Topic :: System :: Monitoring
12
+ License-File: LICENSE
13
+ Summary: Live terminal dashboard for Slurm clusters: queue, GPUs, QoS, nodes, memory and storage.
14
+ Keywords: slurm,hpc,cluster,gpu,dashboard,tui,monitoring,rust
15
+ Author: Fabio Bozzoli
16
+ License-Expression: MIT
17
+ Requires-Python: >=3.8
18
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
19
+ Project-URL: Homepage, https://github.com/FabioBozzoli/slurmscope
20
+ Project-URL: Issues, https://github.com/FabioBozzoli/slurmscope/issues
21
+ Project-URL: Source, https://github.com/FabioBozzoli/slurmscope/tree/slurmscope-rust/rust
22
+
23
+ # slurmscope
24
+
25
+ Live terminal dashboard for Slurm clusters: queue, GPUs, QoS, nodes, memory and storage, in one
26
+ interactive view. Since 2.3.0 the stable release is this Rust implementation (a single static-ish
27
+ binary, no runtime dependency beyond the Slurm client commands and glibc ≥ 2.17).
28
+
29
+ pip install slurmscope # or: pipx install slurmscope / uv tool install slurmscope
30
+ slurmscope # interactive dashboard
31
+ slurmscope --once --page 2 # one snapshot of the jobs page
32
+ slurmscope --help
33
+
34
+ It needs the Slurm client commands (`squeue`, `scontrol`) in `PATH`, typically on a login node.
35
+ Wheels are provided for Linux x86_64 and aarch64 (glibc ≥ 2.17); elsewhere pip builds from the
36
+ source distribution, which needs a Rust toolchain (`cargo`). The previous Python implementation
37
+ remains available: `pip install "slurmscope<2"`. Both are protocol-compatible: they share the
38
+ per-login-node collector, its snapshots and cache files.
39
+
40
+ ## Pokémon thumbnails
41
+
42
+ When a job name is a Pokémon species (`Pikachu`, `Mr. Mime`, `★ Snorlax shiny ★`, …) a small hopping
43
+ sprite is drawn next to it, in terminals that can show images: iTerm2, WezTerm, kitty, Ghostty
44
+ (animated), and Sixel terminals such as Windows Terminal, foot, Konsole or VS Code with
45
+ `"terminal.integrated.enableImages": true` (static); also inside tmux. Elsewhere nothing changes.
46
+ `p` turns them on and off; `--no-sprites` disables them. No image is shipped: on the first start
47
+ slurmscope downloads them once from PokeAPI with `curl` into `~/.cache/slurmscope/sprites.zip`
48
+ (without internet it simply runs without them). Inside tmux < 3.3 the terminal background cannot be
49
+ detected: set it with `SLURMSCOPE_SPRITE_BG='#RRGGBB'` (or `--sprite-bg`).
50
+
51
+ Pokémon and the sprites are © The Pokémon Company / Nintendo; slurmscope is not affiliated with them.
52
+
53
+ ## Status
54
+
55
+ The Rust implementation is compared with the Python one by differential tests (function-level
56
+ fuzzing, the App driven event by event, real-process scenarios and byte-for-byte `--once` output);
57
+ the documented differences are listed in
58
+ [rust/README.md](https://github.com/FabioBozzoli/slurmscope/blob/slurmscope-rust/rust/README.md).
59
+ Please report problems at https://github.com/FabioBozzoli/slurmscope/issues.
60
+
@@ -0,0 +1,37 @@
1
+ # slurmscope
2
+
3
+ Live terminal dashboard for Slurm clusters: queue, GPUs, QoS, nodes, memory and storage, in one
4
+ interactive view. Since 2.3.0 the stable release is this Rust implementation (a single static-ish
5
+ binary, no runtime dependency beyond the Slurm client commands and glibc ≥ 2.17).
6
+
7
+ pip install slurmscope # or: pipx install slurmscope / uv tool install slurmscope
8
+ slurmscope # interactive dashboard
9
+ slurmscope --once --page 2 # one snapshot of the jobs page
10
+ slurmscope --help
11
+
12
+ It needs the Slurm client commands (`squeue`, `scontrol`) in `PATH`, typically on a login node.
13
+ Wheels are provided for Linux x86_64 and aarch64 (glibc ≥ 2.17); elsewhere pip builds from the
14
+ source distribution, which needs a Rust toolchain (`cargo`). The previous Python implementation
15
+ remains available: `pip install "slurmscope<2"`. Both are protocol-compatible: they share the
16
+ per-login-node collector, its snapshots and cache files.
17
+
18
+ ## Pokémon thumbnails
19
+
20
+ When a job name is a Pokémon species (`Pikachu`, `Mr. Mime`, `★ Snorlax shiny ★`, …) a small hopping
21
+ sprite is drawn next to it, in terminals that can show images: iTerm2, WezTerm, kitty, Ghostty
22
+ (animated), and Sixel terminals such as Windows Terminal, foot, Konsole or VS Code with
23
+ `"terminal.integrated.enableImages": true` (static); also inside tmux. Elsewhere nothing changes.
24
+ `p` turns them on and off; `--no-sprites` disables them. No image is shipped: on the first start
25
+ slurmscope downloads them once from PokeAPI with `curl` into `~/.cache/slurmscope/sprites.zip`
26
+ (without internet it simply runs without them). Inside tmux < 3.3 the terminal background cannot be
27
+ detected: set it with `SLURMSCOPE_SPRITE_BG='#RRGGBB'` (or `--sprite-bg`).
28
+
29
+ Pokémon and the sprites are © The Pokémon Company / Nintendo; slurmscope is not affiliated with them.
30
+
31
+ ## Status
32
+
33
+ The Rust implementation is compared with the Python one by differential tests (function-level
34
+ fuzzing, the App driven event by event, real-process scenarios and byte-for-byte `--once` output);
35
+ the documented differences are listed in
36
+ [rust/README.md](https://github.com/FabioBozzoli/slurmscope/blob/slurmscope-rust/rust/README.md).
37
+ Please report problems at https://github.com/FabioBozzoli/slurmscope/issues.
@@ -18,29 +18,80 @@ The binary has no runtime dependency beyond the Slurm client commands and glibc.
18
18
  A fully static binary can be built with `rustup target add x86_64-unknown-linux-musl` and
19
19
  `cargo build --release --target x86_64-unknown-linux-musl`.
20
20
 
21
- ## Packaging (PyPI pre-release)
21
+ ## Packaging (PyPI)
22
22
 
23
- Published under the same PyPI name as the Python version, as a **pre-release**, so that
24
- `pip install slurmscope` keeps installing the stable Python 1.6.x and the Rust build is only
25
- installed on request (`pip install "slurmscope==2.2.0.dev1"`, or `pipx install --suffix=-rs …` to
26
- keep both). `pyproject.toml` uses maturin with `bindings = "bin"`: the wheel ships the
27
- `slurmscope` executable and no Python module. The version comes from `Cargo.toml`
28
- (`2.2.0-dev.1`, semver), which maturin publishes as `2.2.0.dev1` (PEP 440); `build.rs` exposes the
29
- same PEP 440 form to the program (`--version`, help). `PYPI.md` is the project description shown
30
- on PyPI for this release.
23
+ Since 2.3.0 this Rust implementation is the **stable** release on PyPI (`pip install slurmscope`); the Python
24
+ implementation stays installable as 1.6.x (`pip install "slurmscope<2"`). `pyproject.toml` uses maturin with
25
+ `bindings = "bin"`: the wheel ships the `slurmscope` executable and no Python module. The version comes from
26
+ `Cargo.toml` (semver; a pre-release such as `2.2.0-dev.1` is published as `2.2.0.dev1`, PEP 440, and `build.rs`
27
+ exposes the same form to `--version`). `PYPI.md` is the project description shown on PyPI.
31
28
 
32
29
  pip install "maturin>=1.5,<2" ziglang twine
33
- maturin build --release --zig --compatibility manylinux2014 --out dist # Linux x86_64, glibc >= 2.17
30
+ rustup target add aarch64-unknown-linux-gnu
31
+ maturin build --release --zig --compatibility manylinux2014 --out dist # x86_64
32
+ maturin build --release --zig --compatibility manylinux2014 --target aarch64-unknown-linux-gnu --out dist # aarch64
34
33
  maturin sdist --out dist # source: needs cargo to install
35
34
  twine check dist/*
36
- twine upload dist/slurmscope-2.2.0.dev1* # API token of the project
37
-
38
- Checks made on the artifacts before publishing: wheel contents (binary, metadata, license, SBOM
39
- only), highest glibc symbol version required (2.17), absence of the test-only probe, `twine check`,
40
- installation in a clean environment, `difftest.sh` and `test_process_parity.py` run against the
41
- binary installed from the wheel (`SLURMSCOPE_RS=<path>`), and installation of the sdist (build from
42
- source) in a clean environment. A version uploaded to PyPI can never be reused, even after deletion:
43
- bump `Cargo.toml` (e.g. `2.0.0-dev.2`) for every new upload.
35
+ twine upload dist/slurmscope-2.3.0* # API token of the project
36
+
37
+ Checks made on the artifacts before publishing: wheel contents (binary, metadata, license only), highest glibc
38
+ symbol version required (2.17), absence of the test-only probe, `twine check`, installation in a clean
39
+ environment, `difftest.sh` and `test_process_parity.py` run against the binary installed from the wheel
40
+ (`SLURMSCOPE_RS=<path>`), and installation of the sdist (build from source) in a clean environment. A version
41
+ uploaded to PyPI can never be reused, even after deletion: bump `Cargo.toml` for every new upload.
42
+
43
+ ## Pokémon thumbnails (Rust only)
44
+
45
+ When a job name is a Pokémon species (`Pikachu`, `Mr. Mime`, `Nidoran♀`, `★ Snorlax shiny ★`, case-insensitive),
46
+ a 3-column thumbnail (`SLOT_COLS`) is drawn before the name in the job lists (Overview "Jobs of", Jobs page, node details,
47
+ Killed jobs, job details, cancel confirmation). `p` turns them on and off at any time. Shiny names use the same sprite.
48
+
49
+ * **Images are not shipped** (copyright The Pokémon Company). On the first interactive start in a terminal with
50
+ images, a background thread downloads them with `curl` (`src/sprite_fetch.rs`): species list from PokeAPI, then
51
+ the Gen-7 menu icon of every species from the PokeAPI/sprites repository (default sprite when there is no icon),
52
+ each cropped to a centred square, all in one stored zip `~/.cache/slurmscope/sprites.zip` (~1025 entries, ~0.6 MB;
53
+ one file because chunked network filesystems charge a chunk per small file; temporary files in the system temp
54
+ directory). Thumbnails appear when it is ready (~1 min). No curl / no internet / < 90% of the sprites: no
55
+ thumbnails, `sprites.zip.failed` records the time and the download is retried after 24 h; `sprites.zip.lock`
56
+ keeps parallel instances from downloading twice. `--sprites-file ZIP` picks another archive;
57
+ `tools/fetch_sprites.py` builds the same archive by hand (e.g. on a machine with internet, then copy it).
58
+ * **Background.** Sprites are composited on the terminal's (or tmux's) default background, also on the selection
59
+ bar (iTerm2 shows transparent pixels as black inside tmux): `--sprite-bg '#RRGGBB'` / `SLURMSCOPE_SPRITE_BG`,
60
+ else the terminal's OSC 11 reply (not available through tmux < 3.3, which neither answers nor forwards it),
61
+ else tmux's `window-style` bg; unknown: transparent.
62
+ * **Size.** Each sprite is cropped to its opaque pixels and stands on the bottom of the slot; with 3 columns all
63
+ sprites reach ~93% of the row height (with 2, wide sprites were limited by the width: median x1.04, 90th
64
+ percentile x1.33 over the 1025 sprites).
65
+ * **Hopping**, as party icons in the games: two frames, 250 ms each: resting under a room of 8% of the sprite height
66
+ (the sprite fills ~93% of the row), and lifted by 10% (its top 2% cut) (`ROOM_PCT`, `HOP_PCT` in
67
+ `src/sprite_anim.rs`). Sprites are first enlarged (nearest neighbour) to >= 200 px so these percentages are
68
+ exact, not whole sprite pixels. The image
69
+ is padded to the exact proportions of its 3x1-cell box and stretched over it (`preserveAspectRatio=0`;
70
+ cell size from the tty when reported, else 1.44 = 3 columns : 1 row of Menlo/Monaco 12) so the background
71
+ covers all three cells; iTerm2 leaves the uncovered part of the box black. The animation is played by the terminal
72
+ itself (`src/sprite_anim.rs`): an animated GIF for iTerm2/WezTerm (own LZW encoder), animation frames for kitty.
73
+ Each image is sent once; slurmscope never redraws it while the slot
74
+ stays (iTerm2 outside tmux: the frame text skips the slot cells). Inside tmux: tmux re-sends a whole line to the
75
+ outer terminal whenever a program writes it (measured on tmux 3.2a by replaying the client output in an
76
+ emulator), erasing the image; so a line unchanged up to its last sprite is written only from after the sprite
77
+ (cursor move + SGR state), and images are re-sent when their line changed before them or tmux redrew the pane
78
+ (window switch, copy mode, zoom, re-attach; `tmux display`, at most once a second).
79
+ * **Automatic on/off.** On only in interactive mode, in a terminal with an image protocol:
80
+ - iTerm2 / WezTerm: OSC 1337 inline images (animated GIF);
81
+ - kitty / Ghostty: kitty graphics with Unicode placeholders (image sent once, placeholders in the text);
82
+ - Sixel (static sprite, no hop): any terminal whose DA1 reply lists attribute 4 (Windows Terminal, foot,
83
+ Konsole, xterm with Sixel, mlterm, contour, VS Code with `"terminal.integrated.enableImages": true`, off by
84
+ default); inside tmux only tmux >= 3.4, which stores Sixel images itself. Scaled to 3 cells x the row height
85
+ rounded down to whole 6-pixel bands (never reaches the next row), cell size from TIOCGWINSZ pixels, else
86
+ `CSI 16 t`, else 10x20.
87
+ - `SLURMSCOPE_SPRITES=iterm|kitty|sixel|off` forces a protocol where detection cannot work (e.g. VS Code
88
+ inside tmux < 3.4: tmux answers DA1 itself); inside tmux the images then go through passthrough.
89
+ Detection: `TERM`, `TERM_PROGRAM`, `LC_TERMINAL` (forwarded by iTerm2 over ssh), `KITTY_WINDOW_ID`, else the
90
+ terminal's XTVERSION / DA1 replies (0.5 s timeout). Inside tmux: the client's `#{client_termname}` or `LC_TERMINAL`,
91
+ images through DCS passthrough (tmux >= 3.3 needs `set -g allow-passthrough on`; off means feature off), with
92
+ absolute positions from `#{pane_top}`/`#{pane_left}`. Any other terminal: off. `--no-sprites` turns it off.
93
+ * `--once`, the probe build and every non-matching name are unchanged (byte-identical to Python): the slot is two
94
+ private-use code points that only the interactive loop replaces.
44
95
 
45
96
  ## Verification
46
97
 
@@ -138,6 +189,10 @@ are not a proof of functional equivalence on every input. Not verified, or verif
138
189
 
139
190
  ## Known differences (all deliberate or outside realistic input)
140
191
 
192
+ - **Keys (2.3.0, deliberate):** `p` toggles the Pokémon thumbnails instead of pausing the refresh; Space no longer
193
+ pauses; the help line of `p` and the footer key list say so (same lengths as before). The parity tests apply
194
+ exactly these changes to the Python reference (`tests/pyref.py`, textual patches that must match once).
195
+
141
196
  - **Integers beyond ±2⁶³** in Slurm fields (e.g. a priority `4987E46`) saturate at the i64 limit;
142
197
  Python keeps arbitrary precision. Slurm never prints such values.
143
198
  - **Inputs on which the Python version raises**, listed in `ALLOWED` of `parity_funcs.py` with the
@@ -5,7 +5,7 @@ build-backend = "maturin"
5
5
  [project]
6
6
  name = "slurmscope"
7
7
  dynamic = ["version"]
8
- description = "Live terminal dashboard for Slurm clusters - Rust implementation (pre-release)."
8
+ description = "Live terminal dashboard for Slurm clusters: queue, GPUs, QoS, nodes, memory and storage."
9
9
  readme = "PYPI.md"
10
10
  requires-python = ">=3.8"
11
11
  license = "MIT"
@@ -13,7 +13,7 @@ license-files = ["LICENSE"]
13
13
  authors = [{name = "Fabio Bozzoli"}]
14
14
  keywords = ["slurm", "hpc", "cluster", "gpu", "dashboard", "tui", "monitoring", "rust"]
15
15
  classifiers = [
16
- "Development Status :: 3 - Alpha",
16
+ "Development Status :: 4 - Beta",
17
17
  "Environment :: Console",
18
18
  "Intended Audience :: Science/Research",
19
19
  "Intended Audience :: System Administrators",
@@ -33,4 +33,4 @@ Issues = "https://github.com/FabioBozzoli/slurmscope/issues"
33
33
  bindings = "bin"
34
34
  # Release builds only; the test-only `probe` feature is never enabled here.
35
35
  profile = "release"
36
- include = [{ path = "LICENSE", format = "sdist" }, { path = "CHANGELOG.md", format = "sdist" }]
36
+ include = [{ path = "LICENSE", format = "sdist" }, { path = "CHANGELOG.md", format = "sdist" }, { path = "tools/fetch_sprites.py", format = "sdist" }]
@@ -1012,10 +1012,12 @@ impl App {
1012
1012
  _ => "guide",
1013
1013
  }, None)
1014
1014
  }
1015
- Ev::Char(' ' | 'p') => {
1016
- self.ctx.paused = !self.ctx.paused;
1017
- self.poll_now = !self.ctx.paused;
1018
- }
1015
+ // p: Pokémon sprites on/off (refresh pause removed, 2.3.0)
1016
+ Ev::Char('p') => match crate::sprites::toggle() {
1017
+ Some(true) => self.flash("Pokémon sprites on".into(), "ok"),
1018
+ Some(false) => self.flash("Pokémon sprites off".into(), "ok"),
1019
+ None => self.flash(crate::sprites::UNAVAILABLE.into(), "warn"),
1020
+ },
1019
1021
  Ev::Char('+' | '=') => self.set_interval(-1),
1020
1022
  Ev::Char('-' | '_') => self.set_interval(1),
1021
1023
  Ev::Char(c @ '1'..='5') => {
@@ -1296,7 +1298,7 @@ impl App {
1296
1298
  } else {
1297
1299
  match slurm_job_id(&j.id) {
1298
1300
  // validated before the confirmation is even shown
1299
- Ok(id) => self.confirm = Some((format!("Cancel job {} ({})?", id, j.name), id)),
1301
+ Ok(id) => self.confirm = Some((format!("Cancel job {} ({})?", id, crate::sprites::tag(&j.name)), id)),
1300
1302
  Err(e) => self.flash(e, "bad"),
1301
1303
  }
1302
1304
  }
@@ -1775,7 +1777,8 @@ impl App {
1775
1777
  Some("qos") => qos_label(&j.qos),
1776
1778
  Some(f) => job_field(j, f),
1777
1779
  };
1778
- let cell = pad(&clip(&value, cw), cw, spec.2);
1780
+ let sprite = if spec.4 == Some("name") { crate::sprites::name_cell(&j.name, cw) } else { None };
1781
+ let cell = pad(&sprite.unwrap_or_else(|| clip(&value, cw)), cw, spec.2);
1779
1782
  if spec.4 == Some("user") && j.user == me {
1780
1783
  c(cell, "me", true)
1781
1784
  } else if spec.4 == Some("state") {
@@ -2069,7 +2072,8 @@ impl App {
2069
2072
  let nodes = if r.nodes.is_empty() || r.nodes == "None assigned" { "-".to_string() } else { r.nodes.clone() };
2070
2073
  let cells = [r.end.replace('T', " "), r.id.clone(), r.by.clone(), nodes, r.name.clone()];
2071
2074
  table.push(format!(" {}", cells.iter().zip(&widths).enumerate().map(|(i, (v, &w))| {
2072
- c(pad(&clip(v, w), w, false), if i == 2 { "bad" } else if i == 0 { "dim" } else { "text" }, i == 2)
2075
+ let sprite = if i == 4 { crate::sprites::name_cell(v, w) } else { None };
2076
+ c(pad(&sprite.unwrap_or_else(|| clip(v, w)), w, false), if i == 2 { "bad" } else if i == 0 { "dim" } else { "text" }, i == 2)
2073
2077
  }).collect::<Vec<_>>().join(" ")));
2074
2078
  }
2075
2079
  out.push(String::new());
@@ -2552,7 +2556,7 @@ impl App {
2552
2556
  lines.push(format!("{:<19} {:<14} {:<16} {}", "END", "JOBID", "NODES", "NAME"));
2553
2557
  for r in &killed {
2554
2558
  let nodes = if r.nodes.is_empty() || r.nodes == "None assigned" { "-" } else { r.nodes.as_str() };
2555
- lines.push(format!("{:<19} {:<14} {:<16} {}", r.end.replace('T', " "), r.id, nodes, r.name));
2559
+ lines.push(format!("{:<19} {:<14} {:<16} {}", r.end.replace('T', " "), r.id, nodes, crate::sprites::tag(&r.name)));
2556
2560
  }
2557
2561
  }
2558
2562
  "budget" => {
@@ -2684,7 +2688,7 @@ impl App {
2684
2688
  " i QoS limits, users and pending reasons (in QoS browser)".into(),
2685
2689
  " B / E / D project budgets / session modules / AImageLab guide".into(),
2686
2690
  " P cycle partition filter (storage remains host/filesystem-wide)".into(),
2687
- " p / Space pause / resume refresh + / - refresh interval".into(),
2691
+ " p Pokémon sprites on / off + / - refresh interval".into(),
2688
2692
  String::new(),
2689
2693
  c("Lists (QoS, Jobs, Nodes)", "accent", true),
2690
2694
  format!(" {} j k PgUp PgDn g G move, page, top / bottom (mouse wheel and click work too)", a),
@@ -2742,7 +2746,7 @@ impl App {
2742
2746
  Some(Modal::Job { row, detail, err }) => (row.clone(), detail.clone().unwrap_or_default(), err.clone()),
2743
2747
  _ => unreachable!(),
2744
2748
  };
2745
- let title = format!("Job {} · {}", j.id, j.name);
2749
+ let title = format!("Job {} · {}", j.id, crate::sprites::tag(&j.name));
2746
2750
  let right = c(&j.state, state_color(&j.state), true);
2747
2751
  if let Some(e) = err {
2748
2752
  let mut body = vec![c(format!("{} {}", sym("warn"), e), "warn", false), String::new()];
@@ -2869,7 +2873,7 @@ impl App {
2869
2873
  for j in jobs.iter().skip(off).take(room) {
2870
2874
  let is_me = j.user == self.ctx.user;
2871
2875
  body.push(format!(" {} {} {} {} {} {} {}", pad(&j.id, 16, false),
2872
- if is_me { c(pad(&j.user, 12, false), "me", true) } else { pad(&j.user, 12, false) }, pad(&head(&j.name, 24), 24, false),
2876
+ if is_me { c(pad(&j.user, 12, false), "me", true) } else { pad(&j.user, 12, false) }, pad(&crate::sprites::name_cell(&j.name, 24).unwrap_or_else(|| head(&j.name, 24)), 24, false),
2873
2877
  c(pad(&j.state, 9, false), state_color(&j.state), false), pad(&j.elapsed, 10, true), pad(&j.gpus.to_string(), 3, true), pad(&j.cpus.to_string(), 4, true)));
2874
2878
  }
2875
2879
  if jobs.len() > off + room {
@@ -14,6 +14,9 @@ mod pyuni;
14
14
  mod render;
15
15
  mod share;
16
16
  mod slurm;
17
+ mod sprite_anim;
18
+ mod sprite_fetch;
19
+ mod sprites;
17
20
  mod storage;
18
21
  mod style;
19
22
  mod surfer;
@@ -103,6 +106,15 @@ struct Args {
103
106
  /// do not capture the mouse (keeps terminal text selection)
104
107
  #[arg(long)]
105
108
  no_mouse: bool,
109
+ /// no Pokémon thumbnails next to job names (default: on in terminals with an image protocol)
110
+ #[arg(long)]
111
+ no_sprites: bool,
112
+ /// background behind the thumbnails, #RRGGBB (default: asked to the terminal; also SLURMSCOPE_SPRITE_BG)
113
+ #[arg(long, value_name = "COLOR")]
114
+ sprite_bg: Option<String>,
115
+ /// sprite archive (default ~/.cache/slurmscope/sprites.zip, downloaded on the first run; p toggles the sprites)
116
+ #[arg(long, value_name = "ZIP")]
117
+ sprites_file: Option<String>,
106
118
  }
107
119
 
108
120
  /// argparse `type=float`: Python float() semantics (whitespace, underscores, any-script digits).
@@ -155,6 +167,99 @@ fn isatty(fd: RawFd) -> bool {
155
167
  }
156
168
 
157
169
  /// `shutil.get_terminal_size((120, 40))`.
170
+ /// Pokémon thumbnails: on only in a terminal with an image protocol. The archive is loaded, or on first run
171
+ /// downloaded in the background (the thumbnails appear when it is ready; no internet: no thumbnails).
172
+ fn setup_sprites(fd: RawFd, args: &Args, out: &mut impl Write, wake: Option<Arc<dyn Fn() + Send + Sync>>) {
173
+ let Some(path) = args.sprites_file.clone().or_else(sprites::default_archive) else { return };
174
+ let tmux = sprites::tmux_info();
175
+ let env = |k: &str| std::env::var(k).ok().filter(|v| !v.is_empty());
176
+ let forced = sprites::forced(env("SLURMSCOPE_SPRITES").as_deref());
177
+ let mut backend = match forced {
178
+ Some(b) => b,
179
+ None => sprites::detect(&env, tmux.as_ref(), None, false),
180
+ };
181
+ if backend.is_none() && forced.is_none() {
182
+ // Ask the terminal (inside tmux: tmux itself) its name (XTVERSION), cell size in pixels and DA1, which
183
+ // every terminal answers; attribute 4 of DA1 means Sixel.
184
+ let reply = query_terminal(fd, out, "\x1b[>0q\x1b[16t\x1b]11;?\x1b\\\x1b[c", 0.5);
185
+ if let Some(bg) = sprites::parse_osc11(&reply) {
186
+ sprites::set_default_bg(bg);
187
+ }
188
+ if let Some(cell) = sprites::parse_cell_size(&reply) {
189
+ sprites::set_cell_hint(cell);
190
+ }
191
+ let xt = if tmux.is_some() { None } else { sprites::parse_xtversion(&reply) };
192
+ backend = sprites::detect(&env, tmux.as_ref(), xt.as_deref(), sprites::parse_da1(&reply).contains(&4));
193
+ }
194
+ let Some(backend) = backend else { return };
195
+ sprites::configure(backend, tmux.as_ref());
196
+ // Background behind the sprites (iTerm2 shows transparent pixels as black inside tmux): --sprite-bg /
197
+ // SLURMSCOPE_SPRITE_BG, else OSC 11 (tmux < 3.3 neither answers nor forwards it), else tmux window-style.
198
+ if backend != sprites::Backend::Kitty {
199
+ let user = args.sprite_bg.clone().or_else(|| env("SLURMSCOPE_SPRITE_BG"));
200
+ if let Some(c) = user.as_deref().and_then(sprites::parse_color) {
201
+ sprites::set_default_bg(c);
202
+ } else {
203
+ let tmux_old = tmux.as_ref().map_or(false, |t| t.version < (3, 3));
204
+ if !tmux_old {
205
+ if let Some(bg) = sprites::parse_osc11(&query_terminal(fd, out, "\x1b]11;?\x1b\\\x1b[c", 0.5)) {
206
+ sprites::set_default_bg(bg);
207
+ }
208
+ }
209
+ if tmux.is_some() {
210
+ if let Some(bg) = sprites::tmux_window_bg() {
211
+ sprites::set_default_bg(bg);
212
+ }
213
+ }
214
+ }
215
+ }
216
+ if std::path::Path::new(&path).is_file() {
217
+ sprites::load(&path);
218
+ } else if sprite_fetch::may_try(std::path::Path::new(&path)) {
219
+ std::thread::spawn(move || {
220
+ if sprite_fetch::fetch(std::path::Path::new(&path)) && sprites::load(&path) {
221
+ if let Some(w) = wake {
222
+ w();
223
+ }
224
+ }
225
+ });
226
+ }
227
+ }
228
+
229
+ /// Write `query` and read the replies until a DA1 answer (`ESC [ ? ... c`) or `timeout` seconds.
230
+ fn query_terminal(fd: RawFd, out: &mut impl Write, query: &str, timeout: f64) -> Vec<u8> {
231
+ let _ = write!(out, "{}", query);
232
+ let _ = out.flush();
233
+ let end = util::monotonic() + timeout;
234
+ let mut got = Vec::new();
235
+ let mut buf = [0u8; 1024];
236
+ loop {
237
+ let left = end - util::monotonic();
238
+ if left <= 0.0 {
239
+ break;
240
+ }
241
+ let mut pfd = libc::pollfd { fd, events: libc::POLLIN, revents: 0 };
242
+ if unsafe { libc::poll(&mut pfd, 1, (left * 1000.0).ceil() as i32) } <= 0 {
243
+ break;
244
+ }
245
+ let n = unsafe { libc::read(fd, buf.as_mut_ptr() as *mut libc::c_void, buf.len()) };
246
+ if n <= 0 {
247
+ break;
248
+ }
249
+ got.extend_from_slice(&buf[..n as usize]);
250
+ if da1_done(&got) {
251
+ break;
252
+ }
253
+ }
254
+ got
255
+ }
256
+
257
+ fn da1_done(b: &[u8]) -> bool {
258
+ (0..b.len().saturating_sub(2)).any(|i| {
259
+ b[i..].starts_with(b"\x1b[?") && b[i + 3..].iter().position(|&c| !(c.is_ascii_digit() || c == b';')).map_or(false, |k| b[i + 3 + k] == b'c')
260
+ })
261
+ }
262
+
158
263
  fn terminal_size() -> (usize, usize) {
159
264
  let env = |k: &str| std::env::var(k).ok().and_then(|v| v.parse::<usize>().ok()).filter(|v| *v > 0);
160
265
  let (mut cols, mut lines) = (env("COLUMNS").unwrap_or(0), env("LINES").unwrap_or(0));
@@ -404,6 +509,12 @@ fn interactive(args: &Args, app: &mut App) {
404
509
  let mut next_poll = 0.0;
405
510
  let mut running = true;
406
511
  let mut buf = [0u8; 4096];
512
+ if !args.no_sprites {
513
+ setup_sprites(fd, args, &mut out, app.wake.clone());
514
+ }
515
+ let mut painter = sprites::Painter::default();
516
+ let mut last_size = (0, 0);
517
+ let mut last_generation = sprites::generation();
407
518
  while running && !TERMINATE.load(Ordering::Relaxed) {
408
519
  let now = util::monotonic();
409
520
  if app.poll_now || (!app.ctx.paused && now >= next_poll) {
@@ -413,7 +524,20 @@ fn interactive(args: &Args, app: &mut App) {
413
524
  }
414
525
  let (cols, lines) = terminal_size();
415
526
  let frame = app.frame(cols, lines);
416
- let _ = write!(out, "\x1b[H{}\x1b[K\x1b[J", frame.join("\x1b[K\n"));
527
+ if sprites::generation() != last_generation {
528
+ painter.reset(); // sprites toggled with p: everything is drawn again
529
+ last_generation = sprites::generation();
530
+ }
531
+ let screen = if sprites::active() {
532
+ if (cols, lines) != last_size {
533
+ painter.reset(); // resize or tmux re-attach: pane origin and kitty images may be gone
534
+ last_size = (cols, lines);
535
+ }
536
+ painter.paint(&frame)
537
+ } else {
538
+ sprites::plain_screen(&frame)
539
+ };
540
+ let _ = write!(out, "{}", screen);
417
541
  let _ = out.flush();
418
542
  let mut timeout = if app.ctx.paused { 1.0 } else { (next_poll - util::monotonic()).max(0.0) };
419
543
  if app.animating() {
@@ -441,7 +565,7 @@ fn interactive(args: &Args, app: &mut App) {
441
565
  next_poll = f64::min(next_poll, util::monotonic() + app.ctx.interval);
442
566
  }
443
567
  }
444
- let _ = write!(out, "{}\x1b[?25h\x1b[?1049l", mouse_off);
568
+ let _ = write!(out, "{}{}\x1b[?25h\x1b[?1049l", painter.cleanup(), mouse_off);
445
569
  let _ = out.flush();
446
570
  app.wake = None;
447
571
  WAKE_FD.store(-1, Ordering::SeqCst);
@@ -323,7 +323,7 @@ fn render_my_jobs(ctx: &Ctx, jobs: &[JobRef], width: usize, max_rows: usize) ->
323
323
  }
324
324
  d
325
325
  };
326
- let mut row = vec![pad(&j.id, idw, false), pad(&head(&j.name, namew), namew, false), pad(&c(&j.state, state_color(&j.state), false), statew, false)];
326
+ let mut row = vec![pad(&j.id, idw, false), pad(&crate::sprites::name_cell(&j.name, namew).unwrap_or_else(|| head(&j.name, namew)), namew, false), pad(&c(&j.state, state_color(&j.state), false), statew, false)];
327
327
  if !compact {
328
328
  row.insert(1, pad(&head(&j.part, partw), partw, false));
329
329
  }
@@ -409,7 +409,7 @@ fn render_users(ctx: &Ctx, jobs: &[JobRef], nodes: &[NodeRef], width: usize, top
409
409
  }
410
410
 
411
411
  pub fn render_footer(ctx: &Ctx, width: usize) -> String {
412
- let keys = "q quit p pause +/- interval";
412
+ let keys = "q quit p sprites +/- interval";
413
413
  let info = format!("refresh {}s · poll {} ms{}{}", crate::util::fmt_g(ctx.interval), ctx.poll_ms as i64, share_tag(), if ctx.paused { " · PAUSED" } else { "" });
414
414
  let left = c(keys, "dim", false);
415
415
  let right = c(info, if ctx.paused { "bad" } else { "dim" }, ctx.paused);