Coverage for openhcs/textual_tui/services/config_cache_adapter.py: 0.0%

23 statements  

« prev     ^ index     » next       coverage.py v7.10.3, created at 2025-08-14 05:57 +0000

1""" 

2TUI-specific adapter for unified configuration cache. 

3 

4Provides async interface compatible with existing TUI code. 

5""" 

6 

7from openhcs.core.config_cache import ( 

8 load_cached_global_config, 

9 get_global_config_cache, 

10 AsyncExecutionStrategy 

11) 

12from openhcs.core.config import GlobalPipelineConfig 

13 

14# Re-export with TUI-specific strategy 

15async def load_cached_global_config_tui() -> GlobalPipelineConfig: 

16 """Load cached config with async strategy for TUI.""" 

17 return await load_cached_global_config(AsyncExecutionStrategy()) 

18 

19 

20def get_tui_config_cache(): 

21 """Get config cache with async strategy for TUI.""" 

22 return get_global_config_cache(AsyncExecutionStrategy()) 

23 

24 

25# Additional TUI-specific functions for backward compatibility 

26async def save_global_config_to_cache(config: GlobalPipelineConfig) -> bool: 

27 """Save global config to cache (TUI compatibility).""" 

28 cache = get_tui_config_cache() 

29 return await cache.save_config_to_cache(config) 

30 

31 

32async def clear_global_config_cache() -> bool: 

33 """Clear the global config cache (TUI compatibility).""" 

34 cache = get_tui_config_cache() 

35 return await cache.clear_cache() 

36 

37 

38def get_global_config_cache_info() -> dict: 

39 """Get information about the global config cache (TUI compatibility).""" 

40 cache = get_tui_config_cache() 

41 info = { 

42 "cache_file": str(cache.cache_file), 

43 "exists": cache.cache_file.exists(), 

44 "size": None, 

45 "modified": None 

46 } 

47 

48 if info["exists"]: 

49 try: 

50 stat = cache.cache_file.stat() 

51 info["size"] = stat.st_size 

52 info["modified"] = stat.st_mtime 

53 except Exception: 

54 pass 

55 

56 return info