@arizeai/phoenix-cli 0.1.0 → 0.3.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 +103 -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/build/commands/spanAnnotations.d.ts +14 -0
- package/build/commands/spanAnnotations.d.ts.map +1 -0
- package/build/commands/spanAnnotations.js +60 -0
- package/build/commands/spanAnnotations.js.map +1 -0
- package/build/commands/trace.d.ts.map +1 -1
- package/build/commands/trace.js +29 -0
- package/build/commands/trace.js.map +1 -1
- package/build/commands/traces.d.ts.map +1 -1
- package/build/commands/traces.js +37 -0
- package/build/commands/traces.js.map +1 -1
- package/build/trace.d.ts +9 -5
- package/build/trace.d.ts.map +1 -1
- package/build/trace.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
<img referrerpolicy="no-referrer-when-downgrade" src="https://static.scarf.sh/a.png?x-pxid=8e8e8b34-7900-43fa-a38f-1f070bd48c64&page=js/packages/phoenix-cli/README.md" />
|
|
23
23
|
</p>
|
|
24
24
|
|
|
25
|
-
A command-line interface for
|
|
25
|
+
A command-line interface for [Arize Phoenix](https://github.com/Arize-ai/phoenix). Fetch traces, list datasets, and export experiment results directly from your terminal—or pipe them into AI coding agents like Claude Code, Cursor, Codex, and Gemini CLI.
|
|
26
26
|
|
|
27
27
|
## Installation
|
|
28
28
|
|
|
@@ -96,6 +96,7 @@ px traces --format raw --no-progress | jq # Pipe to jq
|
|
|
96
96
|
| `--since <timestamp>` | Fetch traces since ISO timestamp | — |
|
|
97
97
|
| `--format <format>` | `pretty`, `json`, or `raw` | `pretty` |
|
|
98
98
|
| `--no-progress` | Disable progress output | — |
|
|
99
|
+
| `--include-annotations` | Include span annotations in trace export | — |
|
|
99
100
|
|
|
100
101
|
### `px trace <trace-id>`
|
|
101
102
|
|
|
@@ -107,6 +108,74 @@ px trace abc123def456 --file trace.json # Save to file
|
|
|
107
108
|
px trace abc123def456 --format raw | jq # Pipe to jq
|
|
108
109
|
```
|
|
109
110
|
|
|
111
|
+
| Option | Description | Default |
|
|
112
|
+
| ----------------------- | ---------------------------------------- | -------- |
|
|
113
|
+
| `--file <path>` | Save to file instead of stdout | stdout |
|
|
114
|
+
| `--format <format>` | `pretty`, `json`, or `raw` | `pretty` |
|
|
115
|
+
| `--include-annotations` | Include span annotations in trace export | — |
|
|
116
|
+
|
|
117
|
+
### `px datasets`
|
|
118
|
+
|
|
119
|
+
List all available datasets.
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
px datasets
|
|
123
|
+
px datasets --format json # JSON output
|
|
124
|
+
px datasets --format raw --no-progress | jq # Pipe to jq
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
| Option | Description | Default |
|
|
128
|
+
| ------------------- | -------------------------- | -------- |
|
|
129
|
+
| `--format <format>` | `pretty`, `json`, or `raw` | `pretty` |
|
|
130
|
+
| `--limit <number>` | Maximum number of datasets | — |
|
|
131
|
+
|
|
132
|
+
### `px dataset <dataset-identifier>`
|
|
133
|
+
|
|
134
|
+
Fetch examples from a dataset.
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
px dataset query_response # Fetch all examples
|
|
138
|
+
px dataset query_response --split train # Filter by split
|
|
139
|
+
px dataset query_response --split train --split test # Multiple splits
|
|
140
|
+
px dataset query_response --version <version-id> # Specific version
|
|
141
|
+
px dataset query_response --file dataset.json # Save to file
|
|
142
|
+
px dataset query_response --format raw | jq '.examples[].input'
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
| Option | Description | Default |
|
|
146
|
+
| ---------------- | ---------------------------------------- | -------- |
|
|
147
|
+
| `--split <name>` | Filter by split (can be used repeatedly) | — |
|
|
148
|
+
| `--version <id>` | Fetch from specific dataset version | latest |
|
|
149
|
+
| `--file <path>` | Save to file instead of stdout | stdout |
|
|
150
|
+
| `--format <fmt>` | `pretty`, `json`, or `raw` | `pretty` |
|
|
151
|
+
|
|
152
|
+
### `px experiments --dataset <name-or-id>`
|
|
153
|
+
|
|
154
|
+
List experiments for a dataset, optionally exporting full data to files.
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
px experiments --dataset my-dataset # List experiments
|
|
158
|
+
px experiments --dataset my-dataset --format json # JSON output
|
|
159
|
+
px experiments --dataset my-dataset ./experiments # Export to directory
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
| Option | Description | Default |
|
|
163
|
+
| ------------------------ | ----------------------------------------- | -------- |
|
|
164
|
+
| `--dataset <name-or-id>` | Dataset name or ID (required) | — |
|
|
165
|
+
| `[directory]` | Export experiment JSON files to directory | stdout |
|
|
166
|
+
| `--format <format>` | `pretty`, `json`, or `raw` | `pretty` |
|
|
167
|
+
| `--limit <number>` | Maximum number of experiments | — |
|
|
168
|
+
|
|
169
|
+
### `px experiment <experiment-id>`
|
|
170
|
+
|
|
171
|
+
Fetch a single experiment with all run data.
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
px experiment RXhwZXJpbWVudDox
|
|
175
|
+
px experiment RXhwZXJpbWVudDox --file exp.json # Save to file
|
|
176
|
+
px experiment RXhwZXJpbWVudDox --format json # JSON output
|
|
177
|
+
```
|
|
178
|
+
|
|
110
179
|
| Option | Description | Default |
|
|
111
180
|
| ------------------- | ------------------------------ | -------- |
|
|
112
181
|
| `--file <path>` | Save to file instead of stdout | stdout |
|
|
@@ -196,6 +265,39 @@ px traces --limit 50 --format raw --no-progress | \
|
|
|
196
265
|
px traces --limit 100 --format raw --no-progress | jq '[.[] | select(.status == "ERROR")] | length'
|
|
197
266
|
```
|
|
198
267
|
|
|
268
|
+
### List datasets and experiments
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
# List all datasets
|
|
272
|
+
px datasets --format raw --no-progress | jq '.[].name'
|
|
273
|
+
# Output: "query_response"
|
|
274
|
+
|
|
275
|
+
# List experiments for a dataset
|
|
276
|
+
px experiments --dataset query_response --format raw --no-progress | \
|
|
277
|
+
jq '.[] | {id, successful_run_count, failed_run_count}'
|
|
278
|
+
# Output: {"id":"RXhwZXJpbWVudDox","successful_run_count":249,"failed_run_count":1}
|
|
279
|
+
|
|
280
|
+
# Export all experiment data for a dataset to a directory
|
|
281
|
+
px experiments --dataset query_response ./experiments/
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### Analyze experiment results
|
|
285
|
+
|
|
286
|
+
```bash
|
|
287
|
+
# Get input queries and latency from an experiment
|
|
288
|
+
px experiment RXhwZXJpbWVudDox --format raw --no-progress | \
|
|
289
|
+
jq '.[] | {query: .input.query, latency_ms, trace_id}'
|
|
290
|
+
|
|
291
|
+
# Find failed runs in an experiment
|
|
292
|
+
px experiment RXhwZXJpbWVudDox --format raw --no-progress | \
|
|
293
|
+
jq '.[] | select(.error != null) | {query: .input.query, error}'
|
|
294
|
+
# Output: {"query":"looking for complex fodmap meal ideas","error":"peer closed connection..."}
|
|
295
|
+
|
|
296
|
+
# Calculate average latency across runs
|
|
297
|
+
px experiment RXhwZXJpbWVudDox --format raw --no-progress | \
|
|
298
|
+
jq '[.[].latency_ms] | add / length'
|
|
299
|
+
```
|
|
300
|
+
|
|
199
301
|
---
|
|
200
302
|
|
|
201
303
|
## Community
|
package/build/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAeA,wBAAgB,IAAI,SAuBnB"}
|
package/build/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { createProjectsCommand, createTraceCommand, createTracesCommand, } from "./commands/index.js";
|
|
2
|
+
import { createDatasetCommand, createDatasetsCommand, createExperimentCommand, createExperimentsCommand, createProjectsCommand, createTraceCommand, createTracesCommand, } from "./commands/index.js";
|
|
3
3
|
import { Command } from "commander";
|
|
4
4
|
// Phoenix CLI Main Logic
|
|
5
5
|
export function main() {
|
|
@@ -12,6 +12,10 @@ export function main() {
|
|
|
12
12
|
program.addCommand(createProjectsCommand());
|
|
13
13
|
program.addCommand(createTracesCommand());
|
|
14
14
|
program.addCommand(createTraceCommand());
|
|
15
|
+
program.addCommand(createDatasetsCommand());
|
|
16
|
+
program.addCommand(createDatasetCommand());
|
|
17
|
+
program.addCommand(createExperimentsCommand());
|
|
18
|
+
program.addCommand(createExperimentCommand());
|
|
15
19
|
// Show help if no command provided
|
|
16
20
|
if (process.argv.length === 2) {
|
|
17
21
|
program.help();
|
package/build/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,yBAAyB;AACzB,MAAM,UAAU,IAAI;IAClB,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAE9B,OAAO;SACJ,IAAI,CAAC,IAAI,CAAC;SACV,WAAW,CAAC,sDAAsD,CAAC;SACnE,OAAO,CAAC,OAAO,CAAC,CAAC;IAEpB,oBAAoB;IACpB,OAAO,CAAC,UAAU,CAAC,qBAAqB,EAAE,CAAC,CAAC;IAC5C,OAAO,CAAC,UAAU,CAAC,mBAAmB,EAAE,CAAC,CAAC;IAC1C,OAAO,CAAC,UAAU,CAAC,kBAAkB,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,yBAAyB;AACzB,MAAM,UAAU,IAAI;IAClB,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAE9B,OAAO;SACJ,IAAI,CAAC,IAAI,CAAC;SACV,WAAW,CAAC,sDAAsD,CAAC;SACnE,OAAO,CAAC,OAAO,CAAC,CAAC;IAEpB,oBAAoB;IACpB,OAAO,CAAC,UAAU,CAAC,qBAAqB,EAAE,CAAC,CAAC;IAC5C,OAAO,CAAC,UAAU,CAAC,mBAAmB,EAAE,CAAC,CAAC;IAC1C,OAAO,CAAC,UAAU,CAAC,kBAAkB,EAAE,CAAC,CAAC;IACzC,OAAO,CAAC,UAAU,CAAC,qBAAqB,EAAE,CAAC,CAAC;IAC5C,OAAO,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,CAAC;IAC3C,OAAO,CAAC,UAAU,CAAC,wBAAwB,EAAE,CAAC,CAAC;IAC/C,OAAO,CAAC,UAAU,CAAC,uBAAuB,EAAE,CAAC,CAAC;IAE9C,mCAAmC;IACnC,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,OAAO,CAAC,IAAI,EAAE,CAAC;IACjB,CAAC;IAED,OAAO,CAAC,KAAK,EAAE,CAAC;AAClB,CAAC"}
|
package/build/client.d.ts
CHANGED
|
@@ -28,4 +28,22 @@ export interface ResolveProjectIdOptions {
|
|
|
28
28
|
* If the identifier looks like a Phoenix project ID (hex string), returns it as-is; otherwise fetches by name.
|
|
29
29
|
*/
|
|
30
30
|
export declare function resolveProjectId({ client, projectIdentifier, }: ResolveProjectIdOptions): Promise<string>;
|
|
31
|
+
export interface ResolveDatasetIdOptions {
|
|
32
|
+
/**
|
|
33
|
+
* Phoenix API client.
|
|
34
|
+
*/
|
|
35
|
+
client: PhoenixClient;
|
|
36
|
+
/**
|
|
37
|
+
* Dataset identifier to resolve.
|
|
38
|
+
*
|
|
39
|
+
* Phoenix dataset IDs are hex-encoded strings. If `datasetIdentifier` looks like a hex string,
|
|
40
|
+
* it's treated as an ID; otherwise it's treated as a name and resolved via the API.
|
|
41
|
+
*/
|
|
42
|
+
datasetIdentifier: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Resolve dataset identifier to dataset ID
|
|
46
|
+
* If the identifier looks like a Phoenix dataset ID (hex string), returns it as-is; otherwise fetches by name.
|
|
47
|
+
*/
|
|
48
|
+
export declare function resolveDatasetId({ client, datasetIdentifier, }: ResolveDatasetIdOptions): Promise<string>;
|
|
31
49
|
//# sourceMappingURL=client.d.ts.map
|
package/build/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE3E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,MAAM,WAAW,0BAA0B;IACzC;;OAEG;IACH,MAAM,EAAE,aAAa,CAAC;CACvB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,MAAM,GACP,EAAE,0BAA0B,GAAG,aAAa,CAqB5C;AAED,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,MAAM,EAAE,aAAa,CAAC;IACtB;;;;;OAKG;IACH,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAWD;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,EACrC,MAAM,EACN,iBAAiB,GAClB,EAAE,uBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC,CA2B3C"}
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE3E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,MAAM,WAAW,0BAA0B;IACzC;;OAEG;IACH,MAAM,EAAE,aAAa,CAAC;CACvB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,MAAM,GACP,EAAE,0BAA0B,GAAG,aAAa,CAqB5C;AAED,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,MAAM,EAAE,aAAa,CAAC;IACtB;;;;;OAKG;IACH,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAWD;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,EACrC,MAAM,EACN,iBAAiB,GAClB,EAAE,uBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC,CA2B3C;AAED,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,MAAM,EAAE,aAAa,CAAC;IACtB;;;;;OAKG;IACH,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAWD;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,EACrC,MAAM,EACN,iBAAiB,GAClB,EAAE,uBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC,CAiC3C"}
|
package/build/client.js
CHANGED
|
@@ -54,4 +54,43 @@ export async function resolveProjectId({ client, projectIdentifier, }) {
|
|
|
54
54
|
throw new Error(`Failed to resolve project "${projectIdentifier}": ${error instanceof Error ? error.message : String(error)}`);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
+
function looksLikePhoenixDatasetId(datasetIdentifier) {
|
|
58
|
+
// Dataset IDs are hex-encoded strings (e.g., "a1b2c3d4e5f6...")
|
|
59
|
+
const trimmed = datasetIdentifier.trim();
|
|
60
|
+
if (!trimmed)
|
|
61
|
+
return false;
|
|
62
|
+
// Check if the string is a valid hex string (only 0-9, a-f, A-F)
|
|
63
|
+
return /^[0-9a-fA-F]+$/.test(trimmed);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Resolve dataset identifier to dataset ID
|
|
67
|
+
* If the identifier looks like a Phoenix dataset ID (hex string), returns it as-is; otherwise fetches by name.
|
|
68
|
+
*/
|
|
69
|
+
export async function resolveDatasetId({ client, datasetIdentifier, }) {
|
|
70
|
+
if (looksLikePhoenixDatasetId(datasetIdentifier)) {
|
|
71
|
+
return datasetIdentifier;
|
|
72
|
+
}
|
|
73
|
+
// Otherwise, fetch the dataset by name to get its ID
|
|
74
|
+
try {
|
|
75
|
+
const response = await client.GET("/v1/datasets", {
|
|
76
|
+
params: {
|
|
77
|
+
query: {
|
|
78
|
+
name: datasetIdentifier,
|
|
79
|
+
limit: 1,
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
if (response.error || !response.data) {
|
|
84
|
+
throw new Error(`Failed to resolve dataset "${datasetIdentifier}": ${response.error}`);
|
|
85
|
+
}
|
|
86
|
+
const datasets = response.data.data;
|
|
87
|
+
if (datasets.length === 0) {
|
|
88
|
+
throw new Error(`Dataset not found: "${datasetIdentifier}"`);
|
|
89
|
+
}
|
|
90
|
+
return datasets[0].id;
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
throw new Error(`Failed to resolve dataset "${datasetIdentifier}": ${error instanceof Error ? error.message : String(error)}`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
57
96
|
//# sourceMappingURL=client.js.map
|
package/build/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAsB,MAAM,yBAAyB,CAAC;AAW3E;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,EAClC,MAAM,GACqB;IAC3B,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC;IAEhC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;IAED,MAAM,OAAO,GAA2B;QACtC,GAAG,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC;KAC1B,CAAC;IAEF,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClB,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,MAAM,CAAC,MAAM,EAAE,CAAC;I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K,EAAE,CACtE,CAAC;QACJ,CAAC;QAED,MAAM,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;QACpC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,uBAAuB,iBAAiB,GAAG,CAAC,CAAC;QAC/D,CAAC;QAED,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACxB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,8BAA8B,iBAAiB,MAAM,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAC9G,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataset.d.ts","sourceRoot":"","sources":["../../src/commands/dataset.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA6KpC;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAyB9C"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { createPhoenixClient, resolveDatasetId } from "../client.js";
|
|
2
|
+
import { getConfigErrorMessage, resolveConfig } from "../config.js";
|
|
3
|
+
import { writeError, writeOutput, writeProgress } from "../io.js";
|
|
4
|
+
import { formatDatasetExamplesOutput, } from "./formatDataset.js";
|
|
5
|
+
import { Command } from "commander";
|
|
6
|
+
import * as fs from "fs";
|
|
7
|
+
/**
|
|
8
|
+
* Fetch dataset examples from Phoenix
|
|
9
|
+
*/
|
|
10
|
+
async function fetchDatasetExamples(client, datasetId, options = {}) {
|
|
11
|
+
const response = await client.GET("/v1/datasets/{id}/examples", {
|
|
12
|
+
params: {
|
|
13
|
+
path: {
|
|
14
|
+
id: datasetId,
|
|
15
|
+
},
|
|
16
|
+
query: {
|
|
17
|
+
version_id: options.versionId,
|
|
18
|
+
split: options.splits,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
if (response.error || !response.data) {
|
|
23
|
+
throw new Error(`Failed to fetch dataset examples: ${response.error}`);
|
|
24
|
+
}
|
|
25
|
+
return response.data.data;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Fetch dataset metadata for display name
|
|
29
|
+
*/
|
|
30
|
+
async function fetchDatasetName(client, datasetId) {
|
|
31
|
+
try {
|
|
32
|
+
const response = await client.GET("/v1/datasets/{id}", {
|
|
33
|
+
params: {
|
|
34
|
+
path: {
|
|
35
|
+
id: datasetId,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
if (response.error || !response.data) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
return response.data.data.name;
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Dataset command handler
|
|
50
|
+
*/
|
|
51
|
+
async function datasetHandler(datasetIdentifier, options) {
|
|
52
|
+
try {
|
|
53
|
+
const userSpecifiedFormat = process.argv.includes("--format") ||
|
|
54
|
+
process.argv.some((arg) => arg.startsWith("--format="));
|
|
55
|
+
// Resolve configuration
|
|
56
|
+
const config = resolveConfig({
|
|
57
|
+
cliOptions: {
|
|
58
|
+
endpoint: options.endpoint,
|
|
59
|
+
apiKey: options.apiKey,
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
// Validate that we have endpoint
|
|
63
|
+
if (!config.endpoint) {
|
|
64
|
+
const errors = [
|
|
65
|
+
"Phoenix endpoint not configured. Set PHOENIX_HOST environment variable or use --endpoint flag.",
|
|
66
|
+
];
|
|
67
|
+
writeError({ message: getConfigErrorMessage({ errors }) });
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
// Create client
|
|
71
|
+
const client = createPhoenixClient({ config });
|
|
72
|
+
writeProgress({
|
|
73
|
+
message: `Resolving dataset: ${datasetIdentifier}`,
|
|
74
|
+
noProgress: !options.progress,
|
|
75
|
+
});
|
|
76
|
+
// Resolve dataset ID
|
|
77
|
+
const datasetId = await resolveDatasetId({
|
|
78
|
+
client,
|
|
79
|
+
datasetIdentifier,
|
|
80
|
+
});
|
|
81
|
+
// Fetch dataset name for display
|
|
82
|
+
const datasetName = await fetchDatasetName(client, datasetId);
|
|
83
|
+
writeProgress({
|
|
84
|
+
message: `Fetching examples from dataset ${datasetName || datasetId}...`,
|
|
85
|
+
noProgress: !options.progress,
|
|
86
|
+
});
|
|
87
|
+
// Fetch dataset examples
|
|
88
|
+
const data = await fetchDatasetExamples(client, datasetId, {
|
|
89
|
+
versionId: options.version,
|
|
90
|
+
splits: options.split,
|
|
91
|
+
});
|
|
92
|
+
writeProgress({
|
|
93
|
+
message: `Found ${data.examples.length} example(s)`,
|
|
94
|
+
noProgress: !options.progress,
|
|
95
|
+
});
|
|
96
|
+
// Determine output format
|
|
97
|
+
const outputFormat = options.file
|
|
98
|
+
? "json"
|
|
99
|
+
: options.format || "pretty";
|
|
100
|
+
if (options.file && userSpecifiedFormat && options.format !== "json") {
|
|
101
|
+
writeError({
|
|
102
|
+
message: `Warning: --format is ignored when writing to a file; writing JSON to ${options.file}`,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
// Format output
|
|
106
|
+
const output = formatDatasetExamplesOutput({
|
|
107
|
+
data,
|
|
108
|
+
datasetName,
|
|
109
|
+
format: outputFormat,
|
|
110
|
+
});
|
|
111
|
+
if (options.file) {
|
|
112
|
+
fs.writeFileSync(options.file, output, "utf-8");
|
|
113
|
+
writeProgress({
|
|
114
|
+
message: `Wrote dataset to ${options.file}`,
|
|
115
|
+
noProgress: !options.progress,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
writeOutput({ message: output });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
writeError({
|
|
124
|
+
message: `Error fetching dataset: ${error instanceof Error ? error.message : String(error)}`,
|
|
125
|
+
});
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Collect multiple --split options into an array
|
|
131
|
+
*/
|
|
132
|
+
function collectSplits(value, previous) {
|
|
133
|
+
return previous.concat([value]);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Create the dataset command
|
|
137
|
+
*/
|
|
138
|
+
export function createDatasetCommand() {
|
|
139
|
+
const command = new Command("dataset");
|
|
140
|
+
command
|
|
141
|
+
.description("Fetch examples from a dataset")
|
|
142
|
+
.argument("<dataset-identifier>", "Dataset name or ID")
|
|
143
|
+
.option("--endpoint <url>", "Phoenix API endpoint")
|
|
144
|
+
.option("--api-key <key>", "Phoenix API key for authentication")
|
|
145
|
+
.option("--format <format>", "Output format: pretty, json, or raw", "pretty")
|
|
146
|
+
.option("--no-progress", "Disable progress indicators")
|
|
147
|
+
.option("--file <path>", "Save output to file instead of stdout")
|
|
148
|
+
.option("--split <name>", "Filter by split name (can be used multiple times)", collectSplits, [])
|
|
149
|
+
.option("--version <id>", "Fetch from a specific dataset version")
|
|
150
|
+
.action(datasetHandler);
|
|
151
|
+
return command;
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=dataset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataset.js","sourceRoot":"","sources":["../../src/commands/dataset.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,EAEL,2BAA2B,GAE5B,MAAM,iBAAiB,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SAC7F,CAAC,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,aAAa,CAAC,KAAa,EAAE,QAAkB;IACtD,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB;IAClC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,SAAS,CAAC,CAAC;IAEvC,OAAO;SACJ,WAAW,CAAC,+BAA+B,CAAC;SAC5C,QAAQ,CAAC,sBAAsB,EAAE,oBAAoB,CAAC;SACtD,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,CAAC,eAAe,EAAE,uCAAuC,CAAC;SAChE,MAAM,CACL,gBAAgB,EAChB,mDAAmD,EACnD,aAAa,EACb,EAAE,CACH;SACA,MAAM,CAAC,gBAAgB,EAAE,uCAAuC,CAAC;SACjE,MAAM,CAAC,cAAc,CAAC,CAAC;IAE1B,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datasets.d.ts","sourceRoot":"","sources":["../../src/commands/datasets.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAuGpC;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,OAAO,CAiB/C"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { createPhoenixClient } from "../client.js";
|
|
2
|
+
import { getConfigErrorMessage, resolveConfig } from "../config.js";
|
|
3
|
+
import { writeError, writeOutput, writeProgress } from "../io.js";
|
|
4
|
+
import { formatDatasetsOutput } from "./formatDatasets.js";
|
|
5
|
+
import { Command } from "commander";
|
|
6
|
+
/**
|
|
7
|
+
* Fetch all datasets from Phoenix
|
|
8
|
+
*/
|
|
9
|
+
async function fetchDatasets(client, options = {}) {
|
|
10
|
+
const allDatasets = [];
|
|
11
|
+
let cursor;
|
|
12
|
+
const pageLimit = options.limit || 100;
|
|
13
|
+
do {
|
|
14
|
+
const response = await client.GET("/v1/datasets", {
|
|
15
|
+
params: {
|
|
16
|
+
query: {
|
|
17
|
+
cursor,
|
|
18
|
+
limit: pageLimit,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
if (response.error || !response.data) {
|
|
23
|
+
throw new Error(`Failed to fetch datasets: ${response.error}`);
|
|
24
|
+
}
|
|
25
|
+
allDatasets.push(...response.data.data);
|
|
26
|
+
cursor = response.data.next_cursor || undefined;
|
|
27
|
+
// If we've fetched enough for the requested limit, stop
|
|
28
|
+
if (options.limit && allDatasets.length >= options.limit) {
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
} while (cursor);
|
|
32
|
+
return allDatasets;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Datasets command handler
|
|
36
|
+
*/
|
|
37
|
+
async function datasetsHandler(options) {
|
|
38
|
+
try {
|
|
39
|
+
// Resolve configuration
|
|
40
|
+
const config = resolveConfig({
|
|
41
|
+
cliOptions: {
|
|
42
|
+
endpoint: options.endpoint,
|
|
43
|
+
apiKey: options.apiKey,
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
// Validate that we have endpoint
|
|
47
|
+
if (!config.endpoint) {
|
|
48
|
+
const errors = [
|
|
49
|
+
"Phoenix endpoint not configured. Set PHOENIX_HOST environment variable or use --endpoint flag.",
|
|
50
|
+
];
|
|
51
|
+
writeError({ message: getConfigErrorMessage({ errors }) });
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
// Create client
|
|
55
|
+
const client = createPhoenixClient({ config });
|
|
56
|
+
writeProgress({
|
|
57
|
+
message: "Fetching datasets...",
|
|
58
|
+
noProgress: !options.progress,
|
|
59
|
+
});
|
|
60
|
+
// Fetch datasets
|
|
61
|
+
const datasets = await fetchDatasets(client, {
|
|
62
|
+
limit: options.limit,
|
|
63
|
+
});
|
|
64
|
+
writeProgress({
|
|
65
|
+
message: `Found ${datasets.length} dataset(s)`,
|
|
66
|
+
noProgress: !options.progress,
|
|
67
|
+
});
|
|
68
|
+
// Output datasets
|
|
69
|
+
const output = formatDatasetsOutput({
|
|
70
|
+
datasets,
|
|
71
|
+
format: options.format,
|
|
72
|
+
});
|
|
73
|
+
writeOutput({ message: output });
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
writeError({
|
|
77
|
+
message: `Error fetching datasets: ${error instanceof Error ? error.message : String(error)}`,
|
|
78
|
+
});
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Create the datasets command
|
|
84
|
+
*/
|
|
85
|
+
export function createDatasetsCommand() {
|
|
86
|
+
const command = new Command("datasets");
|
|
87
|
+
command
|
|
88
|
+
.description("List all available Phoenix datasets")
|
|
89
|
+
.option("--endpoint <url>", "Phoenix API endpoint")
|
|
90
|
+
.option("--api-key <key>", "Phoenix API key for authentication")
|
|
91
|
+
.option("--format <format>", "Output format: pretty, json, or raw", "pretty")
|
|
92
|
+
.option("--no-progress", "Disable progress indicators")
|
|
93
|
+
.option("--limit <number>", "Maximum number of datasets to fetch", parseInt)
|
|
94
|
+
.action(datasetsHandler);
|
|
95
|
+
return command;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=datasets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datasets.js","sourceRoot":"","sources":["../../src/commands/datasets.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,qBAAqB,EA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CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB;IACnC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC;IAExC,OAAO;SACJ,WAAW,CAAC,qCAAqC,CAAC;SAClD,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,CAAC,kBAAkB,EAAE,qCAAqC,EAAE,QAAQ,CAAC;SAC3E,MAAM,CAAC,eAAe,CAAC,CAAC;IAE3B,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"experiment.d.ts","sourceRoot":"","sources":["../../src/commands/experiment.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiHpC;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,OAAO,CAkBjD"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { createPhoenixClient } from "../client.js";
|
|
2
|
+
import { getConfigErrorMessage, resolveConfig } from "../config.js";
|
|
3
|
+
import { writeError, writeOutput, writeProgress } from "../io.js";
|
|
4
|
+
import { formatExperimentJsonOutput, } from "./formatExperiment.js";
|
|
5
|
+
import { Command } from "commander";
|
|
6
|
+
import * as fs from "fs";
|
|
7
|
+
/**
|
|
8
|
+
* Download experiment JSON data
|
|
9
|
+
*/
|
|
10
|
+
async function downloadExperimentJson(client, experimentId) {
|
|
11
|
+
const response = await client.GET("/v1/experiments/{experiment_id}/json", {
|
|
12
|
+
params: {
|
|
13
|
+
path: {
|
|
14
|
+
experiment_id: experimentId,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
parseAs: "text",
|
|
18
|
+
});
|
|
19
|
+
if (response.error || response.data === undefined) {
|
|
20
|
+
throw new Error(`Failed to download experiment: ${response.error}`);
|
|
21
|
+
}
|
|
22
|
+
return response.data;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Experiment command handler
|
|
26
|
+
*/
|
|
27
|
+
async function experimentHandler(experimentId, options) {
|
|
28
|
+
try {
|
|
29
|
+
const userSpecifiedFormat = process.argv.includes("--format") ||
|
|
30
|
+
process.argv.some((arg) => arg.startsWith("--format="));
|
|
31
|
+
// Resolve configuration
|
|
32
|
+
const config = resolveConfig({
|
|
33
|
+
cliOptions: {
|
|
34
|
+
endpoint: options.endpoint,
|
|
35
|
+
apiKey: options.apiKey,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
// Validate that we have endpoint
|
|
39
|
+
if (!config.endpoint) {
|
|
40
|
+
const errors = [
|
|
41
|
+
"Phoenix endpoint not configured. Set PHOENIX_HOST environment variable or use --endpoint flag.",
|
|
42
|
+
];
|
|
43
|
+
writeError({ message: getConfigErrorMessage({ errors }) });
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
// Create client
|
|
47
|
+
const client = createPhoenixClient({ config });
|
|
48
|
+
writeProgress({
|
|
49
|
+
message: `Fetching experiment ${experimentId}...`,
|
|
50
|
+
noProgress: !options.progress,
|
|
51
|
+
});
|
|
52
|
+
// Download experiment JSON
|
|
53
|
+
const jsonData = await downloadExperimentJson(client, experimentId);
|
|
54
|
+
writeProgress({
|
|
55
|
+
message: `Downloaded experiment data`,
|
|
56
|
+
noProgress: !options.progress,
|
|
57
|
+
});
|
|
58
|
+
// Determine output format
|
|
59
|
+
const outputFormat = options.file
|
|
60
|
+
? "json"
|
|
61
|
+
: options.format || "pretty";
|
|
62
|
+
if (options.file && userSpecifiedFormat && options.format !== "json") {
|
|
63
|
+
writeError({
|
|
64
|
+
message: `Warning: --format is ignored when writing to a file; writing JSON to ${options.file}`,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
// Format output
|
|
68
|
+
const output = formatExperimentJsonOutput({
|
|
69
|
+
jsonData,
|
|
70
|
+
format: outputFormat,
|
|
71
|
+
});
|
|
72
|
+
if (options.file) {
|
|
73
|
+
fs.writeFileSync(options.file, output, "utf-8");
|
|
74
|
+
writeProgress({
|
|
75
|
+
message: `Wrote experiment to ${options.file}`,
|
|
76
|
+
noProgress: !options.progress,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
writeOutput({ message: output });
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
writeError({
|
|
85
|
+
message: `Error fetching experiment: ${error instanceof Error ? error.message : String(error)}`,
|
|
86
|
+
});
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Create the experiment command
|
|
92
|
+
*/
|
|
93
|
+
export function createExperimentCommand() {
|
|
94
|
+
const command = new Command("experiment");
|
|
95
|
+
command
|
|
96
|
+
.description("Fetch a specific experiment by ID with all run data")
|
|
97
|
+
.argument("<experiment-id>", "Experiment identifier")
|
|
98
|
+
.option("--endpoint <url>", "Phoenix API endpoint")
|
|
99
|
+
.option("--api-key <key>", "Phoenix API key for authentication")
|
|
100
|
+
.option("--format <format>", "Output format: pretty, json, or raw", "pretty")
|
|
101
|
+
.option("--no-progress", "Disable progress indicators")
|
|
102
|
+
.option("--file <path>", "Save experiment to file instead of stdout")
|
|
103
|
+
.action(experimentHandler);
|
|
104
|
+
return command;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=experiment.js.map
|