trainfabric 0.1.39 → 0.1.40
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 +37 -10
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -9279,7 +9279,7 @@ function buildComputeSpec(options) {
|
|
|
9279
9279
|
|
|
9280
9280
|
// src/index.ts
|
|
9281
9281
|
var DEFAULT_TRAINFABRIC_API_URL2 = "https://api.trainfabric.com";
|
|
9282
|
-
var CLI_VERSION = "0.1.
|
|
9282
|
+
var CLI_VERSION = "0.1.40";
|
|
9283
9283
|
var CONFIG_DIR = import_node_path3.default.join(import_node_os2.default.homedir(), ".trainfabric");
|
|
9284
9284
|
var CONFIG_PATH = import_node_path3.default.join(CONFIG_DIR, "config.json");
|
|
9285
9285
|
var FALLBACK_SECRET_PATH = import_node_path3.default.join(CONFIG_DIR, "session.enc");
|
|
@@ -9618,6 +9618,20 @@ function printUsageSummary(usage) {
|
|
|
9618
9618
|
console.log(` ${item.label}: ${formatUsd(item.amountUsd)} - ${item.description}`);
|
|
9619
9619
|
}
|
|
9620
9620
|
}
|
|
9621
|
+
function summarizeRunDetail(detail) {
|
|
9622
|
+
return {
|
|
9623
|
+
runId: detail.run.id,
|
|
9624
|
+
status: detail.run.status,
|
|
9625
|
+
dispatchStatus: detail.run.dispatchStatus,
|
|
9626
|
+
durationSeconds: detail.run.durationSeconds,
|
|
9627
|
+
estimatedCostUsd: detail.run.estimatedCostUsd,
|
|
9628
|
+
customerChargeUsd: detail.usageSummary?.customerChargeUsd,
|
|
9629
|
+
reservedGpuSeconds: detail.usageSummary?.reservedGpuSeconds,
|
|
9630
|
+
artifactCount: detail.artifacts?.length ?? 0,
|
|
9631
|
+
metricCount: detail.metrics?.length ?? 0,
|
|
9632
|
+
modelId: detail.run.modelId
|
|
9633
|
+
};
|
|
9634
|
+
}
|
|
9621
9635
|
function updateConfig(mutate) {
|
|
9622
9636
|
const config = loadConfig();
|
|
9623
9637
|
mutate(config);
|
|
@@ -9776,7 +9790,14 @@ async function watchRun(runId, json = false, timeoutMs, pollMs) {
|
|
|
9776
9790
|
});
|
|
9777
9791
|
}
|
|
9778
9792
|
const detail = await handle.wait({ timeoutMs, pollMs });
|
|
9779
|
-
|
|
9793
|
+
const summary = summarizeRunDetail(detail);
|
|
9794
|
+
if (json) {
|
|
9795
|
+
printJson({ type: "terminal", payload: summary });
|
|
9796
|
+
} else {
|
|
9797
|
+
console.log(
|
|
9798
|
+
`[terminal] status=${summary.status} charge=${formatUsd(summary.customerChargeUsd)} artifacts=${summary.artifactCount}`
|
|
9799
|
+
);
|
|
9800
|
+
}
|
|
9780
9801
|
}
|
|
9781
9802
|
function parseDurationMs(value) {
|
|
9782
9803
|
if (!value) {
|
|
@@ -9963,7 +9984,14 @@ program2.command("datasets:get").argument("<datasetId>").description("Fetch data
|
|
|
9963
9984
|
});
|
|
9964
9985
|
program2.command("datasets:delete").argument("<datasetId>").description("Delete a dataset").action(async (datasetId) => {
|
|
9965
9986
|
const normalizedDatasetId = normalizeId(datasetId, "dataset", "Dataset ID");
|
|
9966
|
-
|
|
9987
|
+
const client = createClient(loadConfig());
|
|
9988
|
+
try {
|
|
9989
|
+
await client.datasets.get(normalizedDatasetId);
|
|
9990
|
+
} catch {
|
|
9991
|
+
printJson({ deleted: false, alreadyDeleted: true, id: normalizedDatasetId });
|
|
9992
|
+
return;
|
|
9993
|
+
}
|
|
9994
|
+
await client.datasets.delete(normalizedDatasetId);
|
|
9967
9995
|
printJson({ deleted: true, id: normalizedDatasetId });
|
|
9968
9996
|
});
|
|
9969
9997
|
program2.command("datasets:upload").argument("<file>").option("--project <projectId>").option("--name <name>").description("Upload a dataset through upload sessions").action(async (file, options) => {
|
|
@@ -10048,14 +10076,13 @@ program2.command("runs:status").argument("<runId>").description("Fetch full run
|
|
|
10048
10076
|
program2.command("runs:logs").argument("<runId>").description("Fetch run logs").action(async (runId) => {
|
|
10049
10077
|
printJson(await createClient(loadConfig()).runs.logs(normalizeId(runId, "run", "Run ID")));
|
|
10050
10078
|
});
|
|
10051
|
-
program2.command("runs:wait").argument("<runId>").option("--timeout <duration>", "maximum wait duration, for example 30s, 10m, or 1h").option("--poll <duration>", "poll interval, for example 1s or 500ms").description("Wait for a run to reach a terminal state").action(async (runId, options) => {
|
|
10079
|
+
program2.command("runs:wait").argument("<runId>").option("--timeout <duration>", "maximum wait duration, for example 30s, 10m, or 1h").option("--poll <duration>", "poll interval, for example 1s or 500ms").option("--summary", "print a compact terminal run summary").description("Wait for a run to reach a terminal state").action(async (runId, options) => {
|
|
10052
10080
|
const normalizedRunId = normalizeId(runId, "run", "Run ID");
|
|
10053
|
-
|
|
10054
|
-
|
|
10055
|
-
|
|
10056
|
-
|
|
10057
|
-
|
|
10058
|
-
);
|
|
10081
|
+
const detail = await createClient(loadConfig()).runs.wait(normalizedRunId, {
|
|
10082
|
+
timeoutMs: parseDurationMs(options.timeout),
|
|
10083
|
+
pollMs: parsePositiveMs(options.poll, 1e3)
|
|
10084
|
+
});
|
|
10085
|
+
printJson(options.summary ? summarizeRunDetail(detail) : detail);
|
|
10059
10086
|
});
|
|
10060
10087
|
program2.command("runs:watch").argument("<runId>").option("--json", "emit event output as JSON").option("--timeout <duration>", "maximum watch duration, for example 30s, 10m, or 1h").option("--poll <duration>", "poll interval, for example 1s or 500ms").description("Stream a run until it completes").action(async (runId, options) => {
|
|
10061
10088
|
await watchRun(normalizeId(runId, "run", "Run ID"), Boolean(options.json), parseDurationMs(options.timeout), parsePositiveMs(options.poll, 1e3));
|