diff --git a/src/lib/buy/index.tsx b/src/lib/buy/index.tsx index 0512ace..667def0 100644 --- a/src/lib/buy/index.tsx +++ b/src/lib/buy/index.tsx @@ -45,10 +45,7 @@ export function _registerBuy(program: Command) { .command("buy") .description("Place a buy order") .showHelpAfterError() - .option( - "-t, --type ", - "Type of GPU", - ) + .option("-t, --type ", "Type of GPU") .option( "-n, --accelerators ", "Number of GPUs to purchase", @@ -118,6 +115,12 @@ export function _registerBuy(program: Command) { command.help(); process.exit(1); } + // let user know if they're using a zone or cluster and it's overriding the instance type + if (type && (zone || cluster)) { + console.warn( + `Warning: Zone '${zone}' takes precedence over instance type '${type}'`, + ); + } }) .configureHelp({ optionDescription: (option) => { @@ -277,8 +280,25 @@ export function QuoteAndBuy(props: { options: SfBuyOptions }) { const { type, accelerators, colocate, yes, standing, cluster } = props.options; + // If the user specifies a cluster, use the hardware type of the zone + let actualType = type; + if (cluster) { + const zoneMetadata = await getZoneMetadata(cluster); + if (zoneMetadata) { + const DeliveryTypeMetadata = { + "K8s": { displayName: "Kubernetes" }, + "VM": { displayName: "Virtual Machine" }, + }; + + const deliveryDisplayName = + DeliveryTypeMetadata[zoneMetadata.deliveryType]?.displayName || + zoneMetadata.deliveryType; + actualType = `${deliveryDisplayName} (${zoneMetadata.hardwareType})`; + } + } + setOrderProps({ - type, + type: actualType, price: pricePerGpuHour, size: accelerators / GPUS_PER_NODE, startAt, @@ -370,11 +390,7 @@ function BuyOrderPreview(props: BuyOrderProps) { {typeLabel} - {isSupportedType && ( - - ({props.type!}) - - )} + {isSupportedType && ({props.type!})} )} @@ -558,10 +574,7 @@ function BuyOrder(props: BuyOrderProps) { Place order? (y/n) - + )} @@ -591,7 +604,8 @@ function BuyOrder(props: BuyOrderProps) { (order as Awaited>) && order.execution_price && ( - {order.start_at && order.end_at && + {order.start_at && + order.end_at && order.start_at !== order.end_at && ( - {order.execution_price && Number(order.price) > 0 && + {order.execution_price && + Number(order.price) > 0 && Number(order.execution_price) > 0 && Number(order.execution_price) < Number(order.price) && ( z.name === zoneName); + return zone + ? { + deliveryType: zone.delivery_type, // "K8s" or "VM" + hardwareType: zone.hardware_type, // "h100i", "h100v", etc. + } + : null; +}