You've already forked FrameTour-RenderWorker
feat(render): 实现渲染系统v2核心架构
- 添加v2支持的任务类型常量定义 - 更新软件版本至0.0.9 - 定义v2统一音视频编码参数 - 实现系统信息工具get_sys_info_v2方法 - 新增get_capabilities和_get_gpu_info功能 - 创建core模块及TaskHandler抽象基类 - 添加渲染系统设计文档包括集群架构、v2 PRD和Worker PRD - 实现任务处理器抽象基类及接口规范
This commit is contained in:
@@ -1,14 +1,24 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
系统信息工具
|
||||
|
||||
提供系统信息采集功能。
|
||||
"""
|
||||
|
||||
import os
|
||||
import platform
|
||||
from datetime import datetime
|
||||
|
||||
import psutil
|
||||
from constant import SUPPORT_FEATURE, SOFTWARE_VERSION
|
||||
from constant import SUPPORT_FEATURE, SOFTWARE_VERSION, V2_DEFAULT_CAPABILITIES
|
||||
|
||||
|
||||
def get_sys_info():
|
||||
"""
|
||||
Returns a dictionary with system information.
|
||||
获取系统信息(v1 格式)
|
||||
|
||||
Returns:
|
||||
dict: 系统信息字典
|
||||
"""
|
||||
info = {
|
||||
'version': SOFTWARE_VERSION,
|
||||
@@ -22,3 +32,65 @@ def get_sys_info():
|
||||
'support_feature': SUPPORT_FEATURE
|
||||
}
|
||||
return info
|
||||
|
||||
|
||||
def get_sys_info_v2():
|
||||
"""
|
||||
获取系统信息(v2 格式)
|
||||
|
||||
Returns:
|
||||
dict: v2 API 所需的系统信息字典
|
||||
"""
|
||||
mem = psutil.virtual_memory()
|
||||
|
||||
info = {
|
||||
'os': platform.system(),
|
||||
'cpu': f"{os.cpu_count()} cores",
|
||||
'memory': f"{mem.total // (1024**3)}GB",
|
||||
'cpuUsage': f"{psutil.cpu_percent()}%",
|
||||
'memoryAvailable': f"{mem.available // (1024**3)}GB",
|
||||
'platform': platform.system(),
|
||||
'pythonVersion': platform.python_version(),
|
||||
}
|
||||
|
||||
# 尝试获取 GPU 信息
|
||||
gpu_info = _get_gpu_info()
|
||||
if gpu_info:
|
||||
info['gpu'] = gpu_info
|
||||
|
||||
return info
|
||||
|
||||
|
||||
def get_capabilities():
|
||||
"""
|
||||
获取 Worker 支持的能力列表
|
||||
|
||||
Returns:
|
||||
list: 能力列表
|
||||
"""
|
||||
return V2_DEFAULT_CAPABILITIES.copy()
|
||||
|
||||
|
||||
def _get_gpu_info():
|
||||
"""
|
||||
尝试获取 GPU 信息
|
||||
|
||||
Returns:
|
||||
str: GPU 信息,失败返回 None
|
||||
"""
|
||||
try:
|
||||
import subprocess
|
||||
# 尝试使用 nvidia-smi
|
||||
result = subprocess.run(
|
||||
['nvidia-smi', '--query-gpu=name', '--format=csv,noheader'],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=5
|
||||
)
|
||||
if result.returncode == 0:
|
||||
gpu_name = result.stdout.strip().split('\n')[0]
|
||||
return gpu_name
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user