Skip to content

Studio: show the models drive in the Live Monitor when it is not the system disk - #12724

Merged
danielhanchen merged 9 commits into
mainfrom
studio-live-monitor-models-disk
Oct 5, 2026
Merged

danielhanchen merged 9 commits into
mainfrom
studio-live-monitor-models-disk

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Fixes #9259. Supersedes #9261 (thanks @yzxcj797 for the first pass).

Problem

Settings > Resources > Live Monitor and the Storage section read only the root filesystem. When the Hugging Face cache is symlinked to, or configured on, another drive, Studio never shows the drive that actually holds the models.

Change

  • studio/backend/utils/system_disk.py: models_disk_usage() resolves the active hub cache (get_hf_cache_paths(), so the Models folder setting and HF_HUB_CACHE are honoured) through os.path.realpath and measures that volume. It returns None when the cache is on the same device as /, or on a volume sharing /'s pool (APFS Data volume on macOS, btrfs subvolumes such as Fedora's /home: own st_dev, same size and free space), so single-disk hosts see no change. A cache folder that does not exist yet is measured at its nearest existing parent; an unreadable one is omitted.
  • The reading runs on a background thread keyed on the unresolved Models folder setting (one probe per folder, refreshed every 30 s, the request waits at most 0.5 s), so a hung NFS/SMB cache never stalls the 3 s Resources poll. The folder lookup climbs only past paths that are genuinely missing (on Windows confirmed with _absence_is_real), so an unreadable cache is omitted rather than reported as its parent volume.
  • /api/system gains an additive models_disk field (total_gb, free_gb, percent_used, or null). disk stays the system disk, unchanged. No host paths are returned.
  • Frontend: when models_disk is set, the Live Monitor shows a separate "Models disk" tile next to "Disk", and Storage shows a "Models disk" row under "System disk". Each drive keeps its own numbers instead of being summed into one bar.

Testing

  • studio/backend/tests/test_models_disk_usage.py: symlinked cache on a second drive, missing cache dir behind a symlink, cache on the system disk, shared APFS/btrfs pool, cache not created yet, unreadable cache (real chmod 000), a hung probe never blocking the poll, switching away from a hung folder, and (on GitHub-hosted Linux / macOS runners) the real home cache resolving to the system disk. Each functional line was reverted in a scratch copy and fails at least one test.
  • Real /api/system call on a host whose HF cache is on a separate volume: disk 2079 GB (59.4% used), models_disk 30397 GB (77.2% used).
  • npm run typecheck clean; eslint and biome report the same pre-existing findings as main.

Screenshots

Settings > System, host with the HF cache on a separate volume. Live Monitor:

Live Monitor before and after

Storage section:

Storage before and after

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-05T09:06:18.751278Z 83edc74 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen

Copy link
Copy Markdown
Member Author

Both red checks are from this PR, not main:

  1. Frontend unit tests (system-status-verdict.test.ts:140, "no tile fabricates a usage percentage for a host it has not read"): the test counts the <MetricTile ... /> elements in resources-tab.tsx and expects 4; the new models-disk tile makes it 5. The count is there so the per-tile check below it cannot pass by matching nothing, so bump it to 5 and make sure the new tile's percent is gated the same way (hostUnread ? null : ...), since the loop asserts that for every tile.
  2. Frontend build + bundle sanity: the strict i18n check reports settings.resources.liveMonitor.modelsDisk and settings.resources.storage.modelsDisk missing from every locale overlay (only en.ts has them). Add them to the other locales.

@danielhanchen danielhanchen self-assigned this Oct 5, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 5, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 9b62809ef6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 5, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 5, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 5, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dfb10c6c7f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +50 to +51
if usage.total == system.total and abs(usage.free - system.free) < _SAME_POOL_SLACK:
return None

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Do not identify shared pools from capacity alone

When the models cache is on a separate disk with the same formatted capacity as the system disk and its free space differs by less than 1 GiB—for example, two newly formatted identical drives—this condition misclassifies the disks as one APFS/btrfs pool and suppresses the new models-disk display. Equal total and similar free values do not establish shared backing storage, so this heuristic needs to be limited to a platform/filesystem where pool sharing can actually be established.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs two drives with identical capacity and free space within 1 GiB, and the miss only falls back to the pre-PR display (system disk alone). Keeping the heuristic: it is what stops every Mac and Fedora btrfs host from showing a duplicate tile.

Comment on lines +321 to +324
const modelsDisk = systemInfo.models_disk ?? null;
const modelsDiskUsed = modelsDisk
? Math.max(0, modelsDisk.total_gb - modelsDisk.free_gb)
: 0;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Refresh models-disk data after changing the models folder

When Live updates is disabled, saving a new Models folder updates hfCache but never invalidates or force-refreshes the globally cached systemInfo, so this value continues describing the previous cache volume. Closing and reopening the tab does not reliably fix it because useSystemInfo reuses cachedSystem for non-polled reads; the new row can therefore remain absent or show the old drive until some unrelated forced system fetch or a reload occurs.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With Live updates off every Resources reading is a snapshot by design; System disk, RAM and VRAM behave the same way. Turning Live updates on or reopening Settings after a reload refreshes it.

danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 5, 2026
chatgpt-codex-connector[bot]

This comment was marked as resolved.

danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 5, 2026
chatgpt-codex-connector[bot]

This comment was marked as resolved.

danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 5, 2026
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 5, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 5, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 5, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 5, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 5, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 5, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 5, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 5, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 5, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 83edc74977

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


def _probe(key: str) -> None:
# Resolving the configured path can block on the same dead mount, so it happens here.
reading = models_disk_usage()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Measure the cache path captured by each probe

If the Models folder changes after cached_models_disk_usage() captures its key but before this worker resolves _hub_cache(), the worker measures the new folder and stores that reading under the old folder's key. Switching back to the old folder within the 30-second TTL then returns the new drive's capacity without re-probing; pass a path snapshot associated with key into the worker so every cached reading describes its own key.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs the Models folder to change in the microseconds between the key read and the worker's resolve, then be switched back within 30 s; the worst case is one stale reading for at most one TTL. Below the bar.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 83edc74977

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit aec4558 into main Oct 5, 2026
@danielhanchen
danielhanchen deleted the studio-live-monitor-models-disk branch October 5, 2026 09:37
danielhanchen added a commit that referenced this pull request Oct 5, 2026
…12749)

#12724 added a models-disk tile and storage row with two new keys in en.ts only, so
the strict i18n parity step in Frontend build + bundle sanity fails on main. Its fifth
MetricTile also broke system-status-verdict.test.ts, which asserted exactly four.

Add settings.resources.liveMonitor.modelsDisk and settings.resources.storage.modelsDisk
to every locale overlay. Replace the fixed tile count with: at least the four fixed
tiles, and every <MetricTile> opening tag captured whole, so the per-tile percentage
check still covers every tile, including the conditional one.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] reflect symlinked model storage on secondary drives for Live Monitor disk usage

1 participant