Enhance error handling and state management in access card and session modules
- Updated the `render_access_panel` function to conditionally hide LLM errors when the Ollama model is operational, improving user experience by reducing unnecessary error visibility. - Introduced a new `_notes_from_disk` function to streamline the retrieval of notes from disk, enhancing state management during GPU environment checks. - Refactored error handling in the `_bind_access` function to ensure that stack and GPU environment errors are accurately recorded and managed, improving robustness in session state updates. - Added tests to validate the new behavior of error handling and state management, ensuring that LLM errors are appropriately suppressed when conditions are met.
This commit is contained in:
@@ -42,3 +42,27 @@ def test_access_panel_red_when_killer_failed(monkeypatch):
|
||||
)
|
||||
panel = render_access_panel(_Cfg(), tunneled=True)
|
||||
assert panel.border_style == "red"
|
||||
|
||||
|
||||
def test_access_panel_hides_stale_llm_error_when_ollama_ok(monkeypatch):
|
||||
monkeypatch.setattr(
|
||||
"gpu_rent.access_card.load_state",
|
||||
lambda: type(
|
||||
"S",
|
||||
(),
|
||||
{
|
||||
"notes": {
|
||||
"llm_error": "Ollama /api/tags без моделей",
|
||||
"stack_vm": [
|
||||
{
|
||||
"name": "ollama",
|
||||
"ok": True,
|
||||
"detail": "1 models (huihui_ai/qwen2.5-vl-abliterated:7b)",
|
||||
}
|
||||
],
|
||||
}
|
||||
},
|
||||
)(),
|
||||
)
|
||||
panel = render_access_panel(_Cfg(), tunneled=True)
|
||||
assert panel.border_style != "red"
|
||||
|
||||
Reference in New Issue
Block a user