trainfabric 0.1.16 → 0.1.17
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 +24 -12
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -8113,8 +8113,16 @@ var BillingClient = class extends ResourceClient {
|
|
|
8113
8113
|
getSummary() {
|
|
8114
8114
|
return this.requestGet("/v1/billing/summary");
|
|
8115
8115
|
}
|
|
8116
|
-
getUsage(unit) {
|
|
8117
|
-
|
|
8116
|
+
getUsage(unit, runId) {
|
|
8117
|
+
const params = new URLSearchParams();
|
|
8118
|
+
if (unit) {
|
|
8119
|
+
params.set("unit", unit);
|
|
8120
|
+
}
|
|
8121
|
+
if (runId) {
|
|
8122
|
+
params.set("runId", runId);
|
|
8123
|
+
}
|
|
8124
|
+
const query = params.toString();
|
|
8125
|
+
return this.requestGet(`/v1/billing/usage${query ? `?${query}` : ""}`);
|
|
8118
8126
|
}
|
|
8119
8127
|
listInvoices() {
|
|
8120
8128
|
return this.requestGet("/v1/billing/invoices");
|
|
@@ -8379,6 +8387,9 @@ var RunHandle = class {
|
|
|
8379
8387
|
this.client = client;
|
|
8380
8388
|
this.snapshot = snapshot;
|
|
8381
8389
|
}
|
|
8390
|
+
isTerminal() {
|
|
8391
|
+
return ["completed", "failed", "canceled", "terminated"].includes(this.snapshot.status);
|
|
8392
|
+
}
|
|
8382
8393
|
on(event, listener) {
|
|
8383
8394
|
if (!this.listeners.has(event)) {
|
|
8384
8395
|
this.listeners.set(event, /* @__PURE__ */ new Set());
|
|
@@ -8422,7 +8433,7 @@ var RunHandle = class {
|
|
|
8422
8433
|
this.abortController.abort();
|
|
8423
8434
|
}
|
|
8424
8435
|
ensureStreaming() {
|
|
8425
|
-
if (this.streaming || !this.shouldStream) {
|
|
8436
|
+
if (this.streaming || !this.shouldStream || this.isTerminal()) {
|
|
8426
8437
|
return;
|
|
8427
8438
|
}
|
|
8428
8439
|
this.streaming = true;
|
|
@@ -8458,7 +8469,7 @@ var RunHandle = class {
|
|
|
8458
8469
|
}
|
|
8459
8470
|
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
8460
8471
|
}
|
|
8461
|
-
if (
|
|
8472
|
+
if (this.isTerminal()) {
|
|
8462
8473
|
break;
|
|
8463
8474
|
}
|
|
8464
8475
|
}
|
|
@@ -8927,7 +8938,7 @@ function buildComputeSpec(options) {
|
|
|
8927
8938
|
|
|
8928
8939
|
// src/index.ts
|
|
8929
8940
|
var DEFAULT_TRAINFABRIC_API_URL2 = "https://api.trainfabric.com";
|
|
8930
|
-
var CLI_VERSION = "0.1.
|
|
8941
|
+
var CLI_VERSION = "0.1.17";
|
|
8931
8942
|
var CONFIG_DIR = import_node_path3.default.join(import_node_os2.default.homedir(), ".trainfabric");
|
|
8932
8943
|
var CONFIG_PATH = import_node_path3.default.join(CONFIG_DIR, "config.json");
|
|
8933
8944
|
var FALLBACK_SECRET_PATH = import_node_path3.default.join(CONFIG_DIR, "session.enc");
|
|
@@ -9345,16 +9356,17 @@ async function watchRun(runId, json = false, timeoutMs, pollMs) {
|
|
|
9345
9356
|
});
|
|
9346
9357
|
handle.on("metric", (event) => {
|
|
9347
9358
|
const payload = event.payload;
|
|
9348
|
-
|
|
9349
|
-
|
|
9350
|
-
);
|
|
9359
|
+
const evalLoss = payload.evalLoss === void 0 ? "" : ` evalLoss=${payload.evalLoss}`;
|
|
9360
|
+
console.log(`[metric] step=${payload.step ?? "?"} loss=${payload.loss ?? "?"}${evalLoss}`);
|
|
9351
9361
|
});
|
|
9352
9362
|
handle.on("checkpoint", (event) => {
|
|
9353
9363
|
const payload = event.payload;
|
|
9354
9364
|
console.log(`[checkpoint] count=${payload.checkpointCount ?? "?"} path=${payload.checkpointPath ?? ""}`);
|
|
9355
9365
|
});
|
|
9356
|
-
handle.on("completed", () => {
|
|
9357
|
-
|
|
9366
|
+
handle.on("completed", (event) => {
|
|
9367
|
+
const payload = event.payload;
|
|
9368
|
+
const metrics = payload.metrics ? ` finalLoss=${payload.metrics.finalLoss ?? "?"} evalLoss=${payload.metrics.evalLoss ?? "?"}` : "";
|
|
9369
|
+
console.log(`[completed]${metrics}`);
|
|
9358
9370
|
});
|
|
9359
9371
|
handle.on("failed", (event) => {
|
|
9360
9372
|
const payload = event.payload;
|
|
@@ -9627,8 +9639,8 @@ program2.command("deployments:get").argument("<deploymentId>").description("Fetc
|
|
|
9627
9639
|
program2.command("billing:summary").description("Fetch billing summary").action(async () => {
|
|
9628
9640
|
printJson(await createClient(loadConfig()).billing.getSummary());
|
|
9629
9641
|
});
|
|
9630
|
-
program2.command("billing:usage").option("--unit <unit>", "normalized_tflop_seconds, reserved_gpu_seconds, or usd").description("List billing usage records").action(async (options) => {
|
|
9631
|
-
printJson(await createClient(loadConfig()).billing.getUsage(options.unit));
|
|
9642
|
+
program2.command("billing:usage").option("--unit <unit>", "normalized_tflop_seconds, reserved_gpu_seconds, or usd").option("--run <runId>", "filter usage records to one run").description("List billing usage records").action(async (options) => {
|
|
9643
|
+
printJson(await createClient(loadConfig()).billing.getUsage(options.unit, options.run));
|
|
9632
9644
|
});
|
|
9633
9645
|
program2.command("billing:invoices").description("List invoices").action(async () => {
|
|
9634
9646
|
printJson(await createClient(loadConfig()).billing.listInvoices());
|