@dreamlake/dreamlake-cli 0.105.0 → 0.106.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/dist/api/index.d.ts +220 -14
- package/dist/api/native-experiments.d.ts +218 -7
- package/dist/api/native-experiments.js +154 -9
- package/dist/cli/auth/commands.d.ts +11 -1
- package/dist/cli/auth/commands.js +34 -10
- package/dist/cli/experiments/native-commands.d.ts +3 -1
- package/dist/cli/experiments/native-commands.js +21 -14
- package/dist/cli/experiments/native-run-data.d.ts +51 -0
- package/dist/cli/experiments/native-run-data.js +826 -0
- package/dist/cli/help-examples.generated.js +48 -37
- package/dist/cli/index.js +4 -3
- package/dist/cli/memos/move-command.js +2 -2
- package/dist/cli/skill/index.js +1 -1
- package/dist/cli/version.d.ts +1 -1
- package/dist/cli/version.js +1 -1
- package/package.json +9 -9
|
@@ -1,30 +1,175 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
1
2
|
import { seg } from "./client.js";
|
|
2
3
|
import { call } from "./common.js";
|
|
3
|
-
|
|
4
|
+
function trackQuery(q) {
|
|
5
|
+
return { start_timestamp: q.startTimestamp, end_timestamp: q.endTimestamp, columns: q.columns?.join(","), format: q.format };
|
|
6
|
+
}
|
|
7
|
+
export function nativeExperimentPaths(namespace, project) {
|
|
4
8
|
const base = `/native-experiments/ns/${seg(namespace)}/projects/${seg(project)}`;
|
|
5
9
|
const run = (id) => `${base}/runs/${seg(id)}`;
|
|
10
|
+
return {
|
|
11
|
+
base,
|
|
12
|
+
run,
|
|
13
|
+
parameters: (id) => `${run(id)}/parameters`,
|
|
14
|
+
logs: (id) => `${run(id)}/logs`,
|
|
15
|
+
metrics: (id) => `${run(id)}/metrics`,
|
|
16
|
+
metric: (id, name) => `${run(id)}/metrics/${seg(name)}`,
|
|
17
|
+
metricStats: (id, name) => `${run(id)}/metrics/${seg(name)}/stats`,
|
|
18
|
+
files: (id) => `${run(id)}/files`,
|
|
19
|
+
file: (id, fileId) => `${run(id)}/files/${seg(fileId)}`,
|
|
20
|
+
fileDownload: (id, fileId) => `${run(id)}/files/${seg(fileId)}/download`,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/** Query parameters of a log read, as the server names them (`level` is a comma list). */
|
|
24
|
+
export function nativeLogQuery(query = {}) {
|
|
25
|
+
const { level, ...rest } = query;
|
|
26
|
+
return { ...rest, ...(level ? { level: level.join(",") } : {}) };
|
|
27
|
+
}
|
|
28
|
+
async function sha256(data) {
|
|
29
|
+
const hash = createHash("sha256");
|
|
30
|
+
if (data instanceof Uint8Array)
|
|
31
|
+
return hash.update(data).digest("hex");
|
|
32
|
+
for await (const chunk of data.stream())
|
|
33
|
+
hash.update(chunk);
|
|
34
|
+
return hash.digest("hex");
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The multipart body of a file upload. Text fields precede the file part: the server reads
|
|
38
|
+
* only the fields received before the file, and verifies `sizeBytes` and `checksum` against it.
|
|
39
|
+
*/
|
|
40
|
+
export async function nativeFileForm(upload) {
|
|
41
|
+
const blob = upload.data instanceof Uint8Array
|
|
42
|
+
? new Blob([upload.data], { type: upload.contentType ?? "application/octet-stream" })
|
|
43
|
+
: upload.data;
|
|
44
|
+
const form = new FormData();
|
|
45
|
+
form.append("sizeBytes", String(blob.size));
|
|
46
|
+
form.append("checksum", upload.checksum ?? await sha256(upload.data));
|
|
47
|
+
if (upload.prefix !== undefined)
|
|
48
|
+
form.append("prefix", upload.prefix);
|
|
49
|
+
if (upload.description !== undefined)
|
|
50
|
+
form.append("description", upload.description);
|
|
51
|
+
if (upload.tags?.length)
|
|
52
|
+
form.append("tags", upload.tags.join(","));
|
|
53
|
+
if (upload.metadata !== undefined)
|
|
54
|
+
form.append("metadata", JSON.stringify(upload.metadata));
|
|
55
|
+
if (upload.folderId !== undefined)
|
|
56
|
+
form.append("folderId", upload.folderId);
|
|
57
|
+
const typed = upload.contentType && blob.type !== upload.contentType ? new Blob([blob], { type: upload.contentType }) : blob;
|
|
58
|
+
form.append("file", typed, upload.filename);
|
|
59
|
+
return form;
|
|
60
|
+
}
|
|
61
|
+
export function nativeExperimentsApi(t, namespace, project) {
|
|
62
|
+
const p = nativeExperimentPaths(namespace, project);
|
|
63
|
+
const { base, run } = p;
|
|
6
64
|
return {
|
|
7
65
|
status: () => call(t, "GET", `${base}/status`),
|
|
8
66
|
session: (mode) => call(t, "POST", `${base}/session`, { mode }),
|
|
9
|
-
create: (key) => call(t, "PUT", run(key)),
|
|
67
|
+
create: (key, body) => call(t, "PUT", run(key), body),
|
|
68
|
+
/** ml-dash's `Experiment(prefix="ns/project/a/b/name")`: create-or-get the run named last in folder `a/b`. */
|
|
69
|
+
createAt: (segments, body) => call(t, "PUT", `${base}/run-paths/${segments.map(seg).join("/")}`, body),
|
|
70
|
+
/** Purge a trashed run for good (ADMIN): 202, its data deleted in the background. */
|
|
71
|
+
purge: (id) => call(t, "POST", `${run(id)}/purge`),
|
|
72
|
+
folders: {
|
|
73
|
+
/** `{ path }` (mkdir -p) or `{ parentId?, name }`: the folder, created if missing. */
|
|
74
|
+
create: (body) => call(t, "POST", `${base}/folders`, body),
|
|
75
|
+
list: (query = {}) => call(t, "GET", `${base}/folders`, undefined, query),
|
|
76
|
+
get: (id) => call(t, "GET", `${base}/folders/${seg(id)}`),
|
|
77
|
+
/** Rename and/or move (`parentId` null: the project root). */
|
|
78
|
+
update: (id, patch) => call(t, "PATCH", `${base}/folders/${seg(id)}`, patch),
|
|
79
|
+
byPath: (segments) => call(t, "GET", `${base}/by-path/${segments.map(seg).join("/")}`),
|
|
80
|
+
/** An operation on every run below: 202 `{ operationId, state }`, applied by the server's worker. */
|
|
81
|
+
operate: (id, kind) => call(t, "POST", `${base}/folders/${seg(id)}/${kind}`),
|
|
82
|
+
operation: (operationId) => call(t, "GET", `${base}/folder-operations/${seg(operationId)}`),
|
|
83
|
+
},
|
|
84
|
+
/** ml-dash's batch delete: up to 100 runs and folders, each on its own, one receipt per item. */
|
|
85
|
+
batch: (action, items) => call(t, "POST", `${base}/batch/${action}`, { items }),
|
|
10
86
|
list: (query = {}) => call(t, "GET", `${base}/runs`, undefined, query),
|
|
11
87
|
get: (id) => call(t, "GET", run(id)),
|
|
12
88
|
trash: (query = {}) => call(t, "GET", `${base}/trash`, undefined, query),
|
|
13
89
|
delete: (id) => call(t, "DELETE", run(id)),
|
|
14
90
|
restoreDeleted: (id) => call(t, "POST", `${run(id)}/restore`),
|
|
15
91
|
archive: (id, archived) => call(t, "PATCH", run(id), { archived }),
|
|
92
|
+
/**
|
|
93
|
+
* Run metadata: `description` (null clears), `tags` (replaces the set), ml-dash's `metadata` dict; a person's
|
|
94
|
+
* rename/move (`name`, `folderPath` "" for the root) and `writeProtected` (set or clear).
|
|
95
|
+
*/
|
|
96
|
+
update: (id, patch) => call(t, "PATCH", run(id), patch),
|
|
16
97
|
parameters: {
|
|
17
|
-
get: (id) => call(t, "GET",
|
|
18
|
-
set: (id, data) => call(t, "POST",
|
|
98
|
+
get: (id) => call(t, "GET", p.parameters(id)),
|
|
99
|
+
set: (id, data) => call(t, "POST", p.parameters(id), { data }),
|
|
100
|
+
delete: (id) => call(t, "DELETE", p.parameters(id)),
|
|
19
101
|
},
|
|
20
102
|
logs: {
|
|
21
|
-
list: (id, query = {}) => call(t, "GET",
|
|
22
|
-
append: (id, entries) => call(t, "POST",
|
|
103
|
+
list: (id, query = {}) => call(t, "GET", p.logs(id), undefined, nativeLogQuery(query)),
|
|
104
|
+
append: (id, entries) => call(t, "POST", p.logs(id), { entries }),
|
|
23
105
|
},
|
|
24
106
|
metrics: {
|
|
25
|
-
list: (id) => call(t, "GET",
|
|
26
|
-
rows: (id, name, query = {}) => call(t, "GET",
|
|
27
|
-
|
|
107
|
+
list: (id) => call(t, "GET", p.metrics(id)),
|
|
108
|
+
rows: (id, name, query = {}) => call(t, "GET", p.metric(id, name), undefined, query),
|
|
109
|
+
/** `descriptor` is stored with the points, atomically, only when this append creates the metric. */
|
|
110
|
+
append: (id, name, dataPoints, descriptor = {}) => call(t, "POST", p.metric(id, name), { dataPoints, ...descriptor }),
|
|
111
|
+
stats: (id, name) => call(t, "GET", p.metricStats(id, name)),
|
|
112
|
+
updateMetadata: (id, name, patch) => call(t, "PATCH", p.metric(id, name), patch),
|
|
113
|
+
},
|
|
114
|
+
files: {
|
|
115
|
+
list: (id, query = {}) => call(t, "GET", p.files(id), undefined, { prefix: query.prefix, tags: query.tags?.join(",") }),
|
|
116
|
+
get: (id, fileId) => call(t, "GET", p.file(id, fileId)),
|
|
117
|
+
upload: async (id, upload) => t.request("POST", p.files(id), { body: await nativeFileForm(upload) }),
|
|
118
|
+
/** The file's bytes from the central API; redirects are refused, so the bearer never leaves it. */
|
|
119
|
+
download: (id, fileId, options = {}) => {
|
|
120
|
+
if (!t.raw)
|
|
121
|
+
throw new Error("This transport cannot stream file downloads.");
|
|
122
|
+
return t.raw("GET", p.fileDownload(id, fileId), { redirect: "error", ...(options.signal ? { signal: options.signal, timeoutMs: null } : {}) });
|
|
123
|
+
},
|
|
124
|
+
update: (id, fileId, patch) => call(t, "PATCH", p.file(id, fileId), patch),
|
|
125
|
+
delete: (id, fileId) => call(t, "DELETE", p.file(id, fileId)),
|
|
126
|
+
/** A signed read URL (images and video only, short-lived). */
|
|
127
|
+
media: (id, fileId) => call(t, "GET", `${p.file(id, fileId)}/media`),
|
|
128
|
+
},
|
|
129
|
+
/** Project and folder files (README.md, `.dashrc`): not a run's. `folderId` absent or "root": the project root. */
|
|
130
|
+
projectFiles: {
|
|
131
|
+
list: (query = {}) => call(t, "GET", `${base}/project-files`, undefined, query),
|
|
132
|
+
upload: async (upload) => t.request("POST", `${base}/project-files`, { body: await nativeFileForm(upload) }),
|
|
133
|
+
get: (fileId) => call(t, "GET", `${base}/project-files/${seg(fileId)}`),
|
|
134
|
+
/** UTF-8 text, at most 512 KiB (larger: 413, never truncated). */
|
|
135
|
+
text: (fileId) => call(t, "GET", `${base}/project-files/${seg(fileId)}/text`),
|
|
136
|
+
download: (fileId, options = {}) => {
|
|
137
|
+
if (!t.raw)
|
|
138
|
+
throw new Error("This transport cannot stream file downloads.");
|
|
139
|
+
return t.raw("GET", `${base}/project-files/${seg(fileId)}/download`, { redirect: "error", ...(options.signal ? { signal: options.signal, timeoutMs: null } : {}) });
|
|
140
|
+
},
|
|
141
|
+
media: (fileId) => call(t, "GET", `${base}/project-files/${seg(fileId)}/media`),
|
|
142
|
+
/** New bytes for the same file: its id, name and metadata stay. */
|
|
143
|
+
replace: async (fileId, upload) => t.request("PUT", `${base}/project-files/${seg(fileId)}/content`, { body: await nativeFileForm(upload) }),
|
|
144
|
+
/** description/tags/metadata, and/or `filename` and `folderId` (null: the root) to rename or move. */
|
|
145
|
+
update: (fileId, patch) => call(t, "PATCH", `${base}/project-files/${seg(fileId)}`, patch),
|
|
146
|
+
delete: (fileId) => call(t, "DELETE", `${base}/project-files/${seg(fileId)}`),
|
|
147
|
+
},
|
|
148
|
+
/** The run's dashboard (its `.dashrc`, else ml-dash's default), read-only: one JSON section, or charts of one type. */
|
|
149
|
+
dashboard: {
|
|
150
|
+
section: (id, field) => call(t, "GET", `${run(id)}/dashboard/${field}`),
|
|
151
|
+
charts: (id, type) => call(t, "GET", `${run(id)}/dashboard/charts/${type}`),
|
|
152
|
+
},
|
|
153
|
+
/** The bindrs a run, or one item of it, is in; attach (by id, or by name: found or created) and detach. */
|
|
154
|
+
bindrs: {
|
|
155
|
+
list: (id, item) => call(t, "GET", `${run(id)}/bindrs`, undefined, (item ? { itemKind: item.kind, itemId: item.id } : {})),
|
|
156
|
+
attach: (id, ref) => call(t, "POST", `${run(id)}/bindrs`, ref),
|
|
157
|
+
detach: (id, ref) => call(t, "DELETE", `${run(id)}/bindrs`, ref),
|
|
158
|
+
},
|
|
159
|
+
/** Tracks of a Dash-homed run; `topic` may contain `/` (encoded as one path segment). */
|
|
160
|
+
tracks: {
|
|
161
|
+
list: (id, query = {}) => call(t, "GET", `${run(id)}/tracks`, undefined, query),
|
|
162
|
+
create: (id, topic, descriptor = {}) => call(t, "POST", `${run(id)}/tracks`, { topic, ...descriptor }),
|
|
163
|
+
/** Entries `{ timestamp, ...data }`, at most 10000, appended in one commit. */
|
|
164
|
+
append: (id, topic, entries) => call(t, "POST", `${run(id)}/tracks/${seg(topic)}/append_batch`, { entries }),
|
|
165
|
+
/** Track data: `json` returns `{ entries, count }`; use `export` for jsonl, parquet (Arrow IPC) or mcap bytes. */
|
|
166
|
+
read: (id, topic, query = {}) => call(t, "GET", `${run(id)}/tracks/${seg(topic)}/data`, undefined, trackQuery({ ...query, format: "json" })),
|
|
167
|
+
export: (id, topic, query, options = {}) => {
|
|
168
|
+
if (!t.raw)
|
|
169
|
+
throw new Error("This transport cannot stream track exports.");
|
|
170
|
+
return t.raw("GET", `${run(id)}/tracks/${seg(topic)}/data`, { query: trackQuery(query), redirect: "error",
|
|
171
|
+
...(options.signal ? { signal: options.signal, timeoutMs: null } : {}) });
|
|
172
|
+
},
|
|
28
173
|
},
|
|
29
174
|
setStatus: (id, status) => call(t, "POST", `${run(id)}/status`, { status }),
|
|
30
175
|
};
|
|
@@ -17,7 +17,17 @@ export declare const DEFAULT_LOGIN_ENV = "prod";
|
|
|
17
17
|
*/
|
|
18
18
|
export declare function resolveLoginEnvName(explicit?: string, filePath?: string): string;
|
|
19
19
|
export declare function runLogin(args: LoginArgs): Promise<number>;
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Shared-login logout (contract v1, docs: Environments → Shared login contract).
|
|
22
|
+
* Removes one saved environment (default: the active one). The projection
|
|
23
|
+
* (tokens.json + config.json) is replaced only when it still holds that
|
|
24
|
+
* environment's server and token: it then becomes the next saved environment,
|
|
25
|
+
* or is cleared. With no saved environment, a projection another client left
|
|
26
|
+
* behind is cleared, so a logout always stays logged out.
|
|
27
|
+
*/
|
|
28
|
+
export declare function runLogout(opts?: {
|
|
29
|
+
env?: string;
|
|
30
|
+
}): Promise<number>;
|
|
21
31
|
export declare function runEnvList(opts: {
|
|
22
32
|
json?: boolean;
|
|
23
33
|
}): Promise<number>;
|
|
@@ -16,7 +16,7 @@ import { spawn } from "node:child_process";
|
|
|
16
16
|
import { resolveRemote, resolveToken, decodeJwtPayload } from "../config.js";
|
|
17
17
|
import { emitJson, renderTable } from "../helpers.js";
|
|
18
18
|
import { authFilePath, builtinEnv, BUILTIN_ENVS, currentEnv, currentEnvName, listEnvs, removeEnv, saveEnv, useEnv, } from "./credentials.js";
|
|
19
|
-
import { clearProjection, dreamlakeDir, projectEnv } from "./materialized.js";
|
|
19
|
+
import { clearProjection, dreamlakeDir, projectEnv, readConfig, readToken } from "./materialized.js";
|
|
20
20
|
import { getOrCreateDeviceSecret } from "./device-secret.js";
|
|
21
21
|
import { AuthorizationDeniedError, DeviceCodeExpiredError, DeviceFlowClient, TokenExchangeError, } from "./device-flow.js";
|
|
22
22
|
async function fetchAuthMe(remote, token) {
|
|
@@ -178,21 +178,45 @@ export async function runLogin(args) {
|
|
|
178
178
|
return 0;
|
|
179
179
|
}
|
|
180
180
|
// ─── logout ──────────────────────────────────────────────────────────
|
|
181
|
-
|
|
182
|
-
|
|
181
|
+
/**
|
|
182
|
+
* Shared-login logout (contract v1, docs: Environments → Shared login contract).
|
|
183
|
+
* Removes one saved environment (default: the active one). The projection
|
|
184
|
+
* (tokens.json + config.json) is replaced only when it still holds that
|
|
185
|
+
* environment's server and token: it then becomes the next saved environment,
|
|
186
|
+
* or is cleared. With no saved environment, a projection another client left
|
|
187
|
+
* behind is cleared, so a logout always stays logged out.
|
|
188
|
+
*/
|
|
189
|
+
export async function runLogout(opts = {}) {
|
|
190
|
+
const name = opts.env ?? currentEnvName();
|
|
191
|
+
const projectedToken = readToken();
|
|
192
|
+
const projectedServer = readConfig().remote_url?.replace(/\/+$/, "");
|
|
183
193
|
if (!name) {
|
|
184
|
-
|
|
194
|
+
if (projectedToken) {
|
|
195
|
+
clearProjection();
|
|
196
|
+
process.stdout.write(`✓ Logged out of ${projectedServer ?? "the unsaved connection"} (it had no saved environment).\n`);
|
|
197
|
+
}
|
|
198
|
+
else
|
|
199
|
+
process.stdout.write(`No active environment (${authFilePath()})\n`);
|
|
185
200
|
return 0;
|
|
186
201
|
}
|
|
202
|
+
const removed = listEnvs().find(e => e.name === name)?.env;
|
|
203
|
+
if (!removed) {
|
|
204
|
+
process.stderr.write(`✗ No saved environment '${name}'. Saved: ${listEnvs().map(e => e.name).join(", ") || "(none)"}\n`);
|
|
205
|
+
return 1;
|
|
206
|
+
}
|
|
187
207
|
removeEnv(name);
|
|
188
|
-
const
|
|
189
|
-
if (
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
208
|
+
const wasProjected = projectedToken === removed.token && projectedServer === removed.server.replace(/\/+$/, "");
|
|
209
|
+
if (wasProjected) {
|
|
210
|
+
const next = currentEnv();
|
|
211
|
+
if (next)
|
|
212
|
+
projectEnv(next);
|
|
213
|
+
else
|
|
214
|
+
clearProjection();
|
|
215
|
+
}
|
|
193
216
|
const nextName = currentEnvName();
|
|
194
217
|
process.stdout.write(`✓ Logged out of '${name}'.` +
|
|
195
|
-
(
|
|
218
|
+
(!wasProjected ? " The active connection was a different environment and is unchanged.\n"
|
|
219
|
+
: nextName ? ` Active environment is now '${nextName}'.\n` : " No environments left.\n"));
|
|
196
220
|
return 0;
|
|
197
221
|
}
|
|
198
222
|
// ─── env (environment switching) ──────────────────────────────────────
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Command } from "commander";
|
|
2
|
-
type Action = "list" | "
|
|
2
|
+
type Action = "list" | "archive" | "restore" | "log" | "trash-list" | "delete" | "trash-restore";
|
|
3
3
|
interface Options {
|
|
4
4
|
namespace: string;
|
|
5
5
|
project: string;
|
|
@@ -7,6 +7,8 @@ interface Options {
|
|
|
7
7
|
limit?: string;
|
|
8
8
|
cursor?: string;
|
|
9
9
|
level?: string;
|
|
10
|
+
includeArchived?: boolean;
|
|
11
|
+
folder?: string;
|
|
10
12
|
}
|
|
11
13
|
export declare function runNativeExperiment(action: Action, opts: Options, subject?: string, message?: string): Promise<number>;
|
|
12
14
|
export declare function registerNativeExperimentCommands(parent: Command): void;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { HttpError, requestJson } from "../client.js";
|
|
2
2
|
import { resolveRemote, resolveToken } from "../config.js";
|
|
3
3
|
import { emitJson, fail } from "../helpers.js";
|
|
4
|
+
import { registerNativeRunDataCommands, runNativeProject } from "./native-run-data.js";
|
|
4
5
|
const id = /^[0-9a-f]{24}$/;
|
|
5
|
-
const key = /^[A-Za-z0-9_-]{1,128}$/;
|
|
6
6
|
export async function runNativeExperiment(action, opts, subject, message) {
|
|
7
7
|
try {
|
|
8
8
|
const token = resolveToken();
|
|
@@ -16,20 +16,17 @@ export async function runNativeExperiment(action, opts, subject, message) {
|
|
|
16
16
|
const limit = opts.limit === undefined ? 50 : Number(opts.limit);
|
|
17
17
|
if (!Number.isSafeInteger(limit) || limit < 1 || limit > 100 ||
|
|
18
18
|
opts.limit !== undefined && !/^[1-9][0-9]*$/.test(opts.limit) ||
|
|
19
|
-
opts.cursor !== undefined && !id.test(opts.cursor)
|
|
20
|
-
|
|
19
|
+
opts.cursor !== undefined && !id.test(opts.cursor) ||
|
|
20
|
+
opts.folder !== undefined && opts.folder !== "root" && !id.test(opts.folder))
|
|
21
|
+
throw new Error("Invalid list limit, cursor or folder.");
|
|
21
22
|
emitJson(await requestJson(remote, `${base}/${action === "trash-list" ? "trash" : "runs"}`, { token, query: { limit,
|
|
22
|
-
...(opts.cursor ? { cursor: opts.cursor } : {})
|
|
23
|
+
...(opts.cursor ? { cursor: opts.cursor } : {}), ...(action === "list" && opts.includeArchived ? { includeArchived: "true" } : {}),
|
|
24
|
+
...(action === "list" && opts.folder !== undefined ? { folderId: opts.folder } : {}) }, redirect: "error" }));
|
|
23
25
|
return 0;
|
|
24
26
|
}
|
|
25
|
-
if (!subject || !
|
|
26
|
-
throw new Error(
|
|
27
|
-
|
|
28
|
-
: "Run ID must be a DreamLake native Experiment ID.");
|
|
29
|
-
if (action === "create") {
|
|
30
|
-
emitJson(await requestJson(remote, `${base}/runs/${encodeURIComponent(subject)}`, { token, method: "PUT", redirect: "error" }));
|
|
31
|
-
}
|
|
32
|
-
else if (action === "delete" || action === "trash-restore") {
|
|
27
|
+
if (!subject || !id.test(subject))
|
|
28
|
+
throw new Error("Run ID must be a DreamLake native Experiment ID.");
|
|
29
|
+
if (action === "delete" || action === "trash-restore") {
|
|
33
30
|
emitJson(await requestJson(remote, `${base}/runs/${subject}${action === "trash-restore" ? "/restore" : ""}`, {
|
|
34
31
|
token, method: action === "delete" ? "DELETE" : "POST", redirect: "error"
|
|
35
32
|
}));
|
|
@@ -63,11 +60,20 @@ export function registerNativeExperimentCommands(parent) {
|
|
|
63
60
|
.requiredOption("--project <slug>", "DreamLake project")
|
|
64
61
|
.option("--json", "emit structured errors (success is JSON)");
|
|
65
62
|
common(runs.command("list").description("list active native runs"))
|
|
63
|
+
.option("--include-archived", "also list archived runs")
|
|
64
|
+
.option("--folder <folder-id|root>", "only the runs in this folder")
|
|
66
65
|
.option("--limit <count>", "page size, 1-100")
|
|
67
66
|
.option("--cursor <id>", "nextCursor from the previous page")
|
|
68
67
|
.action(async (opts) => { process.exitCode = await runNativeExperiment("list", opts); });
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
// ml-dash's `Experiment(prefix=...)`: a root key, or `folder/.../name` (folders created as needed), with the run's
|
|
69
|
+
// description, tags, metadata and protection written with it in one transaction.
|
|
70
|
+
common(runs.command("create").description("create-or-get a native run by key or folder path").argument("<key-or-path>"))
|
|
71
|
+
.option("--description <text>", "run description")
|
|
72
|
+
.option("--tags <list>", "comma-separated run tags")
|
|
73
|
+
.option("--metadata <file|->", "run metadata: a JSON object from a file or stdin")
|
|
74
|
+
.option("--write-protected", "create the run write-protected (a person's action; never unprotects an existing run)")
|
|
75
|
+
.option("--bindrs <names>", "comma-separated bindr names to attach the run to (created if missing)")
|
|
76
|
+
.action(async (subject, opts) => { process.exitCode = await runNativeProject("create", opts, [subject]); });
|
|
71
77
|
for (const action of ["archive", "restore"])
|
|
72
78
|
common(runs.command(action).description(`${action} a native run`).argument("<run-id>"))
|
|
73
79
|
.action(async (subject, opts) => { process.exitCode = await runNativeExperiment(action, opts, subject); });
|
|
@@ -85,4 +91,5 @@ export function registerNativeExperimentCommands(parent) {
|
|
|
85
91
|
.action(async (subject, message, opts) => {
|
|
86
92
|
process.exitCode = await runNativeExperiment("log", opts, subject, message);
|
|
87
93
|
});
|
|
94
|
+
registerNativeRunDataCommands(runs, common);
|
|
88
95
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
export interface RunDataOptions {
|
|
3
|
+
namespace: string;
|
|
4
|
+
project: string;
|
|
5
|
+
json?: boolean;
|
|
6
|
+
limit?: string;
|
|
7
|
+
cursor?: string;
|
|
8
|
+
data?: string;
|
|
9
|
+
level?: string;
|
|
10
|
+
startTime?: string;
|
|
11
|
+
endTime?: string;
|
|
12
|
+
search?: string;
|
|
13
|
+
orderBy?: string;
|
|
14
|
+
order?: string;
|
|
15
|
+
prefix?: string;
|
|
16
|
+
tags?: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
metadata?: string;
|
|
19
|
+
contentType?: string;
|
|
20
|
+
name?: string;
|
|
21
|
+
out?: string;
|
|
22
|
+
topic?: string;
|
|
23
|
+
format?: string;
|
|
24
|
+
start?: string;
|
|
25
|
+
end?: string;
|
|
26
|
+
columns?: string;
|
|
27
|
+
writeProtected?: boolean;
|
|
28
|
+
folder?: string;
|
|
29
|
+
parent?: string;
|
|
30
|
+
runs?: string;
|
|
31
|
+
folders?: string;
|
|
32
|
+
bindrs?: string;
|
|
33
|
+
bindr?: string;
|
|
34
|
+
bindrId?: string;
|
|
35
|
+
itemKind?: string;
|
|
36
|
+
itemId?: string;
|
|
37
|
+
charts?: string;
|
|
38
|
+
}
|
|
39
|
+
export type RunDataAction = "show" | "update" | "status" | "params-get" | "params-set" | "params-delete" | "metrics-list" | "metrics-rows" | "metrics-append" | "metrics-stats" | "metrics-metadata" | "logs-read" | "logs-append" | "files-list" | "files-get" | "files-upload" | "files-download" | "files-update" | "files-delete" | "tracks-list" | "tracks-create" | "tracks-append" | "tracks-read" | "files-media" | "dashboard" | "bindrs-list" | "bindrs-attach" | "bindrs-detach";
|
|
40
|
+
/** Run one action; success is always JSON on stdout, errors follow `--json`. */
|
|
41
|
+
export declare function runNativeRunData(action: RunDataAction, opts: RunDataOptions, args: string[]): Promise<number>;
|
|
42
|
+
export type NativeProjectAction = "create" | "move" | "protect" | "unprotect" | "purge" | "folders-list" | "folders-create" | "folders-show" | "folders-move" | "folders-resolve" | "folders-operate" | "folders-operation" | "batch" | "pfiles-list" | "pfiles-upload" | "pfiles-show" | "pfiles-text" | "pfiles-download" | "pfiles-media" | "pfiles-replace" | "pfiles-update" | "pfiles-delete";
|
|
43
|
+
/**
|
|
44
|
+
* Runs and folders of the project (protocol 6): create-or-get by key or path, with the run's description, tags,
|
|
45
|
+
* metadata and protection written with it; a person's move/rename, protection and purge; folders and their
|
|
46
|
+
* operations; batch trash/purge. The DreamLake login is the person's: the server refuses people-only actions
|
|
47
|
+
* to any other session, and the CLI has no other.
|
|
48
|
+
*/
|
|
49
|
+
export declare function runNativeProject(action: NativeProjectAction, opts: RunDataOptions, args: string[]): Promise<number>;
|
|
50
|
+
/** `experiments runs show|status|params|metrics|logs|files`. */
|
|
51
|
+
export declare function registerNativeRunDataCommands(runs: Command, common: (command: Command) => Command): void;
|