@computesdk/cli 2.5.7 → 2.5.8

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.js CHANGED
@@ -768,6 +768,7 @@ function formatRunDetail(run, runUrl) {
768
768
  if (run.providerOverride) lines.push(`dispatched to: ${run.providerOverride}`);
769
769
  if (run.supersededByRunId) lines.push(`superseded by: ${run.supersededByRunId}`);
770
770
  if (runUrl) lines.push(`url: ${runUrl}`);
771
+ if (run.benchmarks && run.benchmarks.length > 0) lines.push(`benchmarks: ${resultsSummary(run.benchmarks)}`);
771
772
  if (run.jobs.length > 0) {
772
773
  lines.push("");
773
774
  lines.push(pc2.bold("jobs"));
@@ -785,6 +786,57 @@ function formatRunDetail(run, runUrl) {
785
786
  }
786
787
  return lines.join("\n");
787
788
  }
789
+ function resultsSummary(results) {
790
+ return results.map((r) => {
791
+ const rows = overallRows(r);
792
+ if (rows.length === 0) return `${safeTerm(r.benchmarkSlug)} (${safeTerm(r.status)}, no results yet)`;
793
+ const failed = rows.filter((p2) => !p2.skipped && p2.successRate !== null && p2.successRate < 1).length;
794
+ return `${safeTerm(r.benchmarkSlug)} \xB7 ${rows.length} providers${failed > 0 ? ` \xB7 ${failed} failed` : ""}`;
795
+ }).join("; ");
796
+ }
797
+ function overallRows(result) {
798
+ const byProvider = /* @__PURE__ */ new Map();
799
+ for (const p2 of result.providers) {
800
+ const cur = byProvider.get(p2.provider);
801
+ const isOverall = Object.keys(p2.dimensions).length === 0;
802
+ const curIsOverall = cur ? Object.keys(cur.dimensions).length === 0 : false;
803
+ if (!cur || isOverall && !curIsOverall || !curIsOverall && (p2.compositeScore ?? -1) > (cur.compositeScore ?? -1)) {
804
+ byProvider.set(p2.provider, p2);
805
+ }
806
+ }
807
+ return Array.from(byProvider.values());
808
+ }
809
+ function formatScore(n) {
810
+ return n === null ? "-" : n.toFixed(2);
811
+ }
812
+ function formatMetric(n) {
813
+ return Number.isInteger(n) ? String(n) : n.toFixed(Math.abs(n) >= 100 ? 1 : 2);
814
+ }
815
+ function formatRate(n) {
816
+ return n === null ? "-" : `${Math.round(n * 100)}%`;
817
+ }
818
+ function formatRunResults(results) {
819
+ if (results.length === 0) return pc2.dim("no benchmark results on this run");
820
+ const lines = [];
821
+ for (const [i, result] of results.entries()) {
822
+ if (i > 0) lines.push("");
823
+ lines.push(`${pc2.bold(safeTerm(result.benchmarkName))} ${safeTerm(result.status)}`);
824
+ lines.push(pc2.dim(`${safeTerm(result.benchmarkRunId)} ${safeTerm(result.dashboardUrl)}`));
825
+ const rows = [...overallRows(result)].sort((a, b) => (b.compositeScore ?? -1) - (a.compositeScore ?? -1));
826
+ if (rows.length === 0) {
827
+ lines.push(pc2.dim(result.status === "failed" ? " failed before reporting results" : " no results yet"));
828
+ continue;
829
+ }
830
+ const width = Math.max(8, ...rows.map((p2) => p2.provider.length));
831
+ lines.push(pc2.dim(` ${"provider".padEnd(width)} ${"score".padStart(7)} ${"success".padStart(7)} metrics`));
832
+ for (const p2 of rows) {
833
+ const metrics = Object.entries(p2.metrics).map(([name, m]) => `${safeTerm(name)} ${formatMetric(m.median)}${m.unit ? safeTerm(m.unit) : ""}`).join(" ");
834
+ const status = p2.skipped ? pc2.dim(`skipped${p2.skipReason ? `: ${safeTerm(p2.skipReason)}` : ""}`) : metrics;
835
+ lines.push(` ${safeTerm(p2.provider).padEnd(width)} ${formatScore(p2.compositeScore).padStart(7)} ${formatRate(p2.successRate).padStart(7)} ${status}`);
836
+ }
837
+ }
838
+ return lines.join("\n");
839
+ }
788
840
  function formatRunInspection(run) {
789
841
  const lines = [];
790
842
  lines.push(`${pc2.bold("run")} ${conclusionLabel(run.conclusion)}${run.runNumber === null ? "" : ` #${run.runNumber}`}`);
@@ -1345,6 +1397,17 @@ function registerActionsCommands(program2) {
1345
1397
  fail(e, opts);
1346
1398
  }
1347
1399
  });
1400
+ common(
1401
+ actions.command("benchmarks").description("Show the benchmark runs this run produced: per-provider score and success rate").argument("<run-id>", "run ID")
1402
+ ).action(async (runId, opts) => {
1403
+ try {
1404
+ const run = await (await client(opts)).get(`/api/v1/actions/runs/${runId}`);
1405
+ const benchmarks = run.benchmarks ?? [];
1406
+ output(opts, { runId: run.id, conclusion: run.conclusion, benchmarks }, () => console.log(formatRunResults(benchmarks)));
1407
+ } catch (e) {
1408
+ fail(e, opts);
1409
+ }
1410
+ });
1348
1411
  common(
1349
1412
  actions.command("inspect").description("Inspect a run: resolved runner image, caches, secret names, concurrency, placement context").argument("<run-id>", "run ID")
1350
1413
  ).action(async (runId, opts) => {
@@ -1923,7 +1986,7 @@ function credentialBody(fields, values) {
1923
1986
  }
1924
1987
  return { fields: values };
1925
1988
  }
1926
- function formatRate(usd, per) {
1989
+ function formatRate2(usd, per) {
1927
1990
  return formatUsdPer({ usd, per });
1928
1991
  }
1929
1992
  function formatListingStatus(ask) {
@@ -1933,7 +1996,7 @@ function formatListingStatus(ask) {
1933
1996
  else if (!ask.live) label = pc3.gray("expired");
1934
1997
  else label = pc3.green("live");
1935
1998
  if (ask.pendingUsd !== null && ask.pendingPer !== null) {
1936
- label += pc3.dim(` \u2192 ${formatRate(ask.pendingUsd, ask.pendingPer)} next window`);
1999
+ label += pc3.dim(` \u2192 ${formatRate2(ask.pendingUsd, ask.pendingPer)} next window`);
1937
2000
  }
1938
2001
  return label;
1939
2002
  }
@@ -1945,7 +2008,7 @@ function formatListingRow(ask) {
1945
2008
  pc3.dim(ask.useCase === "sandbox" ? "sandbox" : "actions"),
1946
2009
  safeTerm(ask.size),
1947
2010
  safeTerm(ask.region ?? "-"),
1948
- formatRate(ask.usd, ask.per),
2011
+ formatRate2(ask.usd, ask.per),
1949
2012
  pc3.dim(`\xD7${ask.maxConcurrent}`),
1950
2013
  pc3.dim(expiry)
1951
2014
  ].join(" ");
@@ -1982,7 +2045,7 @@ function formatBook(book) {
1982
2045
  const where = ask.region ? safeTerm(ask.region) : "any region";
1983
2046
  const expiry = ask.expiresAt ? pc3.dim(ask.rollover ? ` renews ${ask.expiresAt}` : ` until ${ask.expiresAt}`) : "";
1984
2047
  lines.push(
1985
- ` ${lane(ask.useCase)} ${formatRate(ask.usd, ask.per)} ${safeTerm(ask.providerName)} ${safeTerm(ask.size)} ${where} up to ${ask.maxConcurrent} at once${expiry}`
2048
+ ` ${lane(ask.useCase)} ${formatRate2(ask.usd, ask.per)} ${safeTerm(ask.providerName)} ${safeTerm(ask.size)} ${where} up to ${ask.maxConcurrent} at once${expiry}`
1986
2049
  );
1987
2050
  }
1988
2051
  lines.push("");
@@ -1992,7 +2055,7 @@ function formatBook(book) {
1992
2055
  const where = bid.region ? safeTerm(bid.region) : "anywhere";
1993
2056
  const yours = bid.mine ? pc3.cyan(" (yours)") : "";
1994
2057
  lines.push(
1995
- ` ${lane(bid.useCase)} pays up to ${formatRate(bid.maxUsd, bid.per)} ${safeTerm(bid.size)} ${where} ${pc3.dim(`posted ${bid.createdAt}`)}${yours}`
2058
+ ` ${lane(bid.useCase)} pays up to ${formatRate2(bid.maxUsd, bid.per)} ${safeTerm(bid.size)} ${where} ${pc3.dim(`posted ${bid.createdAt}`)}${yours}`
1996
2059
  );
1997
2060
  }
1998
2061
  lines.push("");
@@ -2001,7 +2064,7 @@ function formatBook(book) {
2001
2064
  for (const fill of book.fills) {
2002
2065
  const statusNote = fill.status === "replaced" ? pc3.yellow(" replaced") : fill.status === "closed" ? pc3.gray(" closed") : "";
2003
2066
  lines.push(
2004
- ` ${pc3.dim(fill.id)} ${lane(fill.useCase)} ${formatRate(fill.usd, fill.per)} ${safeTerm(fill.provider)} ${safeTerm(fill.size)} ${safeTerm(fill.region ?? "-")} ${pc3.dim(fill.createdAt)}${statusNote}`
2067
+ ` ${pc3.dim(fill.id)} ${lane(fill.useCase)} ${formatRate2(fill.usd, fill.per)} ${safeTerm(fill.provider)} ${safeTerm(fill.size)} ${safeTerm(fill.region ?? "-")} ${pc3.dim(fill.createdAt)}${statusNote}`
2005
2068
  );
2006
2069
  }
2007
2070
  return lines.join("\n");
@@ -2064,7 +2127,7 @@ function parseTopupAmount(value) {
2064
2127
  return usd;
2065
2128
  }
2066
2129
  function formatCap(cap) {
2067
- return cap === null ? "No market cap \u2014 market-placed jobs need their own bid to fill." : `market cap ${formatRate(cap.usd, cap.per)}`;
2130
+ return cap === null ? "No market cap \u2014 market-placed jobs need their own bid to fill." : `market cap ${formatRate2(cap.usd, cap.per)}`;
2068
2131
  }
2069
2132
  function formatBidRow(bid) {
2070
2133
  const status = bid.status === "open" ? pc3.green("open") : bid.status === "filled" ? pc3.cyan("filled") : pc3.gray("cancelled");
@@ -2074,7 +2137,7 @@ function formatBidRow(bid) {
2074
2137
  pc3.dim(bid.useCase === "sandbox" ? "sandbox" : "actions"),
2075
2138
  safeTerm(bid.size),
2076
2139
  safeTerm(bid.region ?? "any region"),
2077
- `\u2264 ${formatRate(bid.maxUsd, bid.per)}`,
2140
+ `\u2264 ${formatRate2(bid.maxUsd, bid.per)}`,
2078
2141
  pc3.dim(bid.expiresAt ? `expires ${bid.expiresAt}` : "standing")
2079
2142
  ].join(" ");
2080
2143
  }
@@ -2104,7 +2167,7 @@ function formatPurchaseRow(p2) {
2104
2167
  cost.padStart(10),
2105
2168
  pc3.cyan(safeTerm(p2.sellerName)),
2106
2169
  pc3.dim(`${safeTerm(p2.provider)}/${safeTerm(p2.region ?? "any")}`),
2107
- formatRate(p2.usd, p2.per),
2170
+ formatRate2(p2.usd, p2.per),
2108
2171
  p2.secondsBilled !== null ? pc3.dim(`${p2.secondsBilled}s`) : "",
2109
2172
  p2.status === "replaced" ? pc3.yellow("replaced") : "",
2110
2173
  pc3.dim(p2.runId ? `run ${p2.runId}` : p2.sandboxId ? `sandbox ${p2.sandboxId}` : "")
@@ -2173,7 +2236,7 @@ function registerMarketCommands(program2) {
2173
2236
  listingPatchBody(listingId, { price: opts.price, per: opts.per })
2174
2237
  );
2175
2238
  output(opts, result, (r) => {
2176
- const rate = r.ask.pendingUsd !== null && r.ask.pendingPer !== null ? `${formatRate(r.ask.pendingUsd, r.ask.pendingPer)} ${pc3.dim("(applies next window)")}` : formatRate(r.ask.usd, r.ask.per);
2239
+ const rate = r.ask.pendingUsd !== null && r.ask.pendingPer !== null ? `${formatRate2(r.ask.pendingUsd, r.ask.pendingPer)} ${pc3.dim("(applies next window)")}` : formatRate2(r.ask.usd, r.ask.per);
2177
2240
  console.log(`repriced ${pc3.cyan(r.ask.id)} ${rate}`);
2178
2241
  });
2179
2242
  } catch (e) {