@@ -120,6 +120,61 @@ def __del__(self):
120120 """Clean up temporary files when the model instance is destroyed."""
121121 self ._cleanup_temp_resources ()
122122
123+ print ("df -dh:" )
124+ import psutil
125+
126+ for part in psutil .disk_partitions ():
127+ usage = psutil .disk_usage (part .mountpoint )
128+ print (f"{ part .device } mounted on { part .mountpoint } " )
129+ print (f" Total: { usage .total / 2 ** 30 :.2f} GB" )
130+ print (f" Used: { usage .used / 2 ** 30 :.2f} GB" )
131+ print (f" Free: { usage .free / 2 ** 30 :.2f} GB" )
132+ print (f" Percent Used: { usage .percent } %\n " )
133+ print ()
134+
135+
136+ print ("Walking through all files:" )
137+ import os
138+ from pathlib import Path
139+
140+ def get_dir_size (path ):
141+ total = 0
142+ for dirpath , dirnames , filenames in os .walk (path , onerror = lambda e : None ):
143+ for f in filenames :
144+ try :
145+ fp = os .path .join (dirpath , f )
146+ total += os .path .getsize (fp )
147+ except (FileNotFoundError , PermissionError ):
148+ continue
149+ return total
150+
151+ # Compute top 40 largest directories under /
152+ dirs = []
153+ root = Path ("/" )
154+
155+ for p in root .iterdir ():
156+ try :
157+ size = get_dir_size (p )
158+ dirs .append ((size , str (p )))
159+ except PermissionError :
160+ continue
161+
162+ # Sort and print largest 40
163+ dirs .sort (reverse = True )
164+ for size , path in dirs [:40 ]:
165+ print (f"{ size / 1e9 :.2f} GB\t { path } " )
166+ print ()
167+
168+ print ("Memory used:" )
169+ import psutil
170+
171+ mem = psutil .virtual_memory ()
172+
173+ print (f"Total: { mem .total / (1024 ** 3 ):.2f} GB" )
174+ print (f"Available: { mem .available / (1024 ** 3 ):.2f} GB" )
175+ print (f"Used: { mem .used / (1024 ** 3 ):.2f} GB" )
176+ print (f"Percent: { mem .percent } %" )
177+
123178 def _cleanup_temp_resources (self ):
124179 """Clean up temporary directory and files."""
125180 if hasattr (self , "_temp_dir" ) and self ._temp_dir is not None :
0 commit comments