Skip to content

Commit 4383eeb

Browse files
committed
fix: fix variable name
1 parent 1851ec8 commit 4383eeb

12 files changed

Lines changed: 78 additions & 77 deletions

File tree

packages/cli/src/commands/dataset/list.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ export default defineCommand({
4646
const total = response.data?.total;
4747

4848
// Normalize to consistent structure for both text/json output.
49-
const items = files.map((f) => ({
50-
file_id: f.file_id ?? "",
51-
name: f.name ?? "",
52-
size: f.size !== undefined ? `${(f.size / 1024).toFixed(1)} KB` : "?",
53-
purpose: f.purpose ?? "",
49+
const items = files.map((item) => ({
50+
file_id: item.file_id ?? "",
51+
name: item.name ?? "",
52+
size: item.size !== undefined ? `${(item.size / 1024).toFixed(1)} KB` : "?",
53+
purpose: item.purpose ?? "",
5454
}));
5555

5656
if (format === "json") {

packages/cli/src/commands/dataset/validate.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,21 @@ import {
1313
import { failIfMissing } from "../../output/prompt.ts";
1414
import { emitResult, emitBare } from "../../output/output.ts";
1515

16-
function formatIssue(i: ValidationIssue): string {
16+
function formatIssue(issue: ValidationIssue): string {
1717
const where: string[] = [];
18-
if (i.line !== undefined) where.push(`line ${i.line}`);
19-
if (i.path) where.push(i.path);
18+
if (issue.line !== undefined) where.push(`line ${issue.line}`);
19+
if (issue.path) where.push(issue.path);
2020
const tag = where.length ? ` [${where.join(" · ")}]` : "";
21-
return ` ${i.severity.toUpperCase()} ${i.code}${tag}: ${i.message}`;
21+
return ` ${issue.severity.toUpperCase()} ${issue.code}${tag}: ${issue.message}`;
2222
}
2323

24-
function formatStats(r: ValidationResult): string[] {
24+
function formatStats(result: ValidationResult): string[] {
2525
const out: string[] = [];
26-
if (r.stats.totalRecords !== undefined) out.push(`records: ${r.stats.totalRecords}`);
27-
if (r.stats.sampledRecords !== undefined) out.push(`sampled: ${r.stats.sampledRecords}`);
28-
if (r.stats.bytes !== undefined) out.push(`bytes: ${r.stats.bytes}`);
29-
if (r.stats.durationMs !== undefined) out.push(`took: ${r.stats.durationMs}ms`);
26+
if (result.stats.totalRecords !== undefined) out.push(`records: ${result.stats.totalRecords}`);
27+
if (result.stats.sampledRecords !== undefined)
28+
out.push(`sampled: ${result.stats.sampledRecords}`);
29+
if (result.stats.bytes !== undefined) out.push(`bytes: ${result.stats.bytes}`);
30+
if (result.stats.durationMs !== undefined) out.push(`took: ${result.stats.durationMs}ms`);
3031
return out;
3132
}
3233

@@ -99,14 +100,14 @@ export default defineCommand({
99100

100101
if (result.errors.length) {
101102
emitBare(`Errors (${result.errors.length}):`);
102-
for (const e of result.errors.slice(0, 20)) emitBare(formatIssue(e));
103+
for (const error of result.errors.slice(0, 20)) emitBare(formatIssue(error));
103104
if (result.errors.length > 20) {
104105
emitBare(` … and ${result.errors.length - 20} more.`);
105106
}
106107
}
107108
if (result.warnings.length) {
108109
emitBare(`Warnings (${result.warnings.length}):`);
109-
for (const w of result.warnings.slice(0, 10)) emitBare(formatIssue(w));
110+
for (const warning of result.warnings.slice(0, 10)) emitBare(formatIssue(warning));
110111
if (result.warnings.length > 10) {
111112
emitBare(` … and ${result.warnings.length - 10} more.`);
112113
}

packages/cli/src/commands/deploy/create.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -270,17 +270,17 @@ export default defineCommand({
270270
}
271271

272272
const response = await createDeployment(config, body as never);
273-
const d = response.output ?? response.data;
273+
const deployment = response.output ?? response.data;
274274

275275
if (config.quiet) {
276-
emitBare(d?.deployed_model ?? "");
276+
emitBare(deployment?.deployed_model ?? "");
277277
} else if (format === "text") {
278278
emitBare(`Created deployment.`);
279-
if (d?.deployed_model) emitBare(` deployed_model: ${d.deployed_model}`);
280-
if (d?.status) emitBare(` status: ${d.status}`);
281-
if (d?.plan) emitBare(` plan: ${d.plan}`);
279+
if (deployment?.deployed_model) emitBare(` deployed_model: ${deployment.deployed_model}`);
280+
if (deployment?.status) emitBare(` status: ${deployment.status}`);
281+
if (deployment?.plan) emitBare(` plan: ${deployment.plan}`);
282282
emitBare(
283-
`\nNext: track readiness with: bl deploy get --deployed-model ${d?.deployed_model ?? "<id>"}`,
283+
`\nNext: track readiness with: bl deploy get --deployed-model ${deployment?.deployed_model ?? "<id>"}`,
284284
);
285285
} else {
286286
emitResult(response, format);

packages/cli/src/commands/deploy/delete.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ export default defineCommand({
5555
if (!flags.skipPrecheck) {
5656
try {
5757
const get = await getDeployment(config, deployedModel!);
58-
const d = get.output ?? get.data;
59-
const status = (d?.status ?? "").toUpperCase();
58+
const deployment = get.output ?? get.data;
59+
const status = (deployment?.status ?? "").toUpperCase();
6060
if (status && status !== "STOPPED" && status !== "FAILED") {
6161
throw new BailianError(
6262
`Deployment ${deployedModel} is ${status}. Only STOPPED / FAILED deployments can be deleted. ` +

packages/cli/src/commands/deploy/get.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,43 +35,43 @@ export default defineCommand({
3535
}
3636

3737
const response = await getDeployment(config, deployedModel!);
38-
const d = response.output ?? response.data;
38+
const deployment = response.output ?? response.data;
3939

40-
if (!d) {
40+
if (!deployment) {
4141
emitBare(`No data returned for ${deployedModel}`);
4242
return;
4343
}
4444

4545
const item: Record<string, unknown> = {
46-
deployed_model: d.deployed_model ?? deployedModel,
47-
deployed_name: d.name ?? "",
48-
model_name: d.model_name ?? "",
49-
base_model: d.base_model ?? "",
50-
status: d.status ?? "",
51-
plan: d.plan ?? "",
46+
deployed_model: deployment.deployed_model ?? deployedModel,
47+
deployed_name: deployment.name ?? "",
48+
model_name: deployment.model_name ?? "",
49+
base_model: deployment.base_model ?? "",
50+
status: deployment.status ?? "",
51+
plan: deployment.plan ?? "",
5252
};
53-
if (d.model_unit_spec) item.model_unit_spec = d.model_unit_spec;
54-
if (d.charge_type) item.charge_type = d.charge_type;
55-
if (d.capacity !== undefined) item.capacity = d.capacity;
56-
if (d.base_capacity !== undefined) item.base_capacity = d.base_capacity;
57-
if (d.ready_capacity !== undefined) item.ready_capacity = d.ready_capacity;
58-
if (d.rpm_limit !== undefined) item.rpm_limit = d.rpm_limit;
59-
if (d.tpm_limit !== undefined) item.tpm_limit = d.tpm_limit;
60-
if (d.input_tpm !== undefined) item.input_tpm = d.input_tpm;
61-
if (d.output_tpm !== undefined) item.output_tpm = d.output_tpm;
62-
if (d.gmt_create) item.created_at = d.gmt_create;
63-
if (d.gmt_modified) item.updated_at = d.gmt_modified;
53+
if (deployment.model_unit_spec) item.model_unit_spec = deployment.model_unit_spec;
54+
if (deployment.charge_type) item.charge_type = deployment.charge_type;
55+
if (deployment.capacity !== undefined) item.capacity = deployment.capacity;
56+
if (deployment.base_capacity !== undefined) item.base_capacity = deployment.base_capacity;
57+
if (deployment.ready_capacity !== undefined) item.ready_capacity = deployment.ready_capacity;
58+
if (deployment.rpm_limit !== undefined) item.rpm_limit = deployment.rpm_limit;
59+
if (deployment.tpm_limit !== undefined) item.tpm_limit = deployment.tpm_limit;
60+
if (deployment.input_tpm !== undefined) item.input_tpm = deployment.input_tpm;
61+
if (deployment.output_tpm !== undefined) item.output_tpm = deployment.output_tpm;
62+
if (deployment.gmt_create) item.created_at = deployment.gmt_create;
63+
if (deployment.gmt_modified) item.updated_at = deployment.gmt_modified;
6464

6565
if (format === "json") {
6666
emitResult(item, format);
6767
return;
6868
}
6969

7070
// text / quiet — fixed-width label column for alignment
71-
const label = (k: string) => `${k}:`.padEnd(18);
72-
for (const [k, v] of Object.entries(item)) {
73-
if (v === "" || v === undefined) continue;
74-
emitBare(`${label(k)}${v}`);
71+
const label = (key: string) => `${key}:`.padEnd(18);
72+
for (const [key, value] of Object.entries(item)) {
73+
if (value === "" || value === undefined) continue;
74+
emitBare(`${label(key)}${value}`);
7575
}
7676
},
7777
});

packages/cli/src/commands/deploy/list.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ export default defineCommand({
4545
const deployments = payload?.deployments ?? [];
4646
const total = payload?.total;
4747

48-
const items = deployments.map((d) => ({
49-
deployed_model: d.deployed_model ?? "",
50-
model_name: d.model_name ?? "",
51-
status: d.status ?? "",
52-
plan: d.plan ?? "",
53-
capacity: d.capacity !== undefined ? String(d.capacity) : "",
54-
created_at: d.gmt_create ?? "",
48+
const items = deployments.map((item) => ({
49+
deployed_model: item.deployed_model ?? "",
50+
model_name: item.model_name ?? "",
51+
status: item.status ?? "",
52+
plan: item.plan ?? "",
53+
capacity: item.capacity !== undefined ? String(item.capacity) : "",
54+
created_at: item.gmt_create ?? "",
5555
}));
5656

5757
if (format === "json") {

packages/cli/src/commands/deploy/scale.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,12 @@ export default defineCommand({
9494
}
9595

9696
const response = await scaleDeployment(config, deployedModel!, body);
97-
const d = response.output ?? response.data;
97+
const deployment = response.output ?? response.data;
9898

9999
if (config.quiet) {
100100
emitBare(deployedModel!);
101101
} else if (format === "text") {
102-
const cap = d?.capacity !== undefined ? ` (capacity=${d.capacity})` : "";
102+
const cap = deployment?.capacity !== undefined ? ` (capacity=${deployment.capacity})` : "";
103103
emitBare(`Scaled ${deployedModel}${cap}.`);
104104
} else {
105105
emitResult(response, format);

packages/cli/src/commands/deploy/update.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,14 @@ export default defineCommand({
8686
}
8787

8888
const response = await updateDeployment(config, deployedModel!, body);
89-
const d = response.output ?? response.data;
89+
const deployment = response.output ?? response.data;
9090

9191
if (config.quiet) {
9292
emitBare(deployedModel!);
9393
} else if (format === "text") {
9494
const parts: string[] = [];
95-
if (d?.rpm_limit !== undefined) parts.push(`rpm_limit=${d.rpm_limit}`);
96-
if (d?.tpm_limit !== undefined) parts.push(`tpm_limit=${d.tpm_limit}`);
95+
if (deployment?.rpm_limit !== undefined) parts.push(`rpm_limit=${deployment.rpm_limit}`);
96+
if (deployment?.tpm_limit !== undefined) parts.push(`tpm_limit=${deployment.tpm_limit}`);
9797
const summary = parts.length ? ` (${parts.join(", ")})` : "";
9898
emitBare(`Updated ${deployedModel}${summary}.`);
9999
} else {

packages/cli/src/commands/finetune/checkpoints.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ export default defineCommand({
3838
const ckpts = Array.isArray(payload) ? payload : (payload?.checkpoints ?? []);
3939
const total = Array.isArray(payload) ? payload.length : (payload?.total ?? ckpts.length);
4040

41-
const items = ckpts.map((c) => ({
42-
checkpoint: c.checkpoint ?? c.checkpoint_id ?? "",
43-
step: c.step !== undefined ? String(c.step) : "",
44-
status: c.status ?? "",
41+
const items = ckpts.map((item) => ({
42+
checkpoint: item.checkpoint ?? item.checkpoint_id ?? "",
43+
step: item.step !== undefined ? String(item.step) : "",
44+
status: item.status ?? "",
4545
}));
4646

4747
if (format === "json") {

packages/cli/src/commands/finetune/list.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ export default defineCommand({
4545
const jobs = payload?.jobs ?? [];
4646
const total = payload?.total;
4747

48-
const items = jobs.map((j) => ({
49-
job_id: j.job_id ?? "",
50-
base_model: j.model ?? "",
51-
status: j.status ?? "",
52-
training_type: j.training_type ?? "",
53-
output_model: j.finetuned_output ?? "",
54-
created_at: j.create_time ?? j.gmt_create ?? "",
48+
const items = jobs.map((item) => ({
49+
job_id: item.job_id ?? "",
50+
base_model: item.model ?? "",
51+
status: item.status ?? "",
52+
training_type: item.training_type ?? "",
53+
output_model: item.finetuned_output ?? "",
54+
created_at: item.create_time ?? item.gmt_create ?? "",
5555
}));
5656

5757
if (format === "json") {

0 commit comments

Comments
 (0)