@dreamlake/dreamlake-cli 0.116.0 → 0.118.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.
Files changed (52) hide show
  1. package/dist/api/file-multipart.d.ts +6 -0
  2. package/dist/api/file-multipart.js +11 -0
  3. package/dist/api/index.d.ts +70 -2
  4. package/dist/api/index.js +2 -0
  5. package/dist/api/native-experiments.d.ts +25 -0
  6. package/dist/api/native-experiments.js +49 -3
  7. package/dist/api/project-access.d.ts +42 -0
  8. package/dist/api/project-access.js +67 -0
  9. package/dist/api/project-audience.d.ts +32 -0
  10. package/dist/api/project-audience.js +23 -0
  11. package/dist/api/workspace.d.ts +14 -1
  12. package/dist/api/workspace.js +5 -0
  13. package/dist/cli/create/index.d.ts +1 -0
  14. package/dist/cli/create/index.js +25 -7
  15. package/dist/cli/experiments/index.js +4 -0
  16. package/dist/cli/experiments/management.d.ts +16 -0
  17. package/dist/cli/experiments/management.js +82 -0
  18. package/dist/cli/experiments/transfer/adapter.d.ts +86 -0
  19. package/dist/cli/experiments/transfer/adapter.js +637 -0
  20. package/dist/cli/experiments/transfer/context.d.ts +13 -0
  21. package/dist/cli/experiments/transfer/context.js +20 -0
  22. package/dist/cli/experiments/transfer/download.d.ts +24 -0
  23. package/dist/cli/experiments/transfer/download.js +516 -0
  24. package/dist/cli/experiments/transfer/index.d.ts +2 -0
  25. package/dist/cli/experiments/transfer/index.js +38 -0
  26. package/dist/cli/experiments/transfer/local/safe-path.d.ts +29 -0
  27. package/dist/cli/experiments/transfer/local/safe-path.js +106 -0
  28. package/dist/cli/experiments/transfer/local/storage.d.ts +125 -0
  29. package/dist/cli/experiments/transfer/local/storage.js +432 -0
  30. package/dist/cli/experiments/transfer/transport.d.ts +7 -0
  31. package/dist/cli/experiments/transfer/transport.js +31 -0
  32. package/dist/cli/experiments/transfer/types.d.ts +48 -0
  33. package/dist/cli/experiments/transfer/types.js +1 -0
  34. package/dist/cli/experiments/transfer/upload.d.ts +58 -0
  35. package/dist/cli/experiments/transfer/upload.js +665 -0
  36. package/dist/cli/experiments/transfer/util/ansi.d.ts +24 -0
  37. package/dist/cli/experiments/transfer/util/ansi.js +70 -0
  38. package/dist/cli/experiments/transfer/util/glob.d.ts +4 -0
  39. package/dist/cli/experiments/transfer/util/glob.js +39 -0
  40. package/dist/cli/experiments/transfer/util/json.d.ts +6 -0
  41. package/dist/cli/experiments/transfer/util/json.js +58 -0
  42. package/dist/cli/experiments/transfer/util/pool.d.ts +5 -0
  43. package/dist/cli/experiments/transfer/util/pool.js +21 -0
  44. package/dist/cli/help-examples.generated.js +16 -0
  45. package/dist/cli/project/access.d.ts +10 -0
  46. package/dist/cli/project/access.js +43 -0
  47. package/dist/cli/project/index.js +19 -0
  48. package/dist/cli/project/permissions.d.ts +10 -0
  49. package/dist/cli/project/permissions.js +202 -0
  50. package/dist/cli/version.d.ts +1 -1
  51. package/dist/cli/version.js +1 -1
  52. package/package.json +9 -9
