@@ -23,33 +23,24 @@ import MLXVLM
2323
2424final class ProgressTracker {
2525 var lastUpdate : TimeInterval = 0
26- var lastBytes : Int64 = 0
27- var speedStr = " 0.0 MB/s "
2826 var isDone = false
27+ var spinnerFrames = [ " ⠋ " , " ⠙ " , " ⠹ " , " ⠸ " , " ⠼ " , " ⠴ " , " ⠦ " , " ⠧ " , " ⠇ " , " ⠏ " ]
28+ var frameIndex = 0
2929
3030 func printProgress( _ progress: Progress ) {
3131 if isDone { return }
3232 let now = Date ( ) . timeIntervalSince1970
33-
34- let completed = progress. completedUnitCount
35- let total = progress. totalUnitCount
3633 let fraction = progress. fractionCompleted
3734
3835 if lastUpdate == 0 { lastUpdate = now }
3936 let interval = now - lastUpdate
4037
41- if interval >= 0.5 {
42- let diff = Double ( completed - lastBytes)
43- let speedMBps = ( diff / interval) / 1_048_576.0
44- speedStr = String ( format: " %.1f MB/s " , speedMBps)
45-
46- lastBytes = completed
38+ if interval > 0.1 {
39+ frameIndex = ( frameIndex + 1 ) % spinnerFrames. count
4740 lastUpdate = now
4841 }
4942
5043 let pct = Int ( fraction * 100 )
51- let completedMB = String ( format: " %.1f " , Double ( completed) / 1_048_576 )
52- let totalMB = String ( format: " %.1f " , Double ( total) / 1_048_576 )
5344
5445 let barLength = 20
5546 let completedBars = min ( barLength, Int ( fraction * Double( barLength) ) )
@@ -64,9 +55,13 @@ final class ProgressTracker {
6455 bars += String ( repeating: " " , count: emptyBars)
6556
6657 let pctStr = String ( format: " %3d%% " , pct)
67- let msg = String ( format: " \r [mlx-server] Download: [%@] %@ (%@ MB / %@ MB) | Speed: %@ " , bars, pctStr, completedMB, totalMB, speedStr)
58+ let spinner = spinnerFrames [ frameIndex]
59+
60+ // If the library properly bubbled up throughput or total bytes, we'd show it,
61+ // but swift-transformers aggregated Progress uses abstract units (e.g. 100 for total).
62+ let msg = String ( format: " \r [mlx-server] Download: [%@] %@ %@ " , bars, pctStr, spinner)
6863
69- print ( msg. padding ( toLength: 100 , withPad: " " , startingAt: 0 ) , terminator: " " )
64+ print ( msg. padding ( toLength: 80 , withPad: " " , startingAt: 0 ) , terminator: " " )
7065 fflush ( stdout)
7166
7267 if fraction >= 1.0 {
0 commit comments