@arizeai/phoenix-cli 0.1.0 → 0.2.0
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/README.md +101 -1
- package/build/cli.d.ts.map +1 -1
- package/build/cli.js +5 -1
- package/build/cli.js.map +1 -1
- package/build/client.d.ts +18 -0
- package/build/client.d.ts.map +1 -1
- package/build/client.js +39 -0
- package/build/client.js.map +1 -1
- package/build/commands/dataset.d.ts +6 -0
- package/build/commands/dataset.d.ts.map +1 -0
- package/build/commands/dataset.js +153 -0
- package/build/commands/dataset.js.map +1 -0
- package/build/commands/datasets.d.ts +6 -0
- package/build/commands/datasets.d.ts.map +1 -0
- package/build/commands/datasets.js +97 -0
- package/build/commands/datasets.js.map +1 -0
- package/build/commands/experiment.d.ts +6 -0
- package/build/commands/experiment.d.ts.map +1 -0
- package/build/commands/experiment.js +106 -0
- package/build/commands/experiment.js.map +1 -0
- package/build/commands/experiments.d.ts +6 -0
- package/build/commands/experiments.d.ts.map +1 -0
- package/build/commands/experiments.js +201 -0
- package/build/commands/experiments.js.map +1 -0
- package/build/commands/formatDataset.d.ts +26 -0
- package/build/commands/formatDataset.d.ts.map +1 -0
- package/build/commands/formatDataset.js +60 -0
- package/build/commands/formatDataset.js.map +1 -0
- package/build/commands/formatDatasets.d.ts +27 -0
- package/build/commands/formatDatasets.d.ts.map +1 -0
- package/build/commands/formatDatasets.js +76 -0
- package/build/commands/formatDatasets.js.map +1 -0
- package/build/commands/formatExperiment.d.ts +35 -0
- package/build/commands/formatExperiment.d.ts.map +1 -0
- package/build/commands/formatExperiment.js +191 -0
- package/build/commands/formatExperiment.js.map +1 -0
- package/build/commands/formatExperiments.d.ts +16 -0
- package/build/commands/formatExperiments.d.ts.map +1 -0
- package/build/commands/formatExperiments.js +53 -0
- package/build/commands/formatExperiments.js.map +1 -0
- package/build/commands/index.d.ts +4 -0
- package/build/commands/index.d.ts.map +1 -1
- package/build/commands/index.js +4 -0
- package/build/commands/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"experiments.d.ts","sourceRoot":"","sources":["../../src/commands/experiments.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA6OpC;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,OAAO,CA0BlD"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { createPhoenixClient, resolveDatasetId } from "../client.js";
|
|
2
|
+
import { getConfigErrorMessage, resolveConfig } from "../config.js";
|
|
3
|
+
import { writeError, writeOutput, writeProgress } from "../io.js";
|
|
4
|
+
import { formatExperimentsOutput, } from "./formatExperiments.js";
|
|
5
|
+
import { Command } from "commander";
|
|
6
|
+
import * as fs from "fs";
|
|
7
|
+
import * as path from "path";
|
|
8
|
+
/**
|
|
9
|
+
* Fetch experiments for a dataset from Phoenix
|
|
10
|
+
*/
|
|
11
|
+
async function fetchExperiments(client, datasetId, options = {}) {
|
|
12
|
+
const allExperiments = [];
|
|
13
|
+
let cursor;
|
|
14
|
+
const pageLimit = options.limit || 100;
|
|
15
|
+
do {
|
|
16
|
+
const response = await client.GET("/v1/datasets/{dataset_id}/experiments", {
|
|
17
|
+
params: {
|
|
18
|
+
path: {
|
|
19
|
+
dataset_id: datasetId,
|
|
20
|
+
},
|
|
21
|
+
query: {
|
|
22
|
+
cursor,
|
|
23
|
+
limit: pageLimit,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
if (response.error || !response.data) {
|
|
28
|
+
throw new Error(`Failed to fetch experiments: ${response.error}`);
|
|
29
|
+
}
|
|
30
|
+
allExperiments.push(...response.data.data);
|
|
31
|
+
cursor = response.data.next_cursor || undefined;
|
|
32
|
+
// If we've fetched enough for the requested limit, stop
|
|
33
|
+
if (options.limit && allExperiments.length >= options.limit) {
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
} while (cursor);
|
|
37
|
+
return allExperiments;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Download experiment JSON data
|
|
41
|
+
*/
|
|
42
|
+
async function downloadExperimentJson(client, experimentId) {
|
|
43
|
+
const response = await client.GET("/v1/experiments/{experiment_id}/json", {
|
|
44
|
+
params: {
|
|
45
|
+
path: {
|
|
46
|
+
experiment_id: experimentId,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
parseAs: "text",
|
|
50
|
+
});
|
|
51
|
+
if (response.error || response.data === undefined) {
|
|
52
|
+
throw new Error(`Failed to download experiment: ${response.error}`);
|
|
53
|
+
}
|
|
54
|
+
return response.data;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Write experiments to directory
|
|
58
|
+
*/
|
|
59
|
+
async function writeExperimentsToDirectory(client, experiments, directory, options = {}) {
|
|
60
|
+
// Create directory if it doesn't exist
|
|
61
|
+
if (!fs.existsSync(directory)) {
|
|
62
|
+
fs.mkdirSync(directory, { recursive: true });
|
|
63
|
+
}
|
|
64
|
+
let completed = 0;
|
|
65
|
+
for (const experiment of experiments) {
|
|
66
|
+
try {
|
|
67
|
+
writeProgress({
|
|
68
|
+
message: `[${completed + 1}/${experiments.length}] Downloading experiment ${experiment.id}...`,
|
|
69
|
+
noProgress: options.noProgress,
|
|
70
|
+
});
|
|
71
|
+
const jsonData = await downloadExperimentJson(client, experiment.id);
|
|
72
|
+
const filename = `${experiment.id}.json`;
|
|
73
|
+
const filepath = path.join(directory, filename);
|
|
74
|
+
fs.writeFileSync(filepath, jsonData, "utf-8");
|
|
75
|
+
completed++;
|
|
76
|
+
writeProgress({
|
|
77
|
+
message: `[${completed}/${experiments.length}] Wrote ${filename}`,
|
|
78
|
+
noProgress: options.noProgress,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
writeProgress({
|
|
83
|
+
message: `Warning: Failed to download experiment ${experiment.id}: ${error instanceof Error ? error.message : String(error)}`,
|
|
84
|
+
noProgress: options.noProgress,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Experiments command handler
|
|
91
|
+
*/
|
|
92
|
+
async function experimentsHandler(directory, options) {
|
|
93
|
+
try {
|
|
94
|
+
const userSpecifiedFormat = process.argv.includes("--format") ||
|
|
95
|
+
process.argv.some((arg) => arg.startsWith("--format="));
|
|
96
|
+
// Resolve configuration
|
|
97
|
+
const config = resolveConfig({
|
|
98
|
+
cliOptions: {
|
|
99
|
+
endpoint: options.endpoint,
|
|
100
|
+
apiKey: options.apiKey,
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
// Validate that we have endpoint
|
|
104
|
+
if (!config.endpoint) {
|
|
105
|
+
const errors = [
|
|
106
|
+
"Phoenix endpoint not configured. Set PHOENIX_HOST environment variable or use --endpoint flag.",
|
|
107
|
+
];
|
|
108
|
+
writeError({ message: getConfigErrorMessage({ errors }) });
|
|
109
|
+
process.exit(1);
|
|
110
|
+
}
|
|
111
|
+
// Validate that we have dataset
|
|
112
|
+
if (!options.dataset) {
|
|
113
|
+
writeError({
|
|
114
|
+
message: "Dataset not specified. Use --dataset <name-or-id> to specify a dataset.",
|
|
115
|
+
});
|
|
116
|
+
process.exit(1);
|
|
117
|
+
}
|
|
118
|
+
// Create client
|
|
119
|
+
const client = createPhoenixClient({ config });
|
|
120
|
+
writeProgress({
|
|
121
|
+
message: `Resolving dataset: ${options.dataset}`,
|
|
122
|
+
noProgress: !options.progress,
|
|
123
|
+
});
|
|
124
|
+
// Resolve dataset ID
|
|
125
|
+
const datasetId = await resolveDatasetId({
|
|
126
|
+
client,
|
|
127
|
+
datasetIdentifier: options.dataset,
|
|
128
|
+
});
|
|
129
|
+
writeProgress({
|
|
130
|
+
message: `Fetching experiments for dataset ${datasetId}...`,
|
|
131
|
+
noProgress: !options.progress,
|
|
132
|
+
});
|
|
133
|
+
// Fetch experiments
|
|
134
|
+
const experiments = await fetchExperiments(client, datasetId, {
|
|
135
|
+
limit: options.limit,
|
|
136
|
+
});
|
|
137
|
+
if (experiments.length === 0) {
|
|
138
|
+
writeProgress({
|
|
139
|
+
message: "No experiments found",
|
|
140
|
+
noProgress: !options.progress,
|
|
141
|
+
});
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
writeProgress({
|
|
145
|
+
message: `Found ${experiments.length} experiment(s)`,
|
|
146
|
+
noProgress: !options.progress,
|
|
147
|
+
});
|
|
148
|
+
// Output experiments
|
|
149
|
+
if (directory) {
|
|
150
|
+
if (userSpecifiedFormat && options.format && options.format !== "json") {
|
|
151
|
+
writeError({
|
|
152
|
+
message: `Warning: --format is ignored when writing experiments to a directory; writing JSON files to ${directory}`,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
// Write to directory
|
|
156
|
+
writeProgress({
|
|
157
|
+
message: `Writing experiments to ${directory}...`,
|
|
158
|
+
noProgress: !options.progress,
|
|
159
|
+
});
|
|
160
|
+
await writeExperimentsToDirectory(client, experiments, directory, {
|
|
161
|
+
noProgress: !options.progress,
|
|
162
|
+
});
|
|
163
|
+
writeProgress({
|
|
164
|
+
message: `Done! Wrote ${experiments.length} experiment(s) to ${directory}`,
|
|
165
|
+
noProgress: !options.progress,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
// Write to stdout
|
|
170
|
+
const output = formatExperimentsOutput({
|
|
171
|
+
experiments,
|
|
172
|
+
format: options.format,
|
|
173
|
+
});
|
|
174
|
+
writeOutput({ message: output });
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
writeError({
|
|
179
|
+
message: `Error fetching experiments: ${error instanceof Error ? error.message : String(error)}`,
|
|
180
|
+
});
|
|
181
|
+
process.exit(1);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Create the experiments command
|
|
186
|
+
*/
|
|
187
|
+
export function createExperimentsCommand() {
|
|
188
|
+
const command = new Command("experiments");
|
|
189
|
+
command
|
|
190
|
+
.description("List experiments for a dataset")
|
|
191
|
+
.argument("[directory]", "Directory to write experiment files (optional, downloads full JSON data)")
|
|
192
|
+
.requiredOption("--dataset <name-or-id>", "Dataset name or ID (required)")
|
|
193
|
+
.option("--endpoint <url>", "Phoenix API endpoint")
|
|
194
|
+
.option("--api-key <key>", "Phoenix API key for authentication")
|
|
195
|
+
.option("--format <format>", "Output format: pretty, json, or raw", "pretty")
|
|
196
|
+
.option("--no-progress", "Disable progress indicators")
|
|
197
|
+
.option("--limit <number>", "Maximum number of experiments to fetch", parseInt)
|
|
198
|
+
.action(experimentsHandler);
|
|
199
|
+
return command;
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=experiments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"experiments.js","sourceRoot":"","sources":["../../src/commands/experiments.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE/D,OAAO,EACL,uBAAuB,GAExB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAa7B;;GAEG;AACH,KAAK,UAAU,gBAAgB,CAC7B,MAAqB,EACrB,SAAiB,EACjB,UAA8B,EAAE;IAEhC,MAAM,cAAc,GAAiB,EAAE,CAAC;IACxC,IAAI,MAA0B,CAAC;IAC/B,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,IAAI,GAAG,CAAC;IAEvC,GAAG,CAAC;QACF,MAAM,QAAQ,GAAG,M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AC9B,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,kBAAkB;YAClB,MAAM,MAAM,GAAG,uBAAuB,CAAC;gBACrC,WAAW;gBACX,MAAM,EAAE,OAAO,CAAC,MAAM;aACvB,CAAC,CAAC;YACH,WAAW,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,UAAU,CAAC;YACT,OAAO,EAAE,+BAA+B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;SACjG,CAAC,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,wBAAwB;IACtC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;IAE3C,OAAO;SACJ,WAAW,CAAC,gCAAgC,CAAC;SAC7C,QAAQ,CACP,aAAa,EACb,0EAA0E,CAC3E;SACA,cAAc,CAAC,wBAAwB,EAAE,+BAA+B,CAAC;SACzE,MAAM,CAAC,kBAAkB,EAAE,sBAAsB,CAAC;SAClD,MAAM,CAAC,iBAAiB,EAAE,oCAAoC,CAAC;SAC/D,MAAM,CACL,mBAAmB,EACnB,qCAAqC,EACrC,QAAQ,CACT;SACA,MAAM,CAAC,eAAe,EAAE,6BAA6B,CAAC;SACtD,MAAM,CACL,kBAAkB,EAClB,wCAAwC,EACxC,QAAQ,CACT;SACA,MAAM,CAAC,kBAAkB,CAAC,CAAC;IAE9B,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { componentsV1 } from "@arizeai/phoenix-client";
|
|
2
|
+
export type OutputFormat = "pretty" | "json" | "raw";
|
|
3
|
+
type DatasetExample = componentsV1["schemas"]["DatasetExample"];
|
|
4
|
+
export interface DatasetExamplesData {
|
|
5
|
+
dataset_id: string;
|
|
6
|
+
version_id: string;
|
|
7
|
+
filtered_splits?: string[];
|
|
8
|
+
examples: DatasetExample[];
|
|
9
|
+
}
|
|
10
|
+
export interface FormatDatasetExamplesOutputOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Dataset examples data to format.
|
|
13
|
+
*/
|
|
14
|
+
data: DatasetExamplesData;
|
|
15
|
+
/**
|
|
16
|
+
* Dataset name (for display purposes).
|
|
17
|
+
*/
|
|
18
|
+
datasetName?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Output format. Defaults to `"pretty"`.
|
|
21
|
+
*/
|
|
22
|
+
format?: OutputFormat;
|
|
23
|
+
}
|
|
24
|
+
export declare function formatDatasetExamplesOutput({ data, datasetName, format, }: FormatDatasetExamplesOutputOptions): string;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=formatDataset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatDataset.d.ts","sourceRoot":"","sources":["../../src/commands/formatDataset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,CAAC;AAErD,KAAK,cAAc,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC,gBAAgB,CAAC,CAAC;AAEhE,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,QAAQ,EAAE,cAAc,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,kCAAkC;IACjD;;OAEG;IACH,IAAI,EAAE,mBAAmB,CAAC;IAC1B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAED,wBAAgB,2BAA2B,CAAC,EAC1C,IAAI,EACJ,WAAW,EACX,MAAM,GACP,EAAE,kCAAkC,GAAG,MAAM,CAS7C"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export function formatDatasetExamplesOutput({ data, datasetName, format, }) {
|
|
2
|
+
const selected = format || "pretty";
|
|
3
|
+
if (selected === "raw") {
|
|
4
|
+
return JSON.stringify(data);
|
|
5
|
+
}
|
|
6
|
+
if (selected === "json") {
|
|
7
|
+
return JSON.stringify(data, null, 2);
|
|
8
|
+
}
|
|
9
|
+
return formatDatasetExamplesPretty(data, datasetName);
|
|
10
|
+
}
|
|
11
|
+
function formatDatasetExamplesPretty(data, datasetName) {
|
|
12
|
+
const lines = [];
|
|
13
|
+
// Header
|
|
14
|
+
const displayName = datasetName || data.dataset_id;
|
|
15
|
+
lines.push(`Dataset: ${displayName} (${data.dataset_id})`);
|
|
16
|
+
lines.push(`Version: ${data.version_id}`);
|
|
17
|
+
if (data.filtered_splits && data.filtered_splits.length > 0) {
|
|
18
|
+
lines.push(`Splits: ${data.filtered_splits.join(", ")}`);
|
|
19
|
+
}
|
|
20
|
+
lines.push(`Examples: ${data.examples.length}`);
|
|
21
|
+
lines.push("");
|
|
22
|
+
if (data.examples.length === 0) {
|
|
23
|
+
lines.push("No examples found");
|
|
24
|
+
return lines.join("\n");
|
|
25
|
+
}
|
|
26
|
+
// Examples
|
|
27
|
+
for (const example of data.examples) {
|
|
28
|
+
lines.push(`┌─ Example: ${example.id}`);
|
|
29
|
+
const inputPreview = truncateJson(example.input, 150);
|
|
30
|
+
lines.push(`│ Input: ${inputPreview}`);
|
|
31
|
+
const outputPreview = truncateJson(example.output, 150);
|
|
32
|
+
lines.push(`│ Output: ${outputPreview}`);
|
|
33
|
+
if (example.metadata && Object.keys(example.metadata).length > 0) {
|
|
34
|
+
const metadataPreview = truncateJson(example.metadata, 100);
|
|
35
|
+
lines.push(`│ Metadata: ${metadataPreview}`);
|
|
36
|
+
}
|
|
37
|
+
lines.push(`└─`);
|
|
38
|
+
lines.push("");
|
|
39
|
+
}
|
|
40
|
+
return lines.join("\n").trimEnd();
|
|
41
|
+
}
|
|
42
|
+
function truncateJson(obj, maxLength) {
|
|
43
|
+
if (obj === null || obj === undefined) {
|
|
44
|
+
return "null";
|
|
45
|
+
}
|
|
46
|
+
let str;
|
|
47
|
+
try {
|
|
48
|
+
str = JSON.stringify(obj);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
str = String(obj);
|
|
52
|
+
}
|
|
53
|
+
// Clean up whitespace for display
|
|
54
|
+
str = str.replace(/\s+/g, " ").trim();
|
|
55
|
+
if (str.length <= maxLength) {
|
|
56
|
+
return str;
|
|
57
|
+
}
|
|
58
|
+
return `${str.slice(0, maxLength)}…`;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=formatDataset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatDataset.js","sourceRoot":"","sources":["../../src/commands/formatDataset.ts"],"names":[],"mappings":"AA4BA,MAAM,UAAU,2BAA2B,CAAC,EAC1C,IAAI,EACJ,WAAW,EACX,MAAM,GAC6B;IACnC,MAAM,QAAQ,GAAG,MAAM,IAAI,QAAQ,CAAC;IACpC,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IACD,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,2BAA2B,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;AACxD,CAAC;AAED,SAAS,2BAA2B,CAClC,IAAyB,EACzB,WAAoB;IAEpB,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,SAAS;IACT,MAAM,WAAW,GAAG,WAAW,IAAI,IAAI,CAA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AAE,CAAC;YACjE,MAAM,eAAe,GAAG,YAAY,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;YAC5D,KAAK,CAAC,IAAI,CAAC,gBAAgB,eAAe,EAAE,CAAC,CAAC;QAChD,CAAC;QAED,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjB,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;AACpC,CAAC;AAED,SAAS,YAAY,CAAC,GAAY,EAAE,SAAiB;IACnD,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtC,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,GAAW,CAAC;IAChB,IAAI,CAAC;QACH,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IAAC,MAAM,CAAC;QACP,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC;IAED,kCAAkC;IAClC,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IAEtC,IAAI,GAAG,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;QAC5B,OAAO,GAAG,CAAC;IACb,CAAC;IAED,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { componentsV1 } from "@arizeai/phoenix-client";
|
|
2
|
+
export type OutputFormat = "pretty" | "json" | "raw";
|
|
3
|
+
type Dataset = componentsV1["schemas"]["Dataset"];
|
|
4
|
+
export interface FormatDatasetsOutputOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Datasets to format.
|
|
7
|
+
*/
|
|
8
|
+
datasets: Dataset[];
|
|
9
|
+
/**
|
|
10
|
+
* Output format. Defaults to `"pretty"`.
|
|
11
|
+
*/
|
|
12
|
+
format?: OutputFormat;
|
|
13
|
+
}
|
|
14
|
+
export declare function formatDatasetsOutput({ datasets, format, }: FormatDatasetsOutputOptions): string;
|
|
15
|
+
export interface FormatDatasetOutputOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Dataset to format.
|
|
18
|
+
*/
|
|
19
|
+
dataset: Dataset;
|
|
20
|
+
/**
|
|
21
|
+
* Output format. Defaults to `"pretty"`.
|
|
22
|
+
*/
|
|
23
|
+
format?: OutputFormat;
|
|
24
|
+
}
|
|
25
|
+
export declare function formatDatasetOutput({ dataset, format, }: FormatDatasetOutputOptions): string;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=formatDatasets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatDatasets.d.ts","sourceRoot":"","sources":["../../src/commands/formatDatasets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,CAAC;AAErD,KAAK,OAAO,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC;AAElD,MAAM,WAAW,2BAA2B;IAC1C;;OAEG;IACH,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB;;OAEG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAED,wBAAgB,oBAAoB,CAAC,EACnC,QAAQ,EACR,MAAM,GACP,EAAE,2BAA2B,GAAG,MAAM,CAStC;AAiCD,MAAM,WAAW,0BAA0B;IACzC;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAED,wBAAgB,mBAAmB,CAAC,EAClC,OAAO,EACP,MAAM,GACP,EAAE,0BAA0B,GAAG,MAAM,CASrC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
export function formatDatasetsOutput({ datasets, format, }) {
|
|
2
|
+
const selected = format || "pretty";
|
|
3
|
+
if (selected === "raw") {
|
|
4
|
+
return JSON.stringify(datasets);
|
|
5
|
+
}
|
|
6
|
+
if (selected === "json") {
|
|
7
|
+
return JSON.stringify(datasets, null, 2);
|
|
8
|
+
}
|
|
9
|
+
return formatDatasetsPretty(datasets);
|
|
10
|
+
}
|
|
11
|
+
function formatDatasetsPretty(datasets) {
|
|
12
|
+
if (datasets.length === 0) {
|
|
13
|
+
return "No datasets found";
|
|
14
|
+
}
|
|
15
|
+
const lines = [];
|
|
16
|
+
lines.push("Datasets:");
|
|
17
|
+
lines.push("");
|
|
18
|
+
for (const dataset of datasets) {
|
|
19
|
+
const desc = dataset.description === null ||
|
|
20
|
+
dataset.description === undefined ||
|
|
21
|
+
dataset.description === ""
|
|
22
|
+
? ""
|
|
23
|
+
: ` — ${dataset.description}`;
|
|
24
|
+
lines.push(`┌─ ${dataset.name} (${dataset.id})`);
|
|
25
|
+
lines.push(`│ Examples: ${dataset.example_count}`);
|
|
26
|
+
lines.push(`│ Created: ${formatDate(dataset.created_at)}`);
|
|
27
|
+
lines.push(`│ Updated: ${formatDate(dataset.updated_at)}`);
|
|
28
|
+
if (desc) {
|
|
29
|
+
lines.push(`│ Description:${desc}`);
|
|
30
|
+
}
|
|
31
|
+
lines.push(`└─`);
|
|
32
|
+
lines.push("");
|
|
33
|
+
}
|
|
34
|
+
return lines.join("\n").trimEnd();
|
|
35
|
+
}
|
|
36
|
+
export function formatDatasetOutput({ dataset, format, }) {
|
|
37
|
+
const selected = format || "pretty";
|
|
38
|
+
if (selected === "raw") {
|
|
39
|
+
return JSON.stringify(dataset);
|
|
40
|
+
}
|
|
41
|
+
if (selected === "json") {
|
|
42
|
+
return JSON.stringify(dataset, null, 2);
|
|
43
|
+
}
|
|
44
|
+
return formatDatasetPretty(dataset);
|
|
45
|
+
}
|
|
46
|
+
function formatDatasetPretty(dataset) {
|
|
47
|
+
const lines = [];
|
|
48
|
+
const desc = dataset.description === null ||
|
|
49
|
+
dataset.description === undefined ||
|
|
50
|
+
dataset.description === ""
|
|
51
|
+
? ""
|
|
52
|
+
: ` — ${dataset.description}`;
|
|
53
|
+
lines.push(`┌─ Dataset: ${dataset.name} (${dataset.id})`);
|
|
54
|
+
lines.push(`│`);
|
|
55
|
+
lines.push(`│ Examples: ${dataset.example_count}`);
|
|
56
|
+
lines.push(`│ Created: ${formatDate(dataset.created_at)}`);
|
|
57
|
+
lines.push(`│ Updated: ${formatDate(dataset.updated_at)}`);
|
|
58
|
+
if (desc) {
|
|
59
|
+
lines.push(`│ Description:${desc}`);
|
|
60
|
+
}
|
|
61
|
+
if (dataset.metadata && Object.keys(dataset.metadata).length > 0) {
|
|
62
|
+
lines.push(`│ Metadata: ${JSON.stringify(dataset.metadata)}`);
|
|
63
|
+
}
|
|
64
|
+
lines.push(`└─`);
|
|
65
|
+
return lines.join("\n");
|
|
66
|
+
}
|
|
67
|
+
function formatDate(dateStr) {
|
|
68
|
+
try {
|
|
69
|
+
const date = new Date(dateStr);
|
|
70
|
+
return date.toLocaleString();
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return dateStr;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=formatDatasets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatDatasets.js","sourceRoot":"","sources":["../../src/commands/formatDatasets.ts"],"names":[],"mappings":"AAiBA,MAAM,UAAU,oBAAoB,CAAC,EACnC,QAAQ,EACR,MAAM,GACsB;IAC5B,MAAM,QAAQ,GAAG,MAAM,IAAI,QAAQ,CAAC;IACpC,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IAClC,CAAC;IACD,IAAI,QAAQ,K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AK,CAAC,IAAI,CAAC,kBAAkB,IAAI,EAAE,CAAC,CAAC;IACvC,CAAC;IACD,IAAI,OAAO,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACjE,KAAK,CAAC,IAAI,CAAC,gBAAgB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACjE,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEjB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,SAAS,UAAU,CAAC,OAAe;IACjC,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC;QAC/B,OAAO,IAAI,CAAC,cAAc,EAAE,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,OAAO,CAAC;IACjB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { componentsV1 } from "@arizeai/phoenix-client";
|
|
2
|
+
export type OutputFormat = "pretty" | "json" | "raw";
|
|
3
|
+
type Experiment = componentsV1["schemas"]["Experiment"];
|
|
4
|
+
type ExperimentRun = componentsV1["schemas"]["ExperimentRun"];
|
|
5
|
+
export interface ExperimentWithRuns {
|
|
6
|
+
experiment: Experiment;
|
|
7
|
+
runs: ExperimentRun[];
|
|
8
|
+
}
|
|
9
|
+
export interface FormatExperimentOutputOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Experiment data to format.
|
|
12
|
+
*/
|
|
13
|
+
data: ExperimentWithRuns;
|
|
14
|
+
/**
|
|
15
|
+
* Output format. Defaults to `"pretty"`.
|
|
16
|
+
*/
|
|
17
|
+
format?: OutputFormat;
|
|
18
|
+
}
|
|
19
|
+
export declare function formatExperimentOutput({ data, format, }: FormatExperimentOutputOptions): string;
|
|
20
|
+
/**
|
|
21
|
+
* Format raw experiment JSON data from the API
|
|
22
|
+
*/
|
|
23
|
+
export interface FormatExperimentJsonOutputOptions {
|
|
24
|
+
/**
|
|
25
|
+
* Raw JSON data from the experiment endpoint.
|
|
26
|
+
*/
|
|
27
|
+
jsonData: string;
|
|
28
|
+
/**
|
|
29
|
+
* Output format. Defaults to `"pretty"`.
|
|
30
|
+
*/
|
|
31
|
+
format?: OutputFormat;
|
|
32
|
+
}
|
|
33
|
+
export declare function formatExperimentJsonOutput({ jsonData, format, }: FormatExperimentJsonOutputOptions): string;
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=formatExperiment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatExperiment.d.ts","sourceRoot":"","sources":["../../src/commands/formatExperiment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,CAAC;AAErD,KAAK,UAAU,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC,YAAY,CAAC,CAAC;AACxD,KAAK,aAAa,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC,eAAe,CAAC,CAAC;AAE9D,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,UAAU,CAAC;IACvB,IAAI,EAAE,aAAa,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,6BAA6B;IAC5C;;OAEG;IACH,IAAI,EAAE,kBAAkB,CAAC;IACzB;;OAEG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAED,wBAAgB,sBAAsB,CAAC,EACrC,IAAI,EACJ,MAAM,GACP,EAAE,6BAA6B,GAAG,MAAM,CASxC;AAoED;;GAEG;AACH,MAAM,WAAW,iCAAiC;IAChD;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAED,wBAAgB,0BAA0B,CAAC,EACzC,QAAQ,EACR,MAAM,GACP,EAAE,iCAAiC,GAAG,MAAM,CAsB5C"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
export function formatExperimentOutput({ data, format, }) {
|
|
2
|
+
const selected = format || "pretty";
|
|
3
|
+
if (selected === "raw") {
|
|
4
|
+
return JSON.stringify(data);
|
|
5
|
+
}
|
|
6
|
+
if (selected === "json") {
|
|
7
|
+
return JSON.stringify(data, null, 2);
|
|
8
|
+
}
|
|
9
|
+
return formatExperimentPretty(data);
|
|
10
|
+
}
|
|
11
|
+
function formatExperimentPretty(data) {
|
|
12
|
+
const { experiment, runs } = data;
|
|
13
|
+
const lines = [];
|
|
14
|
+
const projectInfo = experiment.project_name
|
|
15
|
+
? ` [Project: ${experiment.project_name}]`
|
|
16
|
+
: "";
|
|
17
|
+
lines.push(`┌─ Experiment: ${experiment.id}${projectInfo}`);
|
|
18
|
+
lines.push(`│`);
|
|
19
|
+
lines.push(`│ Dataset ID: ${experiment.dataset_id}`);
|
|
20
|
+
lines.push(`│ Version ID: ${experiment.dataset_version_id}`);
|
|
21
|
+
lines.push(`│ Examples: ${experiment.example_count}`);
|
|
22
|
+
lines.push(`│ Repetitions: ${experiment.repetitions}`);
|
|
23
|
+
lines.push(`│`);
|
|
24
|
+
lines.push(`│ Run Summary:`);
|
|
25
|
+
lines.push(`│ ✓ Successful: ${experiment.successful_run_count}`);
|
|
26
|
+
lines.push(`│ ✗ Failed: ${experiment.failed_run_count}`);
|
|
27
|
+
lines.push(`│ ○ Missing: ${experiment.missing_run_count}`);
|
|
28
|
+
lines.push(`│`);
|
|
29
|
+
lines.push(`│ Created: ${formatDate(experiment.created_at)}`);
|
|
30
|
+
lines.push(`│ Updated: ${formatDate(experiment.updated_at)}`);
|
|
31
|
+
if (experiment.metadata &&
|
|
32
|
+
Object.keys(experiment.metadata).length > 0) {
|
|
33
|
+
lines.push(`│ Metadata: ${JSON.stringify(experiment.metadata)}`);
|
|
34
|
+
}
|
|
35
|
+
if (runs.length > 0) {
|
|
36
|
+
lines.push(`│`);
|
|
37
|
+
lines.push(`│ Runs (${runs.length}):`);
|
|
38
|
+
for (const run of runs) {
|
|
39
|
+
const status = run.error ? "✗" : "✓";
|
|
40
|
+
const duration = formatDurationMs(run.start_time, run.end_time);
|
|
41
|
+
const traceInfo = run.trace_id ? ` [trace: ${run.trace_id}]` : "";
|
|
42
|
+
const repInfo = run.repetition_number > 1 ? ` (rep ${run.repetition_number})` : "";
|
|
43
|
+
lines.push(`│ ${status} ${run.id}${repInfo} - ${duration}${traceInfo}`);
|
|
44
|
+
if (run.error) {
|
|
45
|
+
lines.push(`│ Error: ${truncate(run.error, 80)}`);
|
|
46
|
+
}
|
|
47
|
+
if (run.output !== null && run.output !== undefined) {
|
|
48
|
+
const outputPreview = truncate(typeof run.output === "string"
|
|
49
|
+
? run.output
|
|
50
|
+
: JSON.stringify(run.output), 100);
|
|
51
|
+
lines.push(`│ Output: ${outputPreview}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
lines.push(`└─`);
|
|
56
|
+
return lines.join("\n");
|
|
57
|
+
}
|
|
58
|
+
export function formatExperimentJsonOutput({ jsonData, format, }) {
|
|
59
|
+
const selected = format || "pretty";
|
|
60
|
+
if (selected === "raw") {
|
|
61
|
+
// Return as compact JSON
|
|
62
|
+
try {
|
|
63
|
+
const parsed = JSON.parse(jsonData);
|
|
64
|
+
return JSON.stringify(parsed);
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return jsonData;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (selected === "json") {
|
|
71
|
+
// Return as pretty JSON
|
|
72
|
+
try {
|
|
73
|
+
const parsed = JSON.parse(jsonData);
|
|
74
|
+
return JSON.stringify(parsed, null, 2);
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return jsonData;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// Pretty format - parse and format nicely
|
|
81
|
+
return formatExperimentJsonPretty(jsonData);
|
|
82
|
+
}
|
|
83
|
+
function formatExperimentJsonPretty(jsonData) {
|
|
84
|
+
try {
|
|
85
|
+
const data = JSON.parse(jsonData);
|
|
86
|
+
const lines = [];
|
|
87
|
+
// Handle array of experiment runs from the JSON endpoint
|
|
88
|
+
if (Array.isArray(data)) {
|
|
89
|
+
lines.push(`Experiment Runs (${data.length}):`);
|
|
90
|
+
lines.push("");
|
|
91
|
+
for (const run of data) {
|
|
92
|
+
const status = run.error ? "✗" : "✓";
|
|
93
|
+
const runId = run.id || run.run_id || "unknown";
|
|
94
|
+
lines.push(`┌─ ${status} Run: ${runId}`);
|
|
95
|
+
if (run.example_id || run.dataset_example_id) {
|
|
96
|
+
lines.push(`│ Example ID: ${run.example_id || run.dataset_example_id}`);
|
|
97
|
+
}
|
|
98
|
+
if (run.repetition_number) {
|
|
99
|
+
lines.push(`│ Repetition: ${run.repetition_number}`);
|
|
100
|
+
}
|
|
101
|
+
if (run.start_time && run.end_time) {
|
|
102
|
+
lines.push(`│ Duration: ${formatDurationMs(run.start_time, run.end_time)}`);
|
|
103
|
+
}
|
|
104
|
+
if (run.trace_id) {
|
|
105
|
+
lines.push(`│ Trace ID: ${run.trace_id}`);
|
|
106
|
+
}
|
|
107
|
+
if (run.error) {
|
|
108
|
+
lines.push(`│ Error: ${truncate(run.error, 100)}`);
|
|
109
|
+
}
|
|
110
|
+
if (run.output !== null && run.output !== undefined) {
|
|
111
|
+
const outputStr = typeof run.output === "string"
|
|
112
|
+
? run.output
|
|
113
|
+
: JSON.stringify(run.output);
|
|
114
|
+
lines.push(`│ Output: ${truncate(outputStr, 200)}`);
|
|
115
|
+
}
|
|
116
|
+
if (run.input !== null && run.input !== undefined) {
|
|
117
|
+
const inputStr = typeof run.input === "string"
|
|
118
|
+
? run.input
|
|
119
|
+
: JSON.stringify(run.input);
|
|
120
|
+
lines.push(`│ Input: ${truncate(inputStr, 200)}`);
|
|
121
|
+
}
|
|
122
|
+
if (run.expected_output !== null && run.expected_output !== undefined) {
|
|
123
|
+
const expectedStr = typeof run.expected_output === "string"
|
|
124
|
+
? run.expected_output
|
|
125
|
+
: JSON.stringify(run.expected_output);
|
|
126
|
+
lines.push(`│ Expected: ${truncate(expectedStr, 200)}`);
|
|
127
|
+
}
|
|
128
|
+
// Handle evaluations
|
|
129
|
+
if (run.evaluations && Object.keys(run.evaluations).length > 0) {
|
|
130
|
+
lines.push(`│ Evaluations:`);
|
|
131
|
+
for (const [name, result] of Object.entries(run.evaluations)) {
|
|
132
|
+
const evalResult = result;
|
|
133
|
+
const parts = [];
|
|
134
|
+
if (evalResult.score !== undefined && evalResult.score !== null) {
|
|
135
|
+
parts.push(`score=${evalResult.score}`);
|
|
136
|
+
}
|
|
137
|
+
if (evalResult.label !== undefined && evalResult.label !== null) {
|
|
138
|
+
parts.push(`label="${evalResult.label}"`);
|
|
139
|
+
}
|
|
140
|
+
lines.push(`│ - ${name}: ${parts.join(", ")}`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
lines.push(`└─`);
|
|
144
|
+
lines.push("");
|
|
145
|
+
}
|
|
146
|
+
return lines.join("\n").trimEnd();
|
|
147
|
+
}
|
|
148
|
+
// Fallback for non-array data
|
|
149
|
+
return JSON.stringify(data, null, 2);
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
return jsonData;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function formatDate(dateStr) {
|
|
156
|
+
try {
|
|
157
|
+
const date = new Date(dateStr);
|
|
158
|
+
return date.toLocaleString();
|
|
159
|
+
}
|
|
160
|
+
catch {
|
|
161
|
+
return dateStr;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function formatDurationMs(startTime, endTime) {
|
|
165
|
+
try {
|
|
166
|
+
const startMs = Date.parse(startTime);
|
|
167
|
+
const endMs = Date.parse(endTime);
|
|
168
|
+
if (Number.isNaN(startMs) || Number.isNaN(endMs)) {
|
|
169
|
+
return "n/a";
|
|
170
|
+
}
|
|
171
|
+
const durationMs = Math.max(0, endMs - startMs);
|
|
172
|
+
if (durationMs < 1000) {
|
|
173
|
+
return `${durationMs}ms`;
|
|
174
|
+
}
|
|
175
|
+
if (durationMs < 60000) {
|
|
176
|
+
return `${(durationMs / 1000).toFixed(2)}s`;
|
|
177
|
+
}
|
|
178
|
+
return `${(durationMs / 60000).toFixed(2)}m`;
|
|
179
|
+
}
|
|
180
|
+
catch {
|
|
181
|
+
return "n/a";
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function truncate(str, maxLength) {
|
|
185
|
+
const cleaned = str.replace(/\s+/g, " ").trim();
|
|
186
|
+
if (cleaned.length <= maxLength) {
|
|
187
|
+
return cleaned;
|
|
188
|
+
}
|
|
189
|
+
return `${cleaned.slice(0, maxLength)}…`;
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=formatExperiment.js.map
|