Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

fix(lume): default disk/memory size to GB when no unit specified (#952)

Francesco Bonaccidceb4d8696c5
diff --git a/libs/lume/src/Commands/Create.swift b/libs/lume/src/Commands/Create.swift
index ea4145953b..4084eba8f4 100644
--- a/libs/lume/src/Commands/Create.swift
+++ b/libs/lume/src/Commands/Create.swift
@@ -21,12 +21,13 @@ struct Create: AsyncParsableCommand {
var cpu: Int = 4
@Option(
- help: "Memory size, e.g., 8192MB or 8GB. Defaults to 8GB.", transform: { try parseSize($0) }
+ help: "Memory size (e.g., 8, 8GB, or 8192MB). Numbers without units are treated as GB. Defaults to 8GB.",
+ transform: { try parseSize($0) }
)
var memory: UInt64 = 8 * 1024 * 1024 * 1024
@Option(
- help: "Disk size, e.g., 20480MB or 20GB. Defaults to 50GB.",
+ help: "Disk size (e.g., 50, 50GB, or 51200MB). Numbers without units are treated as GB. Defaults to 50GB.",
transform: { try parseSize($0) })
var diskSize: UInt64 = 50 * 1024 * 1024 * 1024
@@ -81,6 +82,13 @@ struct Create: AsyncParsableCommand {
throw ValidationError("--unattended is only supported for macOS VMs")
}
+ // Sanity check disk size
+ let minDiskSizeGB: UInt64 = os.lowercased() == "macos" ? 30 : 10
+ let minDiskSize = minDiskSizeGB * 1024 * 1024 * 1024
+ if diskSize < minDiskSize {
+ throw ValidationError("Disk size \(diskSize / (1024 * 1024 * 1024))GB is too small. Minimum recommended size for \(os) is \(minDiskSizeGB)GB.")
+ }
+
// Load unattended config if provided
var unattendedConfig: UnattendedConfig?
if let unattendedArg = unattended {
diff --git a/libs/lume/src/Commands/Set.swift b/libs/lume/src/Commands/Set.swift
index e2420a6894..26c25b9325 100644
--- a/libs/lume/src/Commands/Set.swift
+++ b/libs/lume/src/Commands/Set.swift
@@ -12,10 +12,10 @@ struct Set: AsyncParsableCommand {
@Option(help: "New number of CPU cores")
var cpu: Int?
- @Option(help: "New memory size, e.g., 8192MB or 8GB.", transform: { try parseSize($0) })
+ @Option(help: "New memory size (e.g., 8, 8GB, or 8192MB). Numbers without units are treated as GB.", transform: { try parseSize($0) })
var memory: UInt64?
- @Option(help: "New disk size, e.g., 20480MB or 20GB.", transform: { try parseSize($0) })
+ @Option(help: "New disk size (e.g., 50, 50GB, or 51200MB). Numbers without units are treated as GB.", transform: { try parseSize($0) })
var diskSize: UInt64?
@Option(help: "New display resolution in format WIDTHxHEIGHT.")
diff --git a/libs/lume/src/Utils/Utils.swift b/libs/lume/src/Utils/Utils.swift
index 96f512bdc7..190ef68236 100644
--- a/libs/lume/src/Utils/Utils.swift
+++ b/libs/lume/src/Utils/Utils.swift
@@ -42,8 +42,12 @@ func parseSize(_ input: String) throws -> UInt64 {
} else if lowercased.hasSuffix("kb") {
multiplier = 1024
valueString = String(lowercased.dropLast(2))
+ } else if lowercased.hasSuffix("b") {
+ multiplier = 1
+ valueString = String(lowercased.dropLast(1))
} else {
- multiplier = 1024 * 1024
+ // Default to GB when no unit is specified
+ multiplier = 1024 * 1024 * 1024
valueString = lowercased
}