refactor: remove unnecessary single-element loop in disk usage calc
The 'for pattern in [f"hermes-*{task_id[:8]}*"]' was a loop over a
single-element list — just use a plain variable instead.
This commit is contained in:
parent
6d2481ee5c
commit
8c48bb080f
1 changed files with 9 additions and 10 deletions
|
|
@ -638,19 +638,18 @@ def get_active_environments_info() -> Dict[str, Any]:
|
||||||
"workdirs": {},
|
"workdirs": {},
|
||||||
}
|
}
|
||||||
|
|
||||||
# Calculate total disk usage
|
# Calculate total disk usage (per-task to avoid double-counting)
|
||||||
total_size = 0
|
total_size = 0
|
||||||
for task_id in _active_environments.keys():
|
for task_id in _active_environments.keys():
|
||||||
# Check sandbox and workdir sizes
|
|
||||||
scratch_dir = _get_scratch_dir()
|
scratch_dir = _get_scratch_dir()
|
||||||
for pattern in [f"hermes-*{task_id[:8]}*"]:
|
pattern = f"hermes-*{task_id[:8]}*"
|
||||||
import glob
|
import glob
|
||||||
for path in glob.glob(str(scratch_dir / pattern)):
|
for path in glob.glob(str(scratch_dir / pattern)):
|
||||||
try:
|
try:
|
||||||
size = sum(f.stat().st_size for f in Path(path).rglob('*') if f.is_file())
|
size = sum(f.stat().st_size for f in Path(path).rglob('*') if f.is_file())
|
||||||
total_size += size
|
total_size += size
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
info["total_disk_usage_mb"] = round(total_size / (1024 * 1024), 2)
|
info["total_disk_usage_mb"] = round(total_size / (1024 * 1024), 2)
|
||||||
return info
|
return info
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue