Skip to content

Commit 1015fe6

Browse files
committed
Updated LocalLab v0.2.2
1 parent 51d8d75 commit 1015fe6

File tree

5 files changed

+49
-24
lines changed

5 files changed

+49
-24
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
All notable changes for version updates.
44

5+
## [0.2.2] - 2025-03-03
6+
7+
### Fixed
8+
9+
- Fixed circular import issue between core/app.py and routes/system.py by updating system.py to use get_request_count from logger module directly
10+
- Made Flash Attention warning less alarming by changing it from a warning to an info message with better explanation
11+
- Enhanced get_system_info endpoint with cleaner code and better organization
12+
- Fixed potential issues with GPU info retrieval through better error handling
13+
514
## [0.2.0] - 2025-03-02
615

716
### Added

locallab/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
LocalLab - A lightweight AI inference server
33
"""
44

5-
__version__ = "0.2.1"
5+
__version__ = "0.2.2"
66

77
from typing import Dict, Any, Optional
88

locallab/model_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def __init__(self):
5252
import flash_attn
5353
logger.info("Flash Attention enabled")
5454
except ImportError:
55-
logger.warning("Flash Attention not available")
55+
logger.info("Flash Attention not available - this is optional and won't affect basic functionality")
5656

5757
def _get_quantization_config(self) -> Optional[Dict[str, Any]]:
5858
"""Get quantization configuration based on settings"""

locallab/routes/system.py

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
import torch
1111

1212
from ..logger import get_logger
13-
from ..core.app import model_manager, request_count, start_time
13+
from ..logger.logger import get_request_count, get_uptime_seconds
14+
from ..core.app import model_manager, start_time
1415
from ..ui.banners import print_system_resources
1516
from ..config import system_instructions
1617

@@ -50,6 +51,24 @@ def get_gpu_memory() -> Optional[Tuple[int, int]]:
5051
return None
5152

5253

54+
def get_gpu_info() -> Optional[Dict[str, Any]]:
55+
"""Get detailed GPU information including memory and device name"""
56+
try:
57+
gpu_mem = get_gpu_memory()
58+
if gpu_mem:
59+
total_gpu, free_gpu = gpu_mem
60+
return {
61+
"total_memory": total_gpu,
62+
"free_memory": free_gpu,
63+
"used_memory": total_gpu - free_gpu,
64+
"device": torch.cuda.get_device_name(0)
65+
}
66+
return None
67+
except Exception as e:
68+
logger.debug(f"Failed to get GPU info: {str(e)}")
69+
return None
70+
71+
5372
@router.post("/system/instructions")
5473
async def update_system_instructions(request: SystemInstructionsRequest) -> Dict[str, str]:
5574
"""Update system instructions"""
@@ -84,35 +103,32 @@ async def reset_system_instructions(model_id: Optional[str] = None) -> Dict[str,
84103

85104

86105
@router.get("/system/info", response_model=SystemInfoResponse)
87-
async def system_info() -> SystemInfoResponse:
88-
"""Get detailed system information"""
106+
async def get_system_info():
107+
"""Get system information including CPU, memory, GPU usage, and server stats"""
89108
try:
90-
cpu_usage = psutil.cpu_percent()
109+
# Get CPU and memory usage
110+
cpu_percent = psutil.cpu_percent()
91111
memory = psutil.virtual_memory()
92-
gpu_info = None
112+
memory_percent = memory.percent
93113

94-
if torch.cuda.is_available():
95-
gpu_mem = get_gpu_memory()
96-
if gpu_mem:
97-
total_gpu, free_gpu = gpu_mem
98-
gpu_info = {
99-
"total_memory": total_gpu,
100-
"free_memory": free_gpu,
101-
"used_memory": total_gpu - free_gpu,
102-
"device": torch.cuda.get_device_name(0)
103-
}
114+
# Get GPU info if available
115+
gpu_info = get_gpu_info() if torch.cuda.is_available() else None
104116

117+
# Get server stats
118+
uptime = time.time() - start_time
119+
120+
# Return combined info
105121
return SystemInfoResponse(
106-
cpu_usage=cpu_usage,
107-
memory_usage=memory.percent,
122+
cpu_usage=cpu_percent,
123+
memory_usage=memory_percent,
108124
gpu_info=gpu_info,
109125
active_model=model_manager.current_model,
110-
uptime=time.time() - start_time,
111-
request_count=request_count
126+
uptime=uptime,
127+
request_count=get_request_count() # Use the function from logger.logger instead
112128
)
113129
except Exception as e:
114-
logger.error(f"Failed to get system info: {str(e)}")
115-
raise HTTPException(status_code=500, detail=str(e))
130+
logger.error(f"Error getting system info: {str(e)}")
131+
raise HTTPException(status_code=500, detail=f"Error getting system info: {str(e)}")
116132

117133

118134
@router.get("/health")

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name="locallab",
8-
version="0.2.1",
8+
version="0.2.2",
99
packages=find_packages(include=["locallab", "locallab.*"]),
1010
install_requires=[
1111
"fastapi>=0.68.0,<1.0.0",

0 commit comments

Comments
 (0)