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.
56 lines • 2.9 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.LaunchInferenceInstance = void 0;
const either_1 = require("@/core/logic/either");
const launch_instance_error_1 = require("./errors/launch-instance-error");
class LaunchInferenceInstance {
constructor(apiClient) {
this.apiClient = apiClient;
}
async execute({ hardwareName, regionsIds, minContainers, maxContainers, cooldownPeriod, triggers, envs, startupCommand, modelId, registryId, containerPort, name, timeout, }) {
try {
const instance = await this.apiClient.post("/ai-inference/instances", {
body: JSON.stringify({
modelId,
registryId,
containerPort,
name,
autoScalingConfigurations: regionsIds.map((regionId) => ({
regionId,
scale: {
min: minContainers,
max: maxContainers,
cooldownPeriod,
triggers: {
cpu: (triggers === null || triggers === void 0 ? void 0 : triggers.cpu) ? { threshold: triggers.cpu } : null,
gpuUtilization: (triggers === null || triggers === void 0 ? void 0 : triggers.gpuUtilization)
? { threshold: triggers.gpuUtilization }
: null,
gpuMemory: (triggers === null || triggers === void 0 ? void 0 : triggers.gpuMemory)
? { threshold: triggers.gpuMemory }
: null,
memory: (triggers === null || triggers === void 0 ? void 0 : triggers.memory)
? { threshold: triggers.memory }
: null,
http: (triggers === null || triggers === void 0 ? void 0 : triggers.http) ? { rate: triggers.http } : null,
},
},
})),
podLifetime: timeout,
envs,
hardwareName,
startupCommand,
}),
});
if (!instance) {
return (0, either_1.left)(new launch_instance_error_1.LaunchInferenceInstanceError("Failed to create instance"));
}
return (0, either_1.right)(instance);
}
catch (error) {
return (0, either_1.left)(new launch_instance_error_1.LaunchInferenceInstanceError(error instanceof Error ? error.message : "Unexpected error occurred."));
}
}
}
exports.LaunchInferenceInstance = LaunchInferenceInstance;
//# sourceMappingURL=launch-instance.js.map