make detect_disk_metrics stateless

This commit is contained in:
harisreedhar
2026-02-09 15:47:38 +05:30
committed by henryruhs
parent c527673846
commit d83659ae96
2 changed files with 28 additions and 21 deletions
+27 -20
View File
@@ -1,5 +1,7 @@
import shutil
from typing import List
from facefusion import state_manager
from facefusion.execution import detect_execution_devices
from facefusion.types import DiskMetrics, Metrics
@@ -8,28 +10,33 @@ def get_metrics_set() -> Metrics:
return\
{
'execution_devices': detect_execution_devices(),
'disk': detect_disk_metrics()
'disks': detect_disk_metrics([ state_manager.get_temp_path() ])
}
def detect_disk_metrics() -> DiskMetrics:
usage = shutil.disk_usage('.')
def detect_disk_metrics(drive_paths : List[str]) -> List[DiskMetrics]:
disk_metrics : List[DiskMetrics] = []
return\
{
'total':
for drive_path in drive_paths:
disk_usage = shutil.disk_usage(drive_path)
disk_metrics.append(
{
'value': int(usage.total / (1024 * 1024 * 1024)),
'unit': 'GiB'
},
'free':
{
'value': int(usage.free / (1024 * 1024 * 1024)),
'unit': 'GiB'
},
'utilization':
{
'value': int(usage.used / usage.total * 100),
'unit': '%'
}
}
'total':
{
'value': int(disk_usage.total / (1024 * 1024 * 1024)),
'unit': 'GiB'
},
'free':
{
'value': int(disk_usage.free / (1024 * 1024 * 1024)),
'unit': 'GiB'
},
'utilization':
{
'value': int(disk_usage.used / disk_usage.total * 100),
'unit': '%'
}
})
return disk_metrics
+1 -1
View File
@@ -307,7 +307,7 @@ DiskMetrics = TypedDict('DiskMetrics',
Metrics = TypedDict('Metrics',
{
'execution_devices' : List[ExecutionDevice],
'disk' : DiskMetrics
'disks' : List[DiskMetrics]
})
DownloadProvider = Literal['github', 'huggingface']