trainfabric 0.1.26 → 0.1.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +46 -8
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -8983,6 +8983,9 @@ function normalizeHumanName(value, label) {
|
|
|
8983
8983
|
if (!/[A-Za-z0-9]/.test(name)) {
|
|
8984
8984
|
throw new Error(`${label} is required.`);
|
|
8985
8985
|
}
|
|
8986
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9 ._-]{0,79}$/.test(name) || name.includes("..")) {
|
|
8987
|
+
throw new Error(`${label} contains invalid characters. Use letters, numbers, spaces, dots, underscores, or hyphens.`);
|
|
8988
|
+
}
|
|
8986
8989
|
return name;
|
|
8987
8990
|
}
|
|
8988
8991
|
function normalizeId(value, kind, label) {
|
|
@@ -9024,6 +9027,8 @@ var BASE_MODEL_ALIASES = {
|
|
|
9024
9027
|
var ACCELERATOR_CLASSES = /* @__PURE__ */ new Set(["a10g", "l4", "a40", "l40s", "a100", "h100", "h200", "b200"]);
|
|
9025
9028
|
var PRECISION_MODES = /* @__PURE__ */ new Set(["fp16_bf16", "fp8", "fp32"]);
|
|
9026
9029
|
var INTERCONNECT_TYPES = /* @__PURE__ */ new Set(["pcie", "nvlink"]);
|
|
9030
|
+
var BASE_MODELS = new Set(baseModels);
|
|
9031
|
+
var TRAINING_MODES = new Set(trainingModes);
|
|
9027
9032
|
function normalizePositiveInteger(value, label, fallback) {
|
|
9028
9033
|
const parsed = Number(value ?? String(fallback));
|
|
9029
9034
|
if (!Number.isInteger(parsed) || parsed <= 0) {
|
|
@@ -9052,7 +9057,35 @@ function normalizeOptionalChoice(value, allowed, label, examples) {
|
|
|
9052
9057
|
return normalized;
|
|
9053
9058
|
}
|
|
9054
9059
|
function normalizeBaseModel(model) {
|
|
9055
|
-
|
|
9060
|
+
const normalized = BASE_MODEL_ALIASES[String(model ?? "").trim().toLowerCase()];
|
|
9061
|
+
if (normalized) {
|
|
9062
|
+
return normalized;
|
|
9063
|
+
}
|
|
9064
|
+
const rawModel = String(model ?? "").trim();
|
|
9065
|
+
if (!BASE_MODELS.has(rawModel)) {
|
|
9066
|
+
throw new Error("Model is invalid. Use llama-3-8b, mistral-7b, or qwen-2.5-7b.");
|
|
9067
|
+
}
|
|
9068
|
+
return rawModel;
|
|
9069
|
+
}
|
|
9070
|
+
function normalizeTrainingMode(mode) {
|
|
9071
|
+
if (mode === void 0) {
|
|
9072
|
+
return void 0;
|
|
9073
|
+
}
|
|
9074
|
+
const normalized = String(mode).trim().toLowerCase();
|
|
9075
|
+
if (!TRAINING_MODES.has(normalized)) {
|
|
9076
|
+
throw new Error("Mode is invalid. Use efficient, balanced, or power.");
|
|
9077
|
+
}
|
|
9078
|
+
return normalized;
|
|
9079
|
+
}
|
|
9080
|
+
function normalizeEpochs(epochs) {
|
|
9081
|
+
return normalizePositiveInteger(epochs, "Epochs", 3);
|
|
9082
|
+
}
|
|
9083
|
+
function normalizeLearningRate(lr) {
|
|
9084
|
+
const parsed = Number(lr ?? "0.0002");
|
|
9085
|
+
if (!Number.isFinite(parsed) || parsed < 1e-5 || parsed > 0.01) {
|
|
9086
|
+
throw new Error("Learning rate must be a number between 0.00001 and 0.01.");
|
|
9087
|
+
}
|
|
9088
|
+
return parsed;
|
|
9056
9089
|
}
|
|
9057
9090
|
function buildComputeSpec(options) {
|
|
9058
9091
|
const gpuCount = normalizePositiveInteger(options.gpus, "GPU count", 1);
|
|
@@ -9089,7 +9122,7 @@ function buildComputeSpec(options) {
|
|
|
9089
9122
|
|
|
9090
9123
|
// src/index.ts
|
|
9091
9124
|
var DEFAULT_TRAINFABRIC_API_URL2 = "https://api.trainfabric.com";
|
|
9092
|
-
var CLI_VERSION = "0.1.
|
|
9125
|
+
var CLI_VERSION = "0.1.27";
|
|
9093
9126
|
var CONFIG_DIR = import_node_path3.default.join(import_node_os2.default.homedir(), ".trainfabric");
|
|
9094
9127
|
var CONFIG_PATH = import_node_path3.default.join(CONFIG_DIR, "config.json");
|
|
9095
9128
|
var FALLBACK_SECRET_PATH = import_node_path3.default.join(CONFIG_DIR, "session.enc");
|
|
@@ -9441,15 +9474,15 @@ function buildRunInput(options, config = loadConfig()) {
|
|
|
9441
9474
|
task: "sft",
|
|
9442
9475
|
method: "lora",
|
|
9443
9476
|
baseModel: normalizeBaseModel(options.model),
|
|
9444
|
-
datasetId: options.dataset,
|
|
9445
|
-
evalDatasetId: options.eval,
|
|
9477
|
+
datasetId: normalizeId(options.dataset, "dataset", "Dataset ID"),
|
|
9478
|
+
evalDatasetId: normalizeOptionalId(options.eval, "dataset", "Eval dataset ID"),
|
|
9446
9479
|
pricingQuoteId: options.quote,
|
|
9447
9480
|
...sourceOptions,
|
|
9448
|
-
mode: options.mode,
|
|
9481
|
+
mode: normalizeTrainingMode(options.mode),
|
|
9449
9482
|
compute: buildComputeSpec(options),
|
|
9450
9483
|
hyperparameters: {
|
|
9451
|
-
epochs:
|
|
9452
|
-
lr:
|
|
9484
|
+
epochs: normalizeEpochs(options.epochs),
|
|
9485
|
+
lr: normalizeLearningRate(options.lr),
|
|
9453
9486
|
batchSize: "auto"
|
|
9454
9487
|
}
|
|
9455
9488
|
};
|
|
@@ -9868,7 +9901,12 @@ program2.command("deployments:create").requiredOption("--model <modelId>").optio
|
|
|
9868
9901
|
await client.projects.get(projectId);
|
|
9869
9902
|
}
|
|
9870
9903
|
const modelId = normalizeId(options.model, "model", "Model ID");
|
|
9871
|
-
|
|
9904
|
+
try {
|
|
9905
|
+
printJson(await client.deployments.create({ modelId }));
|
|
9906
|
+
} catch (error) {
|
|
9907
|
+
printJson({ error: error instanceof Error ? error.message : String(error) });
|
|
9908
|
+
process.exitCode = 1;
|
|
9909
|
+
}
|
|
9872
9910
|
});
|
|
9873
9911
|
program2.command("deployments:get").argument("<deploymentId>").description("Fetch a deployment").action(async (deploymentId) => {
|
|
9874
9912
|
printJson(await createClient(loadConfig()).deployments.get(normalizeId(deploymentId, "deployment", "Deployment ID")));
|