@@ -0,0 +1,31 @@
1
+ import { ApiError } from '../../../api/client.js';
2
+ import { ManagementError } from './context.js';
3
+ export const isNativeMetricName = (v) => v.length > 0 && !v.includes('/') && v !== '.' && v !== '..' && [...v].length <= 256;
4
+ export const validName = (v) => v.trim().length > 0 && [...v].length <= 255 && !v.includes('/') && v !== '.' && v !== '..' && !/[\x00-\x1f\x7f]/.test(v);
5
+ export const nativeError = (code, message, remediation, retryable = false) => new ManagementError(code, message, remediation, retryable);
6
+ export async function call(c, route, method = 'GET', body, form) {
7
+ try {
8
+ return await c.transport.raw(method, route, { redirect: 'error',
9
+ timeoutMs: form ? 30 * 60 * 1000 : 30000,
10
+ ...(form ? { body: form.body, headers: { 'content-type': form.contentType } } : { json: body }) });
11
+ }
12
+ catch (error) {
13
+ if (error instanceof ApiError) {
14
+ const code = /^NATIVE_[A-Z0-9_]{1,100}$/.test(error.code) ? error.code : `NATIVE_HTTP_${error.status}`;
15
+ throw nativeError(code, `Experiment request failed (HTTP ${error.status}).`, 'Inspect the run before retrying a write.', error.status >= 500);
16
+ }
17
+ throw nativeError('NATIVE_NETWORK_ERROR', 'Request failed; a write outcome may be unknown.', 'Inspect the run before retrying a write.');
18
+ }
19
+ }
20
+ export async function json(c, route, method = 'GET', body, form) {
21
+ const response = await call(c, route, method, body, form);
22
+ try {
23
+ const data = await response.json();
24
+ if (!data || typeof data !== 'object' || Array.isArray(data))
25
+ throw new Error();
26
+ return data;
27
+ }
28
+ catch {
29
+ throw nativeError('NATIVE_INVALID_RESPONSE', 'Invalid native response.', 'Inspect the run before retrying a write.');
30
+ }
31
+ }
@@ -0,0 +1,48 @@
1
+ /** Options normalized from the DreamLake Commander command. */
2
+ export type ParsedArgs = Record<string, any>;
3
+ /** The data operations needed by the .dash transfer algorithms. */
4
+ export interface RemoteClient {
5
+ createOrUpdateExperiment(args: {
6
+ project: string;
7
+ name: string;
8
+ prefix?: string;
9
+ description?: string | null;
10
+ tags?: string[] | null;
11
+ bindrs?: string[] | null;
12
+ metadata?: Record<string, unknown> | null;
13
+ writeProtected?: boolean;
14
+ }): Promise<any>;
15
+ setParameters(id: string, data: Record<string, unknown>): Promise<any>;
16
+ createLogEntries(id: string, entries: Record<string, unknown>[]): Promise<any>;
17
+ appendBatchToMetric(id: string, name: string, points: unknown[]): Promise<any>;
18
+ uploadFile(args: {
19
+ experimentId: string;
20
+ filePath: string;
21
+ filename: string;
22
+ prefix?: string;
23
+ description?: string | null;
24
+ tags?: string[] | null;
25
+ bindrs?: string[] | null;
26
+ metadata?: Record<string, unknown> | null;
27
+ checksum?: string;
28
+ contentType?: string;
29
+ sizeBytes?: number;
30
+ }): Promise<any>;
31
+ getParameters(id: string): Promise<Record<string, unknown>>;
32
+ queryLogs(id: string, options?: {
33
+ limit?: number;
34
+ offset?: number;
35
+ orderBy?: string;
36
+ order?: string;
37
+ }): Promise<any>;
38
+ listMetrics(id: string): Promise<any[]>;
39
+ getMetricStats(id: string, name: string): Promise<any>;
40
+ downloadMetricChunk(id: string, name: string, index: number): Promise<any>;
41
+ getMetricData(id: string, name: string, options?: {
42
+ startIndex?: number;
43
+ limit?: number;
44
+ bufferOnly?: boolean;
45
+ }): Promise<any>;
46
+ listFiles(id: string, limit?: number, offset?: number): Promise<any>;
47
+ downloadFileStreaming(id: string, destination: string): Promise<string>;
48
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,58 @@
1
+ import type { ParsedArgs, RemoteClient } from "./types.js";
2
+ import { LocalStorage, type LocalMetric } from "./local/storage.js";
3
+ export interface ExperimentInfo {
4
+ project: string;
5
+ experiment: string;
6
+ /** Absolute directory holding experiment.json. */
7
+ dir: string;
8
+ /** Location under the .dash root — what LocalStorage reads from. */
9
+ storagePrefix: string;
10
+ /** Prefix declared in experiment.json — what the server is told. */
11
+ declaredPrefix?: string;
12
+ hasLogs: boolean;
13
+ hasParams: boolean;
14
+ metrics: LocalMetric[];
15
+ fileCount: number;
16
+ estimatedSize: number;
17
+ }
18
+ /**
19
+ * Match the three filter modes argparse's `-p` carried in the Python CLI:
20
+ * a glob is fnmatched against the path under the root, a value with a slash is
21
+ * a path prefix, and a bare word is an exact project-name match.
22
+ */
23
+ export declare function matchesFilter(relPath: string, projectName: string, filter: string): boolean;
24
+ export declare function discoverExperiments(storage: LocalStorage, projectFilter?: string, experimentFilter?: string): ExperimentInfo[];
25
+ export interface ValidationResult {
26
+ isValid: boolean;
27
+ warnings: string[];
28
+ errors: string[];
29
+ metadata?: Record<string, any>;
30
+ parameters?: Record<string, unknown>;
31
+ }
32
+ export declare function validateExperiment(storage: LocalStorage, info: ExperimentInfo, strict: boolean): ValidationResult;
33
+ export interface UploadResult {
34
+ experiment: string;
35
+ success: boolean;
36
+ uploaded: Record<string, number>;
37
+ failed: Record<string, string[]>;
38
+ errors: string[];
39
+ bytesUploaded: number;
40
+ }
41
+ /** What one experiment's upload needs from a server: the standalone RemoteClient, or the native adapter. */
42
+ export type ExperimentUploadClient = Pick<RemoteClient, "createOrUpdateExperiment" | "setParameters" | "createLogEntries" | "appendBatchToMetric" | "uploadFile"> & {
43
+ /**
44
+ * Native only: protect a `write_protected` run after every part was written (a native protected run takes no
45
+ * data). The standalone server receives `writeProtected` with the create, as before.
46
+ */
47
+ protectExperiment?(id: string): Promise<void>;
48
+ };
49
+ /**
50
+ * Where an experiment goes: `--target` acts like an scp destination directory (the
51
+ * experiment name is appended; its second segment names the project), else the prefix
52
+ * declared in experiment.json, else the storage location. Reading always uses storagePrefix.
53
+ */
54
+ export declare function remotePrefixFor(info: ExperimentInfo, targetPrefix?: string): {
55
+ fullPrefix: string;
56
+ targetProject: string;
57
+ };
58
+ export declare function run(args: ParsedArgs): Promise<number>;