dataiku-sdk 3.3.0 → 3.5.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 +6 -4
- package/dist/build-metadata.json +1 -1
- package/dist/src/cli/command-syntax.json +14524 -0
- package/dist/src/cli/commands/analysis.js +6 -9
- package/dist/src/cli/commands/api-deployer.js +15 -33
- package/dist/src/cli/commands/api-service.js +17 -27
- package/dist/src/cli/commands/app.js +22 -39
- package/dist/src/cli/commands/bundle.js +15 -24
- package/dist/src/cli/commands/business-app.js +10 -17
- package/dist/src/cli/commands/code-env.js +23 -36
- package/dist/src/cli/commands/code.js +5 -5
- package/dist/src/cli/commands/connection.js +12 -22
- package/dist/src/cli/commands/continuous-activity.js +6 -9
- package/dist/src/cli/commands/dashboard.js +8 -13
- package/dist/src/cli/commands/data-collection.js +9 -16
- package/dist/src/cli/commands/data-quality.js +14 -26
- package/dist/src/cli/commands/dataset.js +28 -51
- package/dist/src/cli/commands/discussion.js +7 -10
- package/dist/src/cli/commands/doctor.js +3 -3
- package/dist/src/cli/commands/flow-zone.js +8 -17
- package/dist/src/cli/commands/folder.js +12 -20
- package/dist/src/cli/commands/future.js +7 -10
- package/dist/src/cli/commands/group.js +7 -11
- package/dist/src/cli/commands/insight.js +7 -11
- package/dist/src/cli/commands/job.js +17 -25
- package/dist/src/cli/commands/knowledge-bank.js +5 -6
- package/dist/src/cli/commands/llm.js +5 -8
- package/dist/src/cli/commands/macro.js +11 -18
- package/dist/src/cli/commands/meaning.js +7 -11
- package/dist/src/cli/commands/metrics.js +7 -10
- package/dist/src/cli/commands/ml-task.js +12 -20
- package/dist/src/cli/commands/model-evaluation-store.js +7 -11
- package/dist/src/cli/commands/notebook.js +15 -27
- package/dist/src/cli/commands/plugin.js +35 -68
- package/dist/src/cli/commands/project-deployer.js +10 -22
- package/dist/src/cli/commands/project-folder.js +10 -17
- package/dist/src/cli/commands/project-git.js +39 -71
- package/dist/src/cli/commands/project-library.js +15 -23
- package/dist/src/cli/commands/project.js +9 -26
- package/dist/src/cli/commands/recipe.d.ts +16 -0
- package/dist/src/cli/commands/recipe.js +83 -94
- package/dist/src/cli/commands/saved-model.js +23 -39
- package/dist/src/cli/commands/scenario.js +21 -35
- package/dist/src/cli/commands/sql.js +4 -4
- package/dist/src/cli/commands/statistics.js +11 -18
- package/dist/src/cli/commands/streaming-endpoint.js +7 -11
- package/dist/src/cli/commands/user.js +11 -22
- package/dist/src/cli/commands/variable.js +3 -4
- package/dist/src/cli/commands/webapp.js +10 -16
- package/dist/src/cli/commands/wiki.js +9 -13
- package/dist/src/cli/commands/workspace.js +8 -14
- package/dist/src/cli/contract.d.ts +5 -15
- package/dist/src/cli/contract.js +179 -461
- package/dist/src/cli/doctor.js +1 -0
- package/dist/src/cli/env.d.ts +2 -0
- package/dist/src/cli/env.js +15 -1
- package/dist/src/cli/helpers/app-permissions.js +2 -1
- package/dist/src/cli/helpers/flow-zone.js +2 -1
- package/dist/src/cli/helpers/recipe.js +2 -1
- package/dist/src/cli/output-schemas.d.ts +24 -0
- package/dist/src/cli/output-schemas.js +233 -0
- package/dist/src/cli/syntax.d.ts +83 -0
- package/dist/src/cli/syntax.js +217 -0
- package/dist/src/cli/types.d.ts +3 -0
- package/dist/src/cli/usage.d.ts +1 -1
- package/dist/src/cli/usage.js +4 -2
- package/dist/src/cli/version.js +2 -0
- package/dist/src/cli.js +37 -64
- package/dist/src/client.d.ts +10 -1
- package/dist/src/client.js +27 -11
- package/dist/src/errors.d.ts +12 -1
- package/dist/src/errors.js +34 -7
- package/dist/src/generated/action-output-schemas.json +1735 -0
- package/dist/src/index.d.ts +1 -3
- package/dist/src/index.js +2 -2
- package/dist/src/resources/api-services.js +2 -3
- package/dist/src/resources/applications.js +2 -4
- package/dist/src/resources/code-envs.js +2 -2
- package/dist/src/resources/data-quality.js +4 -3
- package/dist/src/resources/datasets.d.ts +13 -0
- package/dist/src/resources/datasets.js +42 -8
- package/dist/src/resources/flow-zones.d.ts +6 -2
- package/dist/src/resources/flow-zones.js +10 -5
- package/dist/src/resources/folders.js +4 -2
- package/dist/src/resources/futures.d.ts +2 -0
- package/dist/src/resources/futures.js +39 -27
- package/dist/src/resources/insights.js +3 -2
- package/dist/src/resources/jobs.js +41 -31
- package/dist/src/resources/macros.js +2 -4
- package/dist/src/resources/ml-tasks.js +28 -19
- package/dist/src/resources/notebooks.js +2 -3
- package/dist/src/resources/plugins.d.ts +0 -2
- package/dist/src/resources/plugins.js +0 -3
- package/dist/src/resources/project-git.d.ts +6 -12
- package/dist/src/resources/project-git.js +31 -58
- package/dist/src/resources/project-library.d.ts +0 -2
- package/dist/src/resources/project-library.js +2 -7
- package/dist/src/resources/projects.d.ts +4 -2
- package/dist/src/resources/projects.js +37 -36
- package/dist/src/resources/recipes.d.ts +28 -0
- package/dist/src/resources/recipes.js +116 -84
- package/dist/src/resources/sql.js +8 -3
- package/dist/src/resources/statistics.js +2 -1
- package/dist/src/resources/variables.js +2 -1
- package/dist/src/resources/webapps.js +2 -3
- package/dist/src/schemas.d.ts +1 -2
- package/dist/src/schemas.js +1 -1
- package/dist/src/skill.js +6 -7
- package/dist/src/utils/cleanup-ledger.js +9 -8
- package/dist/src/utils/git-reference.d.ts +12 -0
- package/dist/src/utils/git-reference.js +38 -0
- package/dist/src/utils/polling.d.ts +3 -0
- package/dist/src/utils/polling.js +3 -0
- package/dist/src/utils/project-archive.js +2 -2
- package/dist/src/utils/stable-hash.d.ts +3 -1
- package/dist/src/utils/stable-hash.js +2 -0
- package/package.json +8 -8
- package/plugin.json +1 -1
- package/skills/dataiku-dss/SKILL.md +3 -2
- package/skills/dataiku-dss/references/app-releases.md +2 -3
- package/skills/dataiku-dss/references/authentication.md +7 -7
- package/skills/dataiku-dss/references/coding.md +1 -1
- package/skills/dataiku-dss/references/mutations.md +1 -1
- package/skills/dataiku-dss/references/troubleshooting.md +2 -2
- package/dist/src/utils/pagination.d.ts +0 -8
- package/dist/src/utils/pagination.js +0 -23
|
@@ -1,16 +1,17 @@
|
|
|
1
|
+
import { unexpectedResponseError, } from "../../errors.js";
|
|
1
2
|
import { writeResponseToFile, } from "../../utils/response-file.js";
|
|
2
3
|
import { json, parseBooleanOption, } from "../coerce.js";
|
|
4
|
+
import { commandUsage, withUsage, } from "../syntax.js";
|
|
3
5
|
import { requireArgs, UsageError, } from "../usage.js";
|
|
4
|
-
export const bundleCommands = {
|
|
6
|
+
export const bundleCommands = withUsage("bundle", {
|
|
5
7
|
"list-exported": {
|
|
6
8
|
handler: (c, _a, f) => c.bundles.listExported(f["project-key"]),
|
|
7
|
-
usage: "dss bundle list-exported [--project-key KEY]",
|
|
8
9
|
description: "List bundles exported from a project on the Design node.",
|
|
9
10
|
examples: ["dss bundle list-exported",],
|
|
10
11
|
},
|
|
11
12
|
export: {
|
|
12
13
|
handler: async (c, a, f) => {
|
|
13
|
-
const usage = "
|
|
14
|
+
const usage = commandUsage("bundle", "export");
|
|
14
15
|
requireArgs(a, 1, usage);
|
|
15
16
|
await c.bundles.exportBundle(a[0], f["project-key"], {
|
|
16
17
|
...(typeof f["release-notes"] === "string" ? { releaseNotes: f["release-notes"], } : {}),
|
|
@@ -22,7 +23,6 @@ export const bundleCommands = {
|
|
|
22
23
|
});
|
|
23
24
|
return { exported: a[0], };
|
|
24
25
|
},
|
|
25
|
-
usage: "dss bundle export <bundleId> [--release-notes TEXT] [--evaluate-standards-checks true|false] [--project-key KEY]",
|
|
26
26
|
description: "Create an exported Design-node bundle. --release-notes forwards the documented releaseNotes parameter; --evaluate-standards-checks toggles the documented Project Standards Checks evaluation (default true; this instance forbids disabling it). DSS refuses re-exporting an existing bundle id — delete-exported first to replace one.",
|
|
27
27
|
examples: [
|
|
28
28
|
"dss bundle export v1",
|
|
@@ -31,40 +31,37 @@ export const bundleCommands = {
|
|
|
31
31
|
},
|
|
32
32
|
"delete-exported": {
|
|
33
33
|
handler: async (c, a, f) => {
|
|
34
|
-
requireArgs(a, 1, "
|
|
34
|
+
requireArgs(a, 1, commandUsage("bundle", "delete-exported"));
|
|
35
35
|
await c.bundles.deleteExported(a[0], f["project-key"]);
|
|
36
36
|
return { deleted: true, };
|
|
37
37
|
},
|
|
38
|
-
usage: "dss bundle delete-exported <bundleId> [--project-key KEY]",
|
|
39
38
|
description: "Delete an exported Design-node bundle.",
|
|
40
39
|
examples: ["dss bundle delete-exported v1",],
|
|
41
40
|
},
|
|
42
41
|
"download-exported": {
|
|
43
42
|
handler: async (c, a, f) => {
|
|
44
|
-
requireArgs(a, 1, "
|
|
43
|
+
requireArgs(a, 1, commandUsage("bundle", "download-exported"));
|
|
45
44
|
const out = f["output"];
|
|
46
45
|
if (!out)
|
|
47
46
|
throw new UsageError("--output PATH is required.", "missing_required_flag");
|
|
48
47
|
const res = await c.bundles.downloadExportedArchive(a[0], f["project-key"]);
|
|
49
48
|
if (!res.body) {
|
|
50
|
-
throw
|
|
49
|
+
throw unexpectedResponseError("bundles.downloadExportedArchive response did not include a body");
|
|
51
50
|
}
|
|
52
51
|
const bytes = await writeResponseToFile(out, res);
|
|
53
52
|
return { path: out, bytes, };
|
|
54
53
|
},
|
|
55
|
-
usage: "dss bundle download-exported <bundleId> --output PATH [--project-key KEY]",
|
|
56
54
|
description: "Download an exported Design-node bundle archive to a local file.",
|
|
57
55
|
examples: ["dss bundle download-exported v1 --output ./bundle.zip",],
|
|
58
56
|
},
|
|
59
57
|
publish: {
|
|
60
58
|
handler: (c, a, f) => {
|
|
61
|
-
const usage = "
|
|
59
|
+
const usage = commandUsage("bundle", "publish");
|
|
62
60
|
requireArgs(a, 1, usage);
|
|
63
61
|
return c.bundles.publish(a[0], f["project-key"], typeof f["published-project-key"] === "string"
|
|
64
62
|
? { publishedProjectKey: f["published-project-key"], }
|
|
65
63
|
: {});
|
|
66
64
|
},
|
|
67
|
-
usage: "dss bundle publish <bundleId> [--published-project-key KEY] [--project-key KEY]",
|
|
68
65
|
description: "Publish a Design-node bundle to the Project Deployer; --published-project-key forwards the documented publishedProjectKey query parameter (a new published project is created when no match exists; the source project's key is the server-side default).",
|
|
69
66
|
examples: [
|
|
70
67
|
"dss bundle publish v1",
|
|
@@ -73,32 +70,29 @@ export const bundleCommands = {
|
|
|
73
70
|
},
|
|
74
71
|
"list-imported": {
|
|
75
72
|
handler: (c, _a, f) => c.bundles.listImported(f["project-key"]),
|
|
76
|
-
usage: "dss bundle list-imported [--project-key KEY]",
|
|
77
73
|
description: "List bundles imported into a project on the Automation node.",
|
|
78
74
|
examples: ["dss bundle list-imported",],
|
|
79
75
|
},
|
|
80
76
|
"import-from-archive": {
|
|
81
77
|
handler: (c, a, f) => {
|
|
82
|
-
requireArgs(a, 1, "
|
|
78
|
+
requireArgs(a, 1, commandUsage("bundle", "import-from-archive"));
|
|
83
79
|
return c.bundles.importFromArchive(a[0], f["project-key"]);
|
|
84
80
|
},
|
|
85
|
-
usage: "dss bundle import-from-archive <serverArchivePath> [--project-key KEY]",
|
|
86
81
|
description: "Import a server-side bundle archive into an Automation-node project.",
|
|
87
82
|
examples: ["dss bundle import-from-archive /data/bundles/v1.zip",],
|
|
88
83
|
},
|
|
89
84
|
"import-from-stream": {
|
|
90
85
|
handler: async (c, a, f) => {
|
|
91
|
-
requireArgs(a, 1, "
|
|
86
|
+
requireArgs(a, 1, commandUsage("bundle", "import-from-stream"));
|
|
92
87
|
await c.bundles.importFromStream(a[0], f["project-key"]);
|
|
93
88
|
return { imported: true, };
|
|
94
89
|
},
|
|
95
|
-
usage: "dss bundle import-from-stream <filePath> [--project-key KEY]",
|
|
96
90
|
description: "Upload and import a local bundle archive into an Automation-node project.",
|
|
97
91
|
examples: ["dss bundle import-from-stream ./v1.zip",],
|
|
98
92
|
},
|
|
99
93
|
activate: {
|
|
100
94
|
handler: (c, a, f) => {
|
|
101
|
-
const usage = "
|
|
95
|
+
const usage = commandUsage("bundle", "activate");
|
|
102
96
|
requireArgs(a, 1, usage);
|
|
103
97
|
const rawScenarios = f["scenarios"];
|
|
104
98
|
let scenariosToEnable;
|
|
@@ -108,13 +102,12 @@ export const bundleCommands = {
|
|
|
108
102
|
|| parsed === null
|
|
109
103
|
|| Array.isArray(parsed)
|
|
110
104
|
|| !Object.values(parsed).every((value) => typeof value === "boolean")) {
|
|
111
|
-
throw new UsageError(
|
|
105
|
+
throw new UsageError(`--scenarios must be a JSON object mapping scenario IDs to true|false. Usage: ${commandUsage("bundle", "activate")}`);
|
|
112
106
|
}
|
|
113
107
|
scenariosToEnable = parsed;
|
|
114
108
|
}
|
|
115
109
|
return c.bundles.activate(a[0], f["project-key"], scenariosToEnable !== undefined ? { scenariosToEnable, } : {});
|
|
116
110
|
},
|
|
117
|
-
usage: "dss bundle activate <bundleId> [--scenarios JSON] [--project-key KEY]",
|
|
118
111
|
description: "Activate an imported Automation-node bundle; --scenarios forwards the documented scenario-ID-to-enabled dict as the scenariosActiveOnActivation body.",
|
|
119
112
|
examples: [
|
|
120
113
|
"dss bundle activate v1",
|
|
@@ -123,21 +116,19 @@ export const bundleCommands = {
|
|
|
123
116
|
},
|
|
124
117
|
preload: {
|
|
125
118
|
handler: (c, a, f) => {
|
|
126
|
-
requireArgs(a, 1, "
|
|
119
|
+
requireArgs(a, 1, commandUsage("bundle", "preload"));
|
|
127
120
|
return c.bundles.preload(a[0], f["project-key"]);
|
|
128
121
|
},
|
|
129
|
-
usage: "dss bundle preload <bundleId> [--project-key KEY]",
|
|
130
122
|
description: "Preload an imported Automation-node bundle (stage data/models).",
|
|
131
123
|
examples: ["dss bundle preload v1",],
|
|
132
124
|
},
|
|
133
125
|
"delete-imported": {
|
|
134
126
|
handler: async (c, a, f) => {
|
|
135
|
-
requireArgs(a, 1, "
|
|
127
|
+
requireArgs(a, 1, commandUsage("bundle", "delete-imported"));
|
|
136
128
|
await c.bundles.deleteImported(a[0], f["project-key"]);
|
|
137
129
|
return { deleted: true, };
|
|
138
130
|
},
|
|
139
|
-
usage: "dss bundle delete-imported <bundleId> [--project-key KEY]",
|
|
140
131
|
description: "Delete an imported Automation-node bundle.",
|
|
141
132
|
examples: ["dss bundle delete-imported v1",],
|
|
142
133
|
},
|
|
143
|
-
};
|
|
134
|
+
});
|
|
@@ -1,76 +1,69 @@
|
|
|
1
1
|
import { requiredJsonInput, } from "../coerce.js";
|
|
2
|
+
import { commandUsage, withUsage, } from "../syntax.js";
|
|
2
3
|
import { requireArgs, } from "../usage.js";
|
|
3
|
-
export const businessAppCommands = {
|
|
4
|
+
export const businessAppCommands = withUsage("business-app", {
|
|
4
5
|
list: {
|
|
5
6
|
handler: (c) => c.applications.listBusinessApps(),
|
|
6
|
-
usage: "dss business-app list",
|
|
7
7
|
description: "List all Business Apps.",
|
|
8
8
|
examples: ["dss business-app list",],
|
|
9
9
|
},
|
|
10
10
|
get: {
|
|
11
11
|
handler: (c, a) => {
|
|
12
|
-
requireArgs(a, 1, "
|
|
12
|
+
requireArgs(a, 1, commandUsage("business-app", "get"));
|
|
13
13
|
return c.applications.getBusinessApp(a[0]);
|
|
14
14
|
},
|
|
15
|
-
usage: "dss business-app get <id>",
|
|
16
15
|
description: "Get Business App details.",
|
|
17
16
|
examples: ["dss business-app get my-bapp",],
|
|
18
17
|
},
|
|
19
18
|
settings: {
|
|
20
19
|
handler: (c, a) => {
|
|
21
|
-
requireArgs(a, 1, "
|
|
20
|
+
requireArgs(a, 1, commandUsage("business-app", "settings"));
|
|
22
21
|
return c.applications.getBusinessAppSettings(a[0]);
|
|
23
22
|
},
|
|
24
|
-
usage: "dss business-app settings <id>",
|
|
25
23
|
description: "Get Business App settings.",
|
|
26
24
|
examples: ["dss business-app settings my-bapp",],
|
|
27
25
|
},
|
|
28
26
|
"save-settings": {
|
|
29
27
|
handler: (c, a, f) => {
|
|
30
|
-
requireArgs(a, 1, "
|
|
28
|
+
requireArgs(a, 1, commandUsage("business-app", "save-settings"));
|
|
31
29
|
const body = requiredJsonInput(f, "--data, --data-file, or --stdin is required (settings JSON).");
|
|
32
30
|
return c.applications.saveBusinessAppSettings(a[0], body);
|
|
33
31
|
},
|
|
34
|
-
usage: "dss business-app save-settings <id> (--data JSON|--data-file PATH|--stdin)",
|
|
35
32
|
description: "Save Business App settings (admin only; includes connection remapping).",
|
|
36
33
|
examples: ["dss business-app save-settings my-bapp --data-file settings.json",],
|
|
37
34
|
},
|
|
38
35
|
instances: {
|
|
39
36
|
handler: (c, a) => {
|
|
40
|
-
requireArgs(a, 1, "
|
|
37
|
+
requireArgs(a, 1, commandUsage("business-app", "instances"));
|
|
41
38
|
return c.applications.listBusinessAppInstances(a[0]);
|
|
42
39
|
},
|
|
43
|
-
usage: "dss business-app instances <id>",
|
|
44
40
|
description: "List instances of a Business App.",
|
|
45
41
|
examples: ["dss business-app instances my-bapp",],
|
|
46
42
|
},
|
|
47
43
|
"create-instance": {
|
|
48
44
|
handler: (c, a, f) => {
|
|
49
|
-
requireArgs(a, 1, "
|
|
45
|
+
requireArgs(a, 1, commandUsage("business-app", "create-instance"));
|
|
50
46
|
const body = requiredJsonInput(f, "--data, --data-file, or --stdin is required (instance payload).");
|
|
51
47
|
return c.applications.createBusinessAppInstance(a[0], body);
|
|
52
48
|
},
|
|
53
|
-
usage: "dss business-app create-instance <id> (--data JSON|--data-file PATH|--stdin)",
|
|
54
49
|
description: "Create an instance of a Business App.",
|
|
55
50
|
examples: ["dss business-app create-instance my-bapp --data '{}'",],
|
|
56
51
|
},
|
|
57
52
|
"upgrade-instance": {
|
|
58
53
|
handler: (c, a) => {
|
|
59
|
-
requireArgs(a, 2, "
|
|
54
|
+
requireArgs(a, 2, commandUsage("business-app", "upgrade-instance"));
|
|
60
55
|
return c.applications.upgradeBusinessAppInstance(a[0], a[1]);
|
|
61
56
|
},
|
|
62
|
-
usage: "dss business-app upgrade-instance <id> <projectKey>",
|
|
63
57
|
description: "Upgrade a Business App instance to the latest version.",
|
|
64
58
|
examples: ["dss business-app upgrade-instance my-bapp INSTANCEPROJ",],
|
|
65
59
|
},
|
|
66
60
|
"install-from-archive": {
|
|
67
61
|
handler: async (c, a) => {
|
|
68
|
-
requireArgs(a, 1, "
|
|
62
|
+
requireArgs(a, 1, commandUsage("business-app", "install-from-archive"));
|
|
69
63
|
await c.applications.installBusinessAppFromArchive(a[0]);
|
|
70
64
|
return { installed: true, };
|
|
71
65
|
},
|
|
72
|
-
usage: "dss business-app install-from-archive <filePath>",
|
|
73
66
|
description: "Install or upgrade a Business App from a zip archive (admin only).",
|
|
74
67
|
examples: ["dss business-app install-from-archive ./my-bapp.zip",],
|
|
75
68
|
},
|
|
76
|
-
};
|
|
69
|
+
});
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { readFileSync, writeFileSync, } from "node:fs";
|
|
2
2
|
import { ClientValidationError, } from "../../errors.js";
|
|
3
|
-
import { stableHash, } from "../../utils/stable-hash.js";
|
|
3
|
+
import { SHA256_HEX_PATTERN, stableHash, } from "../../utils/stable-hash.js";
|
|
4
4
|
import { json, jsonInput, num, numFlag, parseBooleanOption, } from "../coerce.js";
|
|
5
5
|
import { executionMode, } from "../flags.js";
|
|
6
6
|
import { enqueueCliWarning, isNotFoundError, readIfExists, skipResult, } from "../output.js";
|
|
7
|
+
import { commandUsage, withUsage, } from "../syntax.js";
|
|
7
8
|
import { requireArgs, UsageError, } from "../usage.js";
|
|
8
9
|
const CODE_ENV_LANGS = ["PYTHON", "R",];
|
|
9
10
|
/** Validate a positional `<lang>` argument: required, must be PYTHON or R. */
|
|
@@ -24,10 +25,10 @@ function definitionHashMismatch(envLang, envName, expected, current) {
|
|
|
24
25
|
function validateExpectHash(value) {
|
|
25
26
|
if (value === undefined || value === false)
|
|
26
27
|
return undefined;
|
|
27
|
-
if (typeof value !== "string" ||
|
|
28
|
+
if (typeof value !== "string" || !SHA256_HEX_PATTERN.test(value)) {
|
|
28
29
|
throw new ClientValidationError("Expected code env definition hash must be a 64-character SHA-256 hex digest.", "validation_failed", "Use the definitionHash value returned by dss code-env get.");
|
|
29
30
|
}
|
|
30
|
-
return value;
|
|
31
|
+
return value.toLowerCase();
|
|
31
32
|
}
|
|
32
33
|
function codeEnvWait(flags) {
|
|
33
34
|
return flags["no-wait"] !== true;
|
|
@@ -64,10 +65,10 @@ function codeEnvPackageList(flags) {
|
|
|
64
65
|
}
|
|
65
66
|
return packages;
|
|
66
67
|
}
|
|
67
|
-
export const codeEnvCommands = {
|
|
68
|
+
export const codeEnvCommands = withUsage("code-env", {
|
|
68
69
|
list: {
|
|
69
70
|
handler: (c, _a, f) => {
|
|
70
|
-
const usage = "
|
|
71
|
+
const usage = commandUsage("code-env", "list");
|
|
71
72
|
const lang = f["lang"];
|
|
72
73
|
return c.codeEnvs.list({
|
|
73
74
|
envLang: typeof lang === "string"
|
|
@@ -75,46 +76,42 @@ export const codeEnvCommands = {
|
|
|
75
76
|
: undefined,
|
|
76
77
|
});
|
|
77
78
|
},
|
|
78
|
-
usage: "dss code-env list [--lang PYTHON|R]",
|
|
79
79
|
description: "List code environments, optionally filtered to one language.",
|
|
80
80
|
examples: ["dss code-env list", "dss code-env list --lang PYTHON",],
|
|
81
81
|
},
|
|
82
82
|
get: {
|
|
83
83
|
handler: (c, a) => {
|
|
84
|
-
const usage = "
|
|
84
|
+
const usage = commandUsage("code-env", "get");
|
|
85
85
|
requireArgs(a, 2, usage);
|
|
86
86
|
const envLang = requireEnvLang(a[0], usage);
|
|
87
87
|
return c.codeEnvs.get(envLang, a[1]);
|
|
88
88
|
},
|
|
89
|
-
usage: "dss code-env get <lang> <name>",
|
|
90
89
|
description: "Get code environment details: requested vs installed packages, Python interpreter, deployment mode, and the stable definition hash (definitionHash) used by set-definition --expect-hash.",
|
|
91
90
|
examples: ["dss code-env get PYTHON my_env",],
|
|
92
91
|
},
|
|
93
92
|
"get-definition": {
|
|
94
93
|
handler: (c, a) => {
|
|
95
|
-
const usage = "
|
|
94
|
+
const usage = commandUsage("code-env", "get-definition");
|
|
96
95
|
requireArgs(a, 2, usage);
|
|
97
96
|
const envLang = requireEnvLang(a[0], usage);
|
|
98
97
|
return c.codeEnvs.getDefinition(envLang, a[1]);
|
|
99
98
|
},
|
|
100
|
-
usage: "dss code-env get-definition <lang> <name>",
|
|
101
99
|
description: "Get the raw code environment definition exactly as DSS stores it; capture its hash (definitionHash from code-env get) before replacing it with set-definition --expect-hash.",
|
|
102
100
|
examples: ["dss code-env get-definition PYTHON my_env",],
|
|
103
101
|
},
|
|
104
102
|
"list-logs": {
|
|
105
103
|
handler: (c, a) => {
|
|
106
|
-
const usage = "
|
|
104
|
+
const usage = commandUsage("code-env", "list-logs");
|
|
107
105
|
requireArgs(a, 2, usage);
|
|
108
106
|
const envLang = requireEnvLang(a[0], usage);
|
|
109
107
|
return c.codeEnvs.listLogs(envLang, a[1]);
|
|
110
108
|
},
|
|
111
|
-
usage: "dss code-env list-logs <lang> <name>",
|
|
112
109
|
description: "List the build log files DSS keeps for a code environment.",
|
|
113
110
|
examples: ["dss code-env list-logs PYTHON my_env",],
|
|
114
111
|
},
|
|
115
112
|
"get-log": {
|
|
116
113
|
handler: async (c, a, f) => {
|
|
117
|
-
const usage = "
|
|
114
|
+
const usage = commandUsage("code-env", "get-log");
|
|
118
115
|
requireArgs(a, 3, usage);
|
|
119
116
|
const envLang = requireEnvLang(a[0], usage);
|
|
120
117
|
const maxLines = numFlag(f, ["max-lines", "max-log-lines",]);
|
|
@@ -153,7 +150,6 @@ export const codeEnvCommands = {
|
|
|
153
150
|
}
|
|
154
151
|
return { ...result, envLang, envName: a[1], logName: a[2], };
|
|
155
152
|
},
|
|
156
|
-
usage: "dss code-env get-log <lang> <name> <logName> [--max-lines N|--max-log-lines N] [--max-log-bytes N] [--output PATH]",
|
|
157
153
|
description: "Fetch one code-env build log, bounded for safe output: the last --max-lines lines (default 500, 0 for all) and at most --max-log-bytes bytes (default 10 MiB, 0 for all). --output PATH writes the kept content to a file; stdout then carries the path metadata. A truncation warning names which cap hit.",
|
|
158
154
|
examples: [
|
|
159
155
|
"dss code-env get-log PYTHON my_env install.log --max-lines 200",
|
|
@@ -162,23 +158,22 @@ export const codeEnvCommands = {
|
|
|
162
158
|
},
|
|
163
159
|
version: {
|
|
164
160
|
handler: (c, a) => {
|
|
165
|
-
const usage = "
|
|
161
|
+
const usage = commandUsage("code-env", "version");
|
|
166
162
|
requireArgs(a, 3, usage);
|
|
167
163
|
const envLang = requireEnvLang(a[0], usage);
|
|
168
164
|
return c.codeEnvs.getVersionForProject(envLang, a[1], a[2]);
|
|
169
165
|
},
|
|
170
|
-
usage: "dss code-env version <lang> <name> <projectKey>",
|
|
171
166
|
description: "Resolve the code environment version a project uses (versioned automation environments); empty version for unversioned environments.",
|
|
172
167
|
examples: ["dss code-env version PYTHON my_env MY_PROJ",],
|
|
173
168
|
},
|
|
174
169
|
create: {
|
|
175
170
|
handler: async (c, a, f) => {
|
|
176
|
-
const usage = "
|
|
171
|
+
const usage = commandUsage("code-env", "create");
|
|
177
172
|
requireArgs(a, 2, usage);
|
|
178
173
|
const envLang = requireEnvLang(a[0], usage);
|
|
179
174
|
const deploymentMode = f["deployment-mode"];
|
|
180
175
|
if (!deploymentMode) {
|
|
181
|
-
throw new UsageError(
|
|
176
|
+
throw new UsageError(`--deployment-mode is required. Usage: ${commandUsage("code-env", "create")}`);
|
|
182
177
|
}
|
|
183
178
|
const params = codeEnvParams(f);
|
|
184
179
|
const wait = codeEnvWait(f);
|
|
@@ -213,7 +208,6 @@ export const codeEnvCommands = {
|
|
|
213
208
|
});
|
|
214
209
|
return { created: a[1], resource: "code-env", envLang, ...created, };
|
|
215
210
|
},
|
|
216
|
-
usage: "dss code-env create <lang> <name> --deployment-mode MODE [--params JSON|--data JSON|--data-file PATH|--stdin] [--python-interpreter PYTHON311] [--no-wait] [--if-not-exists] [--dry-run]",
|
|
217
211
|
description: "Create a code environment; --no-wait hands back a DSS future payload you can settle with dss future wait.",
|
|
218
212
|
examples: [
|
|
219
213
|
"dss code-env create PYTHON my_env --deployment-mode DESIGN_MANAGED --python-interpreter PYTHON311",
|
|
@@ -222,12 +216,12 @@ export const codeEnvCommands = {
|
|
|
222
216
|
},
|
|
223
217
|
"set-definition": {
|
|
224
218
|
handler: async (c, a, f) => {
|
|
225
|
-
const usage = "
|
|
219
|
+
const usage = commandUsage("code-env", "set-definition");
|
|
226
220
|
requireArgs(a, 2, usage);
|
|
227
221
|
const envLang = requireEnvLang(a[0], usage);
|
|
228
222
|
const definition = jsonInput(f);
|
|
229
223
|
if (!definition) {
|
|
230
|
-
throw new UsageError(
|
|
224
|
+
throw new UsageError(`--data, --data-file, or --stdin is required. Usage: ${commandUsage("code-env", "set-definition")}`);
|
|
231
225
|
}
|
|
232
226
|
const expectHash = validateExpectHash(f["expect-hash"]);
|
|
233
227
|
const definitionHash = stableHash(definition);
|
|
@@ -253,7 +247,6 @@ export const codeEnvCommands = {
|
|
|
253
247
|
}
|
|
254
248
|
return c.codeEnvs.setDefinition(envLang, a[1], definition, { expectHash, });
|
|
255
249
|
},
|
|
256
|
-
usage: "dss code-env set-definition <lang> <name> (--data JSON|--data-file PATH|--stdin) [--expect-hash SHA256] [--dry-run]",
|
|
257
250
|
description: "Replace a code environment definition previously fetched from DSS (get-definition). --expect-hash SHA256 refuses the PUT unless the current definition still hashes to the hash captured with code-env get, so concurrent edits are never clobbered; --dry-run also fetches the current definition and reports both hashes plus a changed flag.",
|
|
258
251
|
examples: [
|
|
259
252
|
"dss code-env set-definition PYTHON my_env --data-file code-env.json --expect-hash $HASH --dry-run",
|
|
@@ -261,7 +254,7 @@ export const codeEnvCommands = {
|
|
|
261
254
|
},
|
|
262
255
|
"set-packages": {
|
|
263
256
|
handler: async (c, a, f) => {
|
|
264
|
-
const usage = "
|
|
257
|
+
const usage = commandUsage("code-env", "set-packages");
|
|
265
258
|
requireArgs(a, 2, usage);
|
|
266
259
|
const envLang = requireEnvLang(a[0], usage);
|
|
267
260
|
const packages = codeEnvPackageList(f);
|
|
@@ -281,7 +274,6 @@ export const codeEnvCommands = {
|
|
|
281
274
|
}
|
|
282
275
|
return c.codeEnvs.setPackages(envLang, a[1], packages, { installCorePackages, expectHash, });
|
|
283
276
|
},
|
|
284
|
-
usage: "dss code-env set-packages <lang> <name> (--packages PKGS|--package PKG|--file PATH) [--install-core-packages true|false] [--expect-hash SHA256] [--dry-run]",
|
|
285
277
|
description: "Fetch the current definition, merge the requested package specs (and --install-core-packages) into it, then PUT the merged definition, so fields outside the package list are never dropped; --expect-hash refuses the merge when DSS changed since the hash was captured. The package list is replaced wholesale, so an explicitly empty --packages value or an empty --file clears the requested packages.",
|
|
286
278
|
examples: [
|
|
287
279
|
"dss code-env set-packages PYTHON my_env --packages 'tabulate\\nnameparser' --dry-run",
|
|
@@ -290,7 +282,7 @@ export const codeEnvCommands = {
|
|
|
290
282
|
},
|
|
291
283
|
"update-packages": {
|
|
292
284
|
handler: async (c, a, f) => {
|
|
293
|
-
const usage = "
|
|
285
|
+
const usage = commandUsage("code-env", "update-packages");
|
|
294
286
|
requireArgs(a, 2, usage);
|
|
295
287
|
const envLang = requireEnvLang(a[0], usage);
|
|
296
288
|
const wait = codeEnvWait(f);
|
|
@@ -316,13 +308,12 @@ export const codeEnvCommands = {
|
|
|
316
308
|
}
|
|
317
309
|
return c.codeEnvs.updatePackages(envLang, a[1], opts);
|
|
318
310
|
},
|
|
319
|
-
usage: "dss code-env update-packages <lang> <name> [--force-rebuild] [--env-version VERSION] [--no-wait] [--dry-run]",
|
|
320
311
|
description: "Rebuild or update code environment packages to match the requested specs; --no-wait hands back a DSS future payload you can settle with dss future wait.",
|
|
321
312
|
examples: ["dss code-env update-packages PYTHON my_env --force-rebuild --dry-run",],
|
|
322
313
|
},
|
|
323
314
|
"update-images": {
|
|
324
315
|
handler: async (c, a, f) => {
|
|
325
|
-
const usage = "
|
|
316
|
+
const usage = commandUsage("code-env", "update-images");
|
|
326
317
|
requireArgs(a, 2, usage);
|
|
327
318
|
const envLang = requireEnvLang(a[0], usage);
|
|
328
319
|
const wait = codeEnvWait(f);
|
|
@@ -340,7 +331,6 @@ export const codeEnvCommands = {
|
|
|
340
331
|
}
|
|
341
332
|
return c.codeEnvs.updateImages(envLang, a[1], { envVersion, wait, });
|
|
342
333
|
},
|
|
343
|
-
usage: "dss code-env update-images <lang> <name> [--env-version VERSION] [--no-wait] [--dry-run]",
|
|
344
334
|
description: "Rebuild the Docker image(s) of a code environment to match its settings; --env-version targets one version of a versioned environment and --no-wait hands back a DSS future payload you can settle with dss future wait.",
|
|
345
335
|
examples: [
|
|
346
336
|
"dss code-env update-images PYTHON my_env --dry-run",
|
|
@@ -349,12 +339,12 @@ export const codeEnvCommands = {
|
|
|
349
339
|
},
|
|
350
340
|
"set-jupyter": {
|
|
351
341
|
handler: async (c, a, f) => {
|
|
352
|
-
const usage = "
|
|
342
|
+
const usage = commandUsage("code-env", "set-jupyter");
|
|
353
343
|
requireArgs(a, 2, usage);
|
|
354
344
|
const envLang = requireEnvLang(a[0], usage);
|
|
355
345
|
const active = parseBooleanOption(f["active"], "--active");
|
|
356
346
|
if (active === undefined) {
|
|
357
|
-
throw new UsageError(
|
|
347
|
+
throw new UsageError(`--active is required. Usage: ${commandUsage("code-env", "set-jupyter")}`);
|
|
358
348
|
}
|
|
359
349
|
const wait = codeEnvWait(f);
|
|
360
350
|
if (executionMode(f).dryRun) {
|
|
@@ -370,13 +360,12 @@ export const codeEnvCommands = {
|
|
|
370
360
|
}
|
|
371
361
|
return c.codeEnvs.setJupyterSupport(envLang, a[1], active, { wait, });
|
|
372
362
|
},
|
|
373
|
-
usage: "dss code-env set-jupyter <lang> <name> --active true|false [--no-wait] [--dry-run]",
|
|
374
363
|
description: "Enable or disable Jupyter support for a code environment; --no-wait hands back a DSS future payload you can settle with dss future wait.",
|
|
375
364
|
examples: ["dss code-env set-jupyter PYTHON my_env --active true --dry-run",],
|
|
376
365
|
},
|
|
377
366
|
delete: {
|
|
378
367
|
handler: async (c, a, f) => {
|
|
379
|
-
const usage = "
|
|
368
|
+
const usage = commandUsage("code-env", "delete");
|
|
380
369
|
requireArgs(a, 2, usage);
|
|
381
370
|
const envLang = requireEnvLang(a[0], usage);
|
|
382
371
|
const wait = codeEnvWait(f);
|
|
@@ -404,7 +393,6 @@ export const codeEnvCommands = {
|
|
|
404
393
|
}
|
|
405
394
|
return c.codeEnvs.delete(envLang, a[1], { wait, });
|
|
406
395
|
},
|
|
407
|
-
usage: "dss code-env delete <lang> <name> [--no-wait] [--if-exists] [--dry-run]",
|
|
408
396
|
description: "Delete a code environment; --no-wait hands back a DSS future payload you can settle with dss future wait.",
|
|
409
397
|
examples: ["dss code-env delete PYTHON my_env --dry-run",],
|
|
410
398
|
},
|
|
@@ -414,10 +402,9 @@ export const codeEnvCommands = {
|
|
|
414
402
|
return c.codeEnvs.listUsages();
|
|
415
403
|
if (a.length === 2)
|
|
416
404
|
return c.codeEnvs.listUsages(a[0], a[1]);
|
|
417
|
-
throw new UsageError(
|
|
405
|
+
throw new UsageError(`Usage: ${commandUsage("code-env", "usages")}`);
|
|
418
406
|
},
|
|
419
|
-
usage: "dss code-env usages [<lang> <name>]",
|
|
420
407
|
description: "List code environment usages globally or for one environment.",
|
|
421
408
|
examples: ["dss code-env usages", "dss code-env usages PYTHON my_env",],
|
|
422
409
|
},
|
|
423
|
-
};
|
|
410
|
+
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { readFileSync, } from "node:fs";
|
|
2
|
-
import { ScenarioScriptRunWithCleanupFailureError, } from "../../resources/scenarios.js";
|
|
3
2
|
import { num, readStdinText, stripUtf8Bom, } from "../coerce.js";
|
|
4
3
|
import { enqueueCliWarning, } from "../output.js";
|
|
4
|
+
import { commandUsage, withUsage, } from "../syntax.js";
|
|
5
5
|
import { UsageError, } from "../usage.js";
|
|
6
|
-
const CODE_RUN_USAGE = "
|
|
6
|
+
const CODE_RUN_USAGE = commandUsage("code", "run");
|
|
7
7
|
function previewFlagValue(value) {
|
|
8
8
|
const text = typeof value === "string" ? value : String(value);
|
|
9
9
|
return text.length <= 32 ? text : `${text.slice(0, 32)}…`;
|
|
@@ -78,13 +78,14 @@ function reportCleanupFailure(cleanupFailure) {
|
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
function unwrapCodeRunError(error) {
|
|
81
|
+
const { ScenarioScriptRunWithCleanupFailureError, } = require("../../resources/scenarios.js");
|
|
81
82
|
if (error instanceof ScenarioScriptRunWithCleanupFailureError) {
|
|
82
83
|
reportCleanupFailure(error.cleanupFailure);
|
|
83
84
|
return error.cause;
|
|
84
85
|
}
|
|
85
86
|
return error;
|
|
86
87
|
}
|
|
87
|
-
export const codeCommands = {
|
|
88
|
+
export const codeCommands = withUsage("code", {
|
|
88
89
|
run: {
|
|
89
90
|
handler: async (c, a, f) => {
|
|
90
91
|
const timeoutMs = parseCodeRunIntegerFlag(f["timeout"], "--timeout");
|
|
@@ -123,7 +124,6 @@ export const codeCommands = {
|
|
|
123
124
|
}
|
|
124
125
|
return result;
|
|
125
126
|
},
|
|
126
|
-
usage: CODE_RUN_USAGE,
|
|
127
127
|
description: "Run Python through a throwaway custom-python scenario and return captured output plus outcome. --timeout caps waiting; --max-log-bytes caps logs; --full-log returns the capped raw log. Exits 4 unless outcome is SUCCESS.",
|
|
128
128
|
examples: [
|
|
129
129
|
"dss code run --file inspect.py",
|
|
@@ -132,4 +132,4 @@ export const codeCommands = {
|
|
|
132
132
|
"dss code run --file inspect.py --full-log",
|
|
133
133
|
],
|
|
134
134
|
},
|
|
135
|
-
};
|
|
135
|
+
});
|