Skip to content

fix(quicklook): keep a history for gpu_mem and gpu_proc - #3744

Merged
nicolargo merged 2 commits into
nicolargo:developfrom
sprayberry-code:fix/quicklook-gpu-sparkline-history
Sep 26, 2026
Merged

nicolargo merged 2 commits into
nicolargo:developfrom
sprayberry-code:fix/quicklook-gpu-sparkline-history

Conversation

@askalf

@askalf askalf commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • gpu_mem and gpu_proc are in quicklook's AVAILABLE_STATS_LIST, so [quicklook] list=cpu,gpu_mem is a valid config. But they were never added to items_history_list, which means no history is kept for them.
  • With --sparkline (or the S hotkey), _msg_cpu builds each sparkline from self.get_raw_history(item=key, ...). For a key with no history that returns None, and the list comprehension over it raises TypeError: 'NoneType' object is not iterable, which exits the curses UI. This is standalone mode; the #1881 client-mode path is already gated by not self.args.client.
  • Fix: two entries appended to items_history_list in glances/plugins/quicklook/__init__.py, in the same shape as the five existing ones.
  • Regression tests: 6 tests, all currently on the branch, in the existing tests/test_plugin_quicklook.py TestQuicklookGpuHistory class (3 parametrized functions x {gpu_mem, gpu_proc}). All 6 fail on base and pass with the fix.
$ git checkout origin/develop -- glances/plugins/quicklook/__init__.py  # base
$ PYTHONPATH=. python repro_sparkline_gpu.py
  File "/agent-workspace/oss/glances-wt-verify-breaker/glances/plugins/quicklook/__init__.py", line 317, in _msg_cpu
    data[key].percents = [i[1] for i in self.get_raw_history(item=key, nb=data[key].size)]
                                        ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not iterable
$ # fix applied
$ python -m pytest tests/test_plugin_quicklook.py -k GpuHistory -v
tests/test_plugin_quicklook.py::TestQuicklookGpuHistory::test_the_gpu_entries_are_historised[gpu_mem-expected0] PASSED [ 16%]
tests/test_plugin_quicklook.py::TestQuicklookGpuHistory::test_the_gpu_entries_are_historised[gpu_proc-expected1] PASSED [ 33%]
tests/test_plugin_quicklook.py::TestQuicklookGpuHistory::test_a_gpu_entry_is_drawn_as_a_sparkline_of_its_history[gpu_mem-expected0] PASSED [ 50%]
tests/test_plugin_quicklook.py::TestQuicklookGpuHistory::test_a_gpu_entry_is_drawn_as_a_sparkline_of_its_history[gpu_proc-expected1] PASSED [ 66%]
tests/test_plugin_quicklook.py::TestQuicklookGpuHistory::test_a_gpu_entry_is_historised_even_when_not_in_the_list[gpu_mem-expected0] PASSED [ 83%]
tests/test_plugin_quicklook.py::TestQuicklookGpuHistory::test_a_gpu_entry_is_historised_even_when_not_in_the_list[gpu_proc-expected1] PASSED [100%]
======================= 6 passed, 22 deselected in 0.10s =======================

Decisions

The change uses the project’s existing implementation path and adds a focused regression test; broader unrelated behavior remains out of scope.

Not run: no checks beyond the staged PR evidence were run during submission.

AI assistance: this bug was found and the fix and tests were drafted with AI tooling in my workflow; the tests and checks above were executed as pasted. I'm responsible for the change and will handle review feedback.

`gpu_mem` and `gpu_proc` are selectable in `[quicklook] list=` but were
never added to `items_history_list`, so `get_raw_history()` returns None
for them. With --sparkline, `_msg_cpu` iterates over that None and the
curses UI exits with "'NoneType' object is not iterable".
History is per plugin, not per displayed stat: a GPU entry keeps
building history while list= omits it, exactly like swap today.
@nicolargo
nicolargo merged commit 43cecf7 into nicolargo:develop Sep 26, 2026
1 of 3 checks passed
@nicolargo nicolargo added this to the Glances 4.5.7 milestone Sep 26, 2026
@nicolargo

Copy link
Copy Markdown
Owner

Thanks for the PR @askalf

Merged into develop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants