Coverage for src/lilbee/modelhub/install_state.py: 100%

14 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-11-06 08:17 +0000

1"""The single definition of where a native model ref loads from.""" 

2 

3from __future__ import annotations 

4 

5from enum import StrEnum 

6 

7from lilbee.modelhub.registry import ModelRegistry 

8from lilbee.providers.model_ref import is_loose_model_file 

9 

10 

11class InstallState(StrEnum): 

12 """Where a native model ref loads from.""" 

13 

14 REGISTERED = "registered" 

15 LOOSE_FILE = "loose_file" 

16 MISSING = "missing" 

17 

18 

19def install_state(ref: str, registry: ModelRegistry) -> InstallState: 

20 """Where *ref* loads from: a registry manifest, a loose GGUF file, or nowhere. 

21 

22 A loose file loads in the TUI, the CLI, the fleet and the HTTP chat routes, 

23 but no model listing shows it. 

24 """ 

25 if registry.is_installed(ref): 

26 return InstallState.REGISTERED 

27 if is_loose_model_file(ref): 

28 return InstallState.LOOSE_FILE 

29 return InstallState.MISSING