sesterce-cli
Version:
A powerful command-line interface tool for managing Sesterce Cloud services. Sesterce CLI provides easy access to GPU cloud instances, AI inference services, container registries, and SSH key management directly from your terminal.
73 lines (66 loc) • 2.22 kB
text/typescript
import { listGpuCloudOffers } from "@/modules/gpu-cloud/use-cases/list-instance-offers";
import { Command } from "commander";
interface TableData {
gpu: string;
hourlyPrice: string;
cloud: string;
"vRam (GB)": number;
"ram (GB)": number;
vcpu: number;
interconnect: string;
nvlink: string;
deploymentType: string;
}
export function createGpuCloudInstanceOffersCommand(
gpuCloudInstanceCommand: Command
) {
gpuCloudInstanceCommand
.command("offers")
.description("List all instance offers in Sesterce Cloud")
.action(async () => {
console.log("Listing instance offers...");
const result = await listGpuCloudOffers.execute();
if (result.isLeft()) {
console.error(result.value.message);
return;
}
const offers = result.value;
// const groupedOffers = offers.reduce(
// (acc, offer) => {
// const key = `${offer.gpuName}x${offer.gpuCount}`;
// if (!acc[key]) {
// acc[key] = [];
// }
// acc[key].push(offer);
// return acc;
// },
// {} as Record<string, GpuCloudInstanceOffer[]>
// );
// const offersKeys = Object.keys(groupedOffers).sort((a, b) =>
// a.localeCompare(b)
// );
// const sortedOffers = offersKeys.flatMap((offerKey) =>
// groupedOffers[offerKey].filter(({ availability }) =>
// availability.some(({ available }) => available)
// )
// );
const tableData = offers.reduce(
(dict, { offer: { instanceId, ...offer } }) => {
dict[instanceId] = {
gpu: `${offer.gpuCount} x ${offer.gpuName}`,
hourlyPrice: `$${offer.hourlyPrice.toFixed(2)}`,
cloud: offer.cloud.name,
"vRam (GB)": offer.configuration.vRamGB,
"ram (GB)": offer.configuration.ramGB,
vcpu: offer.configuration.vCpu,
interconnect: offer.configuration.interconnect,
nvlink: offer.nvlink ? "Yes" : "No",
deploymentType: offer.deploymentType,
};
return dict;
},
{} as Record<string, TableData>
);
console.table(tableData);
});
}