mirror of
https://github.com/modelstudioai/cli.git
synced 2026-09-14 19:49:23 +08:00
fix: fix variable name
This commit is contained in:
@@ -46,11 +46,11 @@ export default defineCommand({
|
||||
const total = response.data?.total;
|
||||
|
||||
// Normalize to consistent structure for both text/json output.
|
||||
const items = files.map((f) => ({
|
||||
file_id: f.file_id ?? "",
|
||||
name: f.name ?? "",
|
||||
size: f.size !== undefined ? `${(f.size / 1024).toFixed(1)} KB` : "?",
|
||||
purpose: f.purpose ?? "",
|
||||
const items = files.map((item) => ({
|
||||
file_id: item.file_id ?? "",
|
||||
name: item.name ?? "",
|
||||
size: item.size !== undefined ? `${(item.size / 1024).toFixed(1)} KB` : "?",
|
||||
purpose: item.purpose ?? "",
|
||||
}));
|
||||
|
||||
if (format === "json") {
|
||||
|
||||
@@ -13,20 +13,21 @@ import {
|
||||
import { failIfMissing } from "../../output/prompt.ts";
|
||||
import { emitResult, emitBare } from "../../output/output.ts";
|
||||
|
||||
function formatIssue(i: ValidationIssue): string {
|
||||
function formatIssue(issue: ValidationIssue): string {
|
||||
const where: string[] = [];
|
||||
if (i.line !== undefined) where.push(`line ${i.line}`);
|
||||
if (i.path) where.push(i.path);
|
||||
if (issue.line !== undefined) where.push(`line ${issue.line}`);
|
||||
if (issue.path) where.push(issue.path);
|
||||
const tag = where.length ? ` [${where.join(" · ")}]` : "";
|
||||
return ` ${i.severity.toUpperCase()} ${i.code}${tag}: ${i.message}`;
|
||||
return ` ${issue.severity.toUpperCase()} ${issue.code}${tag}: ${issue.message}`;
|
||||
}
|
||||
|
||||
function formatStats(r: ValidationResult): string[] {
|
||||
function formatStats(result: ValidationResult): string[] {
|
||||
const out: string[] = [];
|
||||
if (r.stats.totalRecords !== undefined) out.push(`records: ${r.stats.totalRecords}`);
|
||||
if (r.stats.sampledRecords !== undefined) out.push(`sampled: ${r.stats.sampledRecords}`);
|
||||
if (r.stats.bytes !== undefined) out.push(`bytes: ${r.stats.bytes}`);
|
||||
if (r.stats.durationMs !== undefined) out.push(`took: ${r.stats.durationMs}ms`);
|
||||
if (result.stats.totalRecords !== undefined) out.push(`records: ${result.stats.totalRecords}`);
|
||||
if (result.stats.sampledRecords !== undefined)
|
||||
out.push(`sampled: ${result.stats.sampledRecords}`);
|
||||
if (result.stats.bytes !== undefined) out.push(`bytes: ${result.stats.bytes}`);
|
||||
if (result.stats.durationMs !== undefined) out.push(`took: ${result.stats.durationMs}ms`);
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -99,14 +100,14 @@ export default defineCommand({
|
||||
|
||||
if (result.errors.length) {
|
||||
emitBare(`Errors (${result.errors.length}):`);
|
||||
for (const e of result.errors.slice(0, 20)) emitBare(formatIssue(e));
|
||||
for (const error of result.errors.slice(0, 20)) emitBare(formatIssue(error));
|
||||
if (result.errors.length > 20) {
|
||||
emitBare(` … and ${result.errors.length - 20} more.`);
|
||||
}
|
||||
}
|
||||
if (result.warnings.length) {
|
||||
emitBare(`Warnings (${result.warnings.length}):`);
|
||||
for (const w of result.warnings.slice(0, 10)) emitBare(formatIssue(w));
|
||||
for (const warning of result.warnings.slice(0, 10)) emitBare(formatIssue(warning));
|
||||
if (result.warnings.length > 10) {
|
||||
emitBare(` … and ${result.warnings.length - 10} more.`);
|
||||
}
|
||||
|
||||
@@ -270,17 +270,17 @@ export default defineCommand({
|
||||
}
|
||||
|
||||
const response = await createDeployment(config, body as never);
|
||||
const d = response.output ?? response.data;
|
||||
const deployment = response.output ?? response.data;
|
||||
|
||||
if (config.quiet) {
|
||||
emitBare(d?.deployed_model ?? "");
|
||||
emitBare(deployment?.deployed_model ?? "");
|
||||
} else if (format === "text") {
|
||||
emitBare(`Created deployment.`);
|
||||
if (d?.deployed_model) emitBare(` deployed_model: ${d.deployed_model}`);
|
||||
if (d?.status) emitBare(` status: ${d.status}`);
|
||||
if (d?.plan) emitBare(` plan: ${d.plan}`);
|
||||
if (deployment?.deployed_model) emitBare(` deployed_model: ${deployment.deployed_model}`);
|
||||
if (deployment?.status) emitBare(` status: ${deployment.status}`);
|
||||
if (deployment?.plan) emitBare(` plan: ${deployment.plan}`);
|
||||
emitBare(
|
||||
`\nNext: track readiness with: bl deploy get --deployed-model ${d?.deployed_model ?? "<id>"}`,
|
||||
`\nNext: track readiness with: bl deploy get --deployed-model ${deployment?.deployed_model ?? "<id>"}`,
|
||||
);
|
||||
} else {
|
||||
emitResult(response, format);
|
||||
|
||||
@@ -55,8 +55,8 @@ export default defineCommand({
|
||||
if (!flags.skipPrecheck) {
|
||||
try {
|
||||
const get = await getDeployment(config, deployedModel!);
|
||||
const d = get.output ?? get.data;
|
||||
const status = (d?.status ?? "").toUpperCase();
|
||||
const deployment = get.output ?? get.data;
|
||||
const status = (deployment?.status ?? "").toUpperCase();
|
||||
if (status && status !== "STOPPED" && status !== "FAILED") {
|
||||
throw new BailianError(
|
||||
`Deployment ${deployedModel} is ${status}. Only STOPPED / FAILED deployments can be deleted. ` +
|
||||
|
||||
@@ -35,32 +35,32 @@ export default defineCommand({
|
||||
}
|
||||
|
||||
const response = await getDeployment(config, deployedModel!);
|
||||
const d = response.output ?? response.data;
|
||||
const deployment = response.output ?? response.data;
|
||||
|
||||
if (!d) {
|
||||
if (!deployment) {
|
||||
emitBare(`No data returned for ${deployedModel}`);
|
||||
return;
|
||||
}
|
||||
|
||||
const item: Record<string, unknown> = {
|
||||
deployed_model: d.deployed_model ?? deployedModel,
|
||||
deployed_name: d.name ?? "",
|
||||
model_name: d.model_name ?? "",
|
||||
base_model: d.base_model ?? "",
|
||||
status: d.status ?? "",
|
||||
plan: d.plan ?? "",
|
||||
deployed_model: deployment.deployed_model ?? deployedModel,
|
||||
deployed_name: deployment.name ?? "",
|
||||
model_name: deployment.model_name ?? "",
|
||||
base_model: deployment.base_model ?? "",
|
||||
status: deployment.status ?? "",
|
||||
plan: deployment.plan ?? "",
|
||||
};
|
||||
if (d.model_unit_spec) item.model_unit_spec = d.model_unit_spec;
|
||||
if (d.charge_type) item.charge_type = d.charge_type;
|
||||
if (d.capacity !== undefined) item.capacity = d.capacity;
|
||||
if (d.base_capacity !== undefined) item.base_capacity = d.base_capacity;
|
||||
if (d.ready_capacity !== undefined) item.ready_capacity = d.ready_capacity;
|
||||
if (d.rpm_limit !== undefined) item.rpm_limit = d.rpm_limit;
|
||||
if (d.tpm_limit !== undefined) item.tpm_limit = d.tpm_limit;
|
||||
if (d.input_tpm !== undefined) item.input_tpm = d.input_tpm;
|
||||
if (d.output_tpm !== undefined) item.output_tpm = d.output_tpm;
|
||||
if (d.gmt_create) item.created_at = d.gmt_create;
|
||||
if (d.gmt_modified) item.updated_at = d.gmt_modified;
|
||||
if (deployment.model_unit_spec) item.model_unit_spec = deployment.model_unit_spec;
|
||||
if (deployment.charge_type) item.charge_type = deployment.charge_type;
|
||||
if (deployment.capacity !== undefined) item.capacity = deployment.capacity;
|
||||
if (deployment.base_capacity !== undefined) item.base_capacity = deployment.base_capacity;
|
||||
if (deployment.ready_capacity !== undefined) item.ready_capacity = deployment.ready_capacity;
|
||||
if (deployment.rpm_limit !== undefined) item.rpm_limit = deployment.rpm_limit;
|
||||
if (deployment.tpm_limit !== undefined) item.tpm_limit = deployment.tpm_limit;
|
||||
if (deployment.input_tpm !== undefined) item.input_tpm = deployment.input_tpm;
|
||||
if (deployment.output_tpm !== undefined) item.output_tpm = deployment.output_tpm;
|
||||
if (deployment.gmt_create) item.created_at = deployment.gmt_create;
|
||||
if (deployment.gmt_modified) item.updated_at = deployment.gmt_modified;
|
||||
|
||||
if (format === "json") {
|
||||
emitResult(item, format);
|
||||
@@ -68,10 +68,10 @@ export default defineCommand({
|
||||
}
|
||||
|
||||
// text / quiet — fixed-width label column for alignment
|
||||
const label = (k: string) => `${k}:`.padEnd(18);
|
||||
for (const [k, v] of Object.entries(item)) {
|
||||
if (v === "" || v === undefined) continue;
|
||||
emitBare(`${label(k)}${v}`);
|
||||
const label = (key: string) => `${key}:`.padEnd(18);
|
||||
for (const [key, value] of Object.entries(item)) {
|
||||
if (value === "" || value === undefined) continue;
|
||||
emitBare(`${label(key)}${value}`);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -45,13 +45,13 @@ export default defineCommand({
|
||||
const deployments = payload?.deployments ?? [];
|
||||
const total = payload?.total;
|
||||
|
||||
const items = deployments.map((d) => ({
|
||||
deployed_model: d.deployed_model ?? "",
|
||||
model_name: d.model_name ?? "",
|
||||
status: d.status ?? "",
|
||||
plan: d.plan ?? "",
|
||||
capacity: d.capacity !== undefined ? String(d.capacity) : "",
|
||||
created_at: d.gmt_create ?? "",
|
||||
const items = deployments.map((item) => ({
|
||||
deployed_model: item.deployed_model ?? "",
|
||||
model_name: item.model_name ?? "",
|
||||
status: item.status ?? "",
|
||||
plan: item.plan ?? "",
|
||||
capacity: item.capacity !== undefined ? String(item.capacity) : "",
|
||||
created_at: item.gmt_create ?? "",
|
||||
}));
|
||||
|
||||
if (format === "json") {
|
||||
|
||||
@@ -94,12 +94,12 @@ export default defineCommand({
|
||||
}
|
||||
|
||||
const response = await scaleDeployment(config, deployedModel!, body);
|
||||
const d = response.output ?? response.data;
|
||||
const deployment = response.output ?? response.data;
|
||||
|
||||
if (config.quiet) {
|
||||
emitBare(deployedModel!);
|
||||
} else if (format === "text") {
|
||||
const cap = d?.capacity !== undefined ? ` (capacity=${d.capacity})` : "";
|
||||
const cap = deployment?.capacity !== undefined ? ` (capacity=${deployment.capacity})` : "";
|
||||
emitBare(`Scaled ${deployedModel}${cap}.`);
|
||||
} else {
|
||||
emitResult(response, format);
|
||||
|
||||
@@ -86,14 +86,14 @@ export default defineCommand({
|
||||
}
|
||||
|
||||
const response = await updateDeployment(config, deployedModel!, body);
|
||||
const d = response.output ?? response.data;
|
||||
const deployment = response.output ?? response.data;
|
||||
|
||||
if (config.quiet) {
|
||||
emitBare(deployedModel!);
|
||||
} else if (format === "text") {
|
||||
const parts: string[] = [];
|
||||
if (d?.rpm_limit !== undefined) parts.push(`rpm_limit=${d.rpm_limit}`);
|
||||
if (d?.tpm_limit !== undefined) parts.push(`tpm_limit=${d.tpm_limit}`);
|
||||
if (deployment?.rpm_limit !== undefined) parts.push(`rpm_limit=${deployment.rpm_limit}`);
|
||||
if (deployment?.tpm_limit !== undefined) parts.push(`tpm_limit=${deployment.tpm_limit}`);
|
||||
const summary = parts.length ? ` (${parts.join(", ")})` : "";
|
||||
emitBare(`Updated ${deployedModel}${summary}.`);
|
||||
} else {
|
||||
|
||||
@@ -38,10 +38,10 @@ export default defineCommand({
|
||||
const ckpts = Array.isArray(payload) ? payload : (payload?.checkpoints ?? []);
|
||||
const total = Array.isArray(payload) ? payload.length : (payload?.total ?? ckpts.length);
|
||||
|
||||
const items = ckpts.map((c) => ({
|
||||
checkpoint: c.checkpoint ?? c.checkpoint_id ?? "",
|
||||
step: c.step !== undefined ? String(c.step) : "",
|
||||
status: c.status ?? "",
|
||||
const items = ckpts.map((item) => ({
|
||||
checkpoint: item.checkpoint ?? item.checkpoint_id ?? "",
|
||||
step: item.step !== undefined ? String(item.step) : "",
|
||||
status: item.status ?? "",
|
||||
}));
|
||||
|
||||
if (format === "json") {
|
||||
|
||||
@@ -45,13 +45,13 @@ export default defineCommand({
|
||||
const jobs = payload?.jobs ?? [];
|
||||
const total = payload?.total;
|
||||
|
||||
const items = jobs.map((j) => ({
|
||||
job_id: j.job_id ?? "",
|
||||
base_model: j.model ?? "",
|
||||
status: j.status ?? "",
|
||||
training_type: j.training_type ?? "",
|
||||
output_model: j.finetuned_output ?? "",
|
||||
created_at: j.create_time ?? j.gmt_create ?? "",
|
||||
const items = jobs.map((item) => ({
|
||||
job_id: item.job_id ?? "",
|
||||
base_model: item.model ?? "",
|
||||
status: item.status ?? "",
|
||||
training_type: item.training_type ?? "",
|
||||
output_model: item.finetuned_output ?? "",
|
||||
created_at: item.create_time ?? item.gmt_create ?? "",
|
||||
}));
|
||||
|
||||
if (format === "json") {
|
||||
|
||||
@@ -15,10 +15,10 @@ import { emitResult, emitBare } from "../../output/output.ts";
|
||||
*/
|
||||
function renderEntry(entry: FineTuneLogEntry | string): string {
|
||||
if (typeof entry === "string") return entry;
|
||||
const e = entry as Record<string, unknown>;
|
||||
const ts = (e.timestamp ?? e.time ?? e.create_time ?? "") as string;
|
||||
const level = (e.level ?? "") as string;
|
||||
const msg = (e.message ?? e.msg ?? e.log ?? "") as string;
|
||||
const record = entry as Record<string, unknown>;
|
||||
const ts = (record.timestamp ?? record.time ?? record.create_time ?? "") as string;
|
||||
const level = (record.level ?? "") as string;
|
||||
const msg = (record.message ?? record.msg ?? record.log ?? "") as string;
|
||||
if (msg || ts || level) {
|
||||
return [ts, level, msg].filter(Boolean).join("\t");
|
||||
}
|
||||
|
||||
@@ -140,9 +140,9 @@ function inspectMessageObject(msg: unknown, lineNo: number, path: string): Valid
|
||||
);
|
||||
return out;
|
||||
}
|
||||
const m = msg as Record<string, unknown>;
|
||||
const role = m.role;
|
||||
const content = m.content;
|
||||
const record = msg as Record<string, unknown>;
|
||||
const role = record.role;
|
||||
const content = record.content;
|
||||
if (typeof role !== "string" || !VALID_ROLES.has(role)) {
|
||||
out.push(
|
||||
makeIssue(
|
||||
|
||||
Reference in New Issue
Block a user