Repository navigation
Studio: stop two lines repeating in the server log for the whole session - #8306
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8122b9bdcc
ℹ️ 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".
| if hub_bars_off: | ||
| try: | ||
| from huggingface_hub.utils import disable_progress_bars | ||
| disable_progress_bars() |
There was a problem hiding this comment.
Do not restore a stale Hub progress state
With the optional helper pre-cache enabled, main.py starts that background thread before the post-warm embedder thread; the helper temporarily disables Hub progress bars and reenables them in its finally. If this context snapshots that temporary disabled state and the helper finishes before the embedding load, this block disables Hub bars again after the helper has restored them, leaving progress globally disabled for later downloads. The Hub state restoration needs synchronization with other users or a mechanism that does not overwrite changes made while the context was active.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
I looked at this one and left it. The snapshot is only taken when this context also disables the transformers flag, and the worst outcome of losing the race is that Hub bars stay off in a server process that has no terminal and whose download progress already reaches the UI as hub_download_progress events. Adding cross-thread synchronization around a global cosmetic setting would cost more than the failure it prevents.
…w transformers output out of the log
…Hub state Re-emit captured reports from a finally so a load that raises still reports MISSING or MISMATCH; capture only records from the loading thread, since the filters sit on process-global loggers; snapshot and restore the Hub progress setting separately, because transformers' enable_progress_bar() also enables the Hub's.
An UNEXPECTED key other than embeddings.position_ids can change retrieval, so it stays a warning; adapter-backed embedding models report through transformers.integrations.peft, which now gets the same filter.
A report listing the legacy buffer and a discarded learned weight was treated as benign because position_ids appeared somewhere in the table.
transformers appends a Notes section explaining each status, so the UNEXPECTED note line was read as a key row and made every unexpected report serious. The test helper now restores propagate and level on the process-global loggers.
42fd452 to
c1c2a11
Compare
…tests This module logs through the stdlib logger, so a serious report was re-emitted with its ANSI escapes and newlines intact; it is stripped and flattened now. The once-only announcement check is under a lock, and the tests snapshot and restore both process-global progress-bar switches.
encoder.position_ids_projection.weight is a real discarded weight; the key column is parsed and only embeddings.position_ids, optionally under a module prefix, is exempt.
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Summary
Two lines dominate a normal Studio session's log and neither carries information after its first appearance: the model-defaults resolution, which repeats for as long as a browser tab is open, and the raw transformers weight-load output from the RAG embedder, which is unstructured ANSI text in an otherwise JSON log. Both are quieted the way #7087 and #7869 did it: the signal is kept, the repetition is not.
1. "Loaded default model defaults from ..." repeats every poll
GET /api/inference/statusis polled every 5s for as long as the app is open. It callsload_inference_config->load_model_defaults, which logs the resolved config path at info on every call. The path never changes, so the line just repeats.Measured on one machine from
logs/studio_a.log, counting only that event:The four-tab number is the interesting one: every open tab polls independently, so the line scales with tabs and made up the largest single share of non-access events.
_log_model_defaultsnow announces each(model, resolved path)once at info and drops later repeats to debug, so--verboseandLOG_LEVEL=debugstill show every one. The set is bounded (4096 entries, cleared on overflow) so a long-lived server with many models cannot grow it without end. This covers all four resolution branches plus the "No default config found" warning, which had the same repeat problem.Deliberately not a cache: the returned dict is unchanged and the file is still read every call, so editing a YAML under
assets/configs/model_defaults/during development still takes effect immediately. Only the logging is deduplicated.2. Raw transformers output on every boot
Loading the RAG embedder (
unsloth/bge-small-en-v1.5,core/rag/embeddings.py) writes this to stdout on every single boot:That is 7 lines, one of them a tqdm progress bar and one carrying ANSI colour codes, in a log whose every other line is JSON. It fires unconditionally because bge-small-en-v1.5 ships a legacy
embeddings.position_idskey that the currentBertModeldoes not expect, so the report is identical every time. transformers >= 5 emits it throughlogger.warning(transformers/utils/loading_report.py), notprint, so a filter can reach it, the same technique as the existing_DropTorchDtypeDeprecationinloggers/config.py._quiet_transformers_load()wraps only that one load and:LOAD REPORTrecord instead of letting it print, then re-emits it on our own logger, at debug when it reports only UNEXPECTED keys and at warning if it ever mentions MISSING, MISMATCH or CONVERSION;Nothing is lost.
embeddings.pyalready logsloading embedding model <name> on <device>at info, which is the line that actually says what happened, and a report that could change the model's behaviour is promoted rather than hidden.Measured directly by loading the embedder in a subprocess with and without the change: 7 lines of tqdm and report before, 0 after.
What stays logged
loading embedding model ... on ..., unchanged.Tests
studio/backend/tests/test_model_defaults_log_once.py(5 cases): the repeat logs once at info, the repeats are still emitted at debug, a second model gets its own announcement, the announced set stays bounded, and the returned config is unaffected.studio/backend/tests/test_embedding_load_report_quiet.py(6 cases): the report is swallowed and captured, unrelated transformers warnings still pass through, MISSING is flagged serious, the filter is removed after the context, and the progress-bar setting is restored both when it was on and when the caller had already turned it off.Related suites, all green on this branch:
test_rag_embeddings,test_embedding_model_settings,test_embedding_model_security_gate,test_offline_embedding_minimal,test_model_defaults_none_guard,test_kimi_k3_reasoning_defaults,test_models_get_model_config_case_resolution,test_logging_middlewareplus the two new files: 163 passed, 1 skipped.