dataiku-sdk 3.6.0 → 3.7.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 +14 -6
- package/bin/bun-version.js +14 -0
- package/bin/dss.js +23 -12
- package/dist/build-metadata.json +1 -1
- package/dist/packages/types/src/index.d.ts +74 -1
- package/dist/packages/types/src/index.js +53 -1
- package/dist/src/cli/coerce.d.ts +1 -0
- package/dist/src/cli/coerce.js +19 -15
- package/dist/src/cli/command-syntax.json +3521 -416
- package/dist/src/cli/commands/analysis.js +19 -1
- package/dist/src/cli/commands/bundle.js +22 -0
- package/dist/src/cli/commands/connection.js +26 -2
- package/dist/src/cli/commands/data-quality.js +33 -1
- package/dist/src/cli/commands/dataset.js +35 -4
- package/dist/src/cli/commands/discussion.js +15 -0
- package/dist/src/cli/commands/doctor.js +1 -1
- package/dist/src/cli/commands/flow.d.ts +5 -0
- package/dist/src/cli/commands/flow.js +57 -0
- package/dist/src/cli/commands/future.js +8 -0
- package/dist/src/cli/commands/index.js +6 -0
- package/dist/src/cli/commands/job.js +29 -6
- package/dist/src/cli/commands/metrics.js +21 -1
- package/dist/src/cli/commands/ml-task.d.ts +5 -0
- package/dist/src/cli/commands/ml-task.js +86 -16
- package/dist/src/cli/commands/mlflow.d.ts +11 -0
- package/dist/src/cli/commands/mlflow.js +121 -0
- package/dist/src/cli/commands/plugin.js +5 -11
- package/dist/src/cli/commands/project-deployer.js +70 -0
- package/dist/src/cli/commands/project-library.js +2 -5
- package/dist/src/cli/commands/project.js +8 -0
- package/dist/src/cli/commands/recipe.d.ts +9 -0
- package/dist/src/cli/commands/recipe.js +93 -7
- package/dist/src/cli/commands/saved-model.d.ts +1 -1
- package/dist/src/cli/commands/saved-model.js +9 -76
- package/dist/src/cli/commands/streaming-endpoint.js +30 -1
- package/dist/src/cli/commands/webapp.js +8 -0
- package/dist/src/cli/commands/wiki.js +22 -0
- package/dist/src/cli/commands/workspace.js +8 -0
- package/dist/src/cli/contract.d.ts +16 -15
- package/dist/src/cli/contract.js +139 -3404
- package/dist/src/cli/doctor.d.ts +13 -0
- package/dist/src/cli/doctor.js +41 -1
- package/dist/src/cli/flags.d.ts +7 -1
- package/dist/src/cli/flags.js +78 -6
- package/dist/src/cli/helpers/app-successor.js +1 -2
- package/dist/src/cli/helpers/documentation.d.ts +21 -0
- package/dist/src/cli/helpers/documentation.js +53 -0
- package/dist/src/cli/helpers/trained-model.d.ts +26 -0
- package/dist/src/cli/helpers/trained-model.js +144 -0
- package/dist/src/cli/list-output.d.ts +7 -0
- package/dist/src/cli/list-output.js +77 -0
- package/dist/src/cli/list-shapes.d.ts +21 -0
- package/dist/src/cli/list-shapes.js +111 -0
- package/dist/src/cli/output-schemas.d.ts +0 -14
- package/dist/src/cli/output-schemas.js +4 -7
- package/dist/src/cli/output.d.ts +0 -1
- package/dist/src/cli/output.js +27 -19
- package/dist/src/cli/plans.d.ts +14 -0
- package/dist/src/cli/plans.js +3684 -0
- package/dist/src/cli/usage.d.ts +7 -0
- package/dist/src/cli/usage.js +20 -1
- package/dist/src/cli/version.d.ts +2 -2
- package/dist/src/cli/version.js +2 -2
- package/dist/src/cli.js +127 -113
- package/dist/src/client.d.ts +52 -43
- package/dist/src/client.js +267 -96
- package/dist/src/errors.d.ts +11 -1
- package/dist/src/errors.js +31 -47
- package/dist/src/generated/action-output-schemas.json +345 -89
- package/dist/src/index.d.ts +5 -1
- package/dist/src/index.js +3 -0
- package/dist/src/resources/analyses.d.ts +8 -0
- package/dist/src/resources/analyses.js +13 -1
- package/dist/src/resources/bundles.d.ts +34 -0
- package/dist/src/resources/bundles.js +67 -0
- package/dist/src/resources/connections.d.ts +9 -0
- package/dist/src/resources/connections.js +15 -0
- package/dist/src/resources/data-quality.d.ts +20 -0
- package/dist/src/resources/data-quality.js +30 -0
- package/dist/src/resources/dataset-create.d.ts +19 -0
- package/dist/src/resources/dataset-create.js +66 -0
- package/dist/src/resources/datasets.d.ts +25 -15
- package/dist/src/resources/datasets.js +59 -111
- package/dist/src/resources/discussions.d.ts +5 -0
- package/dist/src/resources/discussions.js +7 -0
- package/dist/src/resources/documentation.d.ts +25 -0
- package/dist/src/resources/documentation.js +16 -0
- package/dist/src/resources/flow.d.ts +48 -0
- package/dist/src/resources/flow.js +65 -0
- package/dist/src/resources/futures.d.ts +23 -0
- package/dist/src/resources/futures.js +32 -0
- package/dist/src/resources/jobs.js +102 -2
- package/dist/src/resources/metrics.d.ts +10 -0
- package/dist/src/resources/metrics.js +10 -0
- package/dist/src/resources/ml-tasks.d.ts +65 -2
- package/dist/src/resources/ml-tasks.js +102 -28
- package/dist/src/resources/mlflow-extension.d.ts +73 -0
- package/dist/src/resources/mlflow-extension.js +105 -0
- package/dist/src/resources/projects.d.ts +6 -0
- package/dist/src/resources/projects.js +8 -0
- package/dist/src/resources/recipe-create.d.ts +65 -0
- package/dist/src/resources/recipe-create.js +338 -0
- package/dist/src/resources/recipes.d.ts +28 -29
- package/dist/src/resources/recipes.js +126 -245
- package/dist/src/resources/saved-models.d.ts +10 -6
- package/dist/src/resources/saved-models.js +16 -14
- package/dist/src/resources/scenarios.js +8 -14
- package/dist/src/resources/streaming-endpoints.d.ts +12 -0
- package/dist/src/resources/streaming-endpoints.js +15 -0
- package/dist/src/resources/trained-model.d.ts +60 -0
- package/dist/src/resources/trained-model.js +98 -0
- package/dist/src/resources/webapps.d.ts +8 -0
- package/dist/src/resources/webapps.js +10 -0
- package/dist/src/resources/wiki.d.ts +5 -0
- package/dist/src/resources/wiki.js +7 -0
- package/dist/src/resources/workspaces.d.ts +2 -0
- package/dist/src/resources/workspaces.js +4 -0
- package/dist/src/utils/response-file.js +20 -9
- package/dist/src/utils/secret-sanitize.d.ts +7 -0
- package/dist/src/utils/secret-sanitize.js +46 -0
- package/package.json +25 -26
- package/plugin.json +1 -1
- package/skills/dataiku-dss/SKILL.md +1 -1
- package/skills/dataiku-dss/references/authentication.md +3 -1
- package/skills/dataiku-dss/references/coding.md +1 -0
- package/skills/dataiku-dss/references/discovery.md +4 -6
- package/skills/dataiku-dss/references/troubleshooting.md +3 -2
|
@@ -16,6 +16,16 @@ export class MetricsResource extends BaseResource {
|
|
|
16
16
|
const pk = this.enc(projectKey);
|
|
17
17
|
return this.client.post(`${datasetPath(pk, datasetName)}/actions/computeMetrics?partition=`);
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Run the dataset's checks (POST /actions/runChecks/{?partitions}). Without
|
|
21
|
+
* `checks` DSS runs the checks configured on the dataset; with `checks` it
|
|
22
|
+
* runs those definitions instead (body `{"checks": [...]}`).
|
|
23
|
+
*/
|
|
24
|
+
async runDatasetChecks(datasetName, opts = {}) {
|
|
25
|
+
const pk = this.enc(opts.projectKey);
|
|
26
|
+
const query = opts.partitions ? `?partitions=${encodeURIComponent(opts.partitions)}` : "";
|
|
27
|
+
return this.client.post(`${datasetPath(pk, datasetName)}/actions/runChecks/${query}`, opts.checks ? { checks: opts.checks, } : undefined);
|
|
28
|
+
}
|
|
19
29
|
/** Get the last metric values for a managed folder. */
|
|
20
30
|
async getFolderMetrics(folderId, projectKey) {
|
|
21
31
|
const pk = this.enc(projectKey);
|
|
@@ -1,14 +1,41 @@
|
|
|
1
1
|
import { BaseResource } from "./base.js";
|
|
2
|
+
import { TrainedModel } from "./trained-model.js";
|
|
2
3
|
export type MlTaskType = "PREDICTION" | "CLUSTERING";
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
/** ML task definition; time series forecasting is PREDICTION with predictionType TIMESERIES_FORECAST. */
|
|
5
|
+
export interface MlTaskCreateFields {
|
|
5
6
|
taskType: MlTaskType;
|
|
6
7
|
targetVariable?: string;
|
|
7
8
|
predictionType?: string;
|
|
9
|
+
/** Forecasting tasks: the parsed-date time column. */
|
|
10
|
+
timeVariable?: string;
|
|
11
|
+
/** Forecasting tasks: columns identifying each series of a multi-series dataset. */
|
|
12
|
+
timeseriesIdentifiers?: string[];
|
|
8
13
|
backendType?: string;
|
|
9
14
|
guessPolicy?: string;
|
|
10
15
|
projectKey?: string;
|
|
11
16
|
}
|
|
17
|
+
export interface MlTaskCreateOptions extends MlTaskCreateFields {
|
|
18
|
+
analysisId: string;
|
|
19
|
+
}
|
|
20
|
+
export interface MlTaskCreateForDatasetOptions extends MlTaskCreateFields {
|
|
21
|
+
inputDataset: string;
|
|
22
|
+
}
|
|
23
|
+
export interface MlTaskListItem extends Record<string, unknown> {
|
|
24
|
+
analysisId?: string;
|
|
25
|
+
mlTaskId?: string;
|
|
26
|
+
analysisName?: string;
|
|
27
|
+
mlTaskName?: string;
|
|
28
|
+
taskType?: string;
|
|
29
|
+
inputDataset?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface MlTaskReguessOptions {
|
|
32
|
+
predictionType?: string;
|
|
33
|
+
targetVariable?: string;
|
|
34
|
+
timeVariable?: string;
|
|
35
|
+
timeseriesIdentifiers?: string[];
|
|
36
|
+
/** Re-guess every setting after the core change, not just the impacted ones. */
|
|
37
|
+
fullReguess?: boolean;
|
|
38
|
+
}
|
|
12
39
|
export interface MlTaskCreateResult extends Record<string, unknown> {
|
|
13
40
|
analysisId?: string;
|
|
14
41
|
mlTaskId?: string;
|
|
@@ -91,6 +118,14 @@ export interface MlTaskDeployResult extends Record<string, unknown> {
|
|
|
91
118
|
savedModelId?: string;
|
|
92
119
|
trainRecipeName?: string;
|
|
93
120
|
}
|
|
121
|
+
/** Query of POST .../guess; repeated `timeseriesIdentifiers` as dataikuapi sends a list (pure; shared with `--plan`). */
|
|
122
|
+
export declare function mlTaskReguessQuery(opts: MlTaskReguessOptions): URLSearchParams;
|
|
123
|
+
/**
|
|
124
|
+
* Task-creation body shared by `create` (existing analysis) and
|
|
125
|
+
* `createForDataset` (new analysis), with dataikuapi's defaults (pure; shared
|
|
126
|
+
* with `--plan`).
|
|
127
|
+
*/
|
|
128
|
+
export declare function mlTaskCreateBody(opts: MlTaskCreateFields): Record<string, unknown>;
|
|
94
129
|
export declare class MlTasksResource extends BaseResource {
|
|
95
130
|
/** Create a prediction or clustering task in an existing visual analysis. */
|
|
96
131
|
create(opts: MlTaskCreateOptions): Promise<MlTaskCreateResult>;
|
|
@@ -122,5 +157,33 @@ export declare class MlTasksResource extends BaseResource {
|
|
|
122
157
|
deployToFlow(opts: MlTaskDeployOptions): Promise<MlTaskDeployResult>;
|
|
123
158
|
/** Delete an ML task and its trained models. */
|
|
124
159
|
delete(analysisId: string, mlTaskId: string, projectKey?: string): Promise<void>;
|
|
160
|
+
/** Every ML task of the project, with its visual analysis (GET /models/lab/). */
|
|
161
|
+
list(projectKey?: string): Promise<MlTaskListItem[]>;
|
|
162
|
+
/**
|
|
163
|
+
* Create a new visual analysis on `inputDataset` with one ML task
|
|
164
|
+
* (POST /models/lab/). Returns `{analysisId, mlTaskId}`; DSS guesses the
|
|
165
|
+
* settings asynchronously (watch `status().guessing`).
|
|
166
|
+
*/
|
|
167
|
+
createForDataset(opts: MlTaskCreateForDatasetOptions): Promise<MlTaskCreateResult>;
|
|
168
|
+
/**
|
|
169
|
+
* Re-guess the task settings: all of them, or (prediction tasks) after
|
|
170
|
+
* setting a new prediction type, target, time variable, or series
|
|
171
|
+
* identifiers — only the impacted settings unless `fullReguess`.
|
|
172
|
+
*/
|
|
173
|
+
reguess(analysisId: string, mlTaskId: string, opts?: MlTaskReguessOptions, projectKey?: string): Promise<void>;
|
|
174
|
+
/**
|
|
175
|
+
* Time series forecasting tasks: change the forecasting parameters
|
|
176
|
+
* (`forecastHorizon`, `validationHorizons`, `timestepParams`,
|
|
177
|
+
* `updateAlgorithmSettings`) and re-guess the impacted algorithm settings.
|
|
178
|
+
*/
|
|
179
|
+
reguessForecasting(analysisId: string, mlTaskId: string, params: Record<string, unknown>, projectKey?: string): Promise<void>;
|
|
180
|
+
/**
|
|
181
|
+
* One trained lab model as a {@link TrainedModel}: diagnostics
|
|
182
|
+
* (subpopulation analyses, partial dependencies, timeseries residuals and
|
|
183
|
+
* per-series results), documentation, scoring exports, user metadata.
|
|
184
|
+
*/
|
|
185
|
+
model(analysisId: string, mlTaskId: string, modelId: string, projectKey?: string): TrainedModel;
|
|
186
|
+
/** GET a generated lab model documentation (docx) by the `exportId` of its finished future. */
|
|
187
|
+
downloadModelDocumentation(exportId: string, projectKey?: string): Promise<Response>;
|
|
125
188
|
private taskPath;
|
|
126
189
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ClientValidationError, } from "../errors.js";
|
|
2
2
|
import { computeNextPollDelayMs, isRequestDeadlineError, } from "../utils/polling.js";
|
|
3
|
-
import { BaseResource, requireNonEmpty, } from "./base.js";
|
|
3
|
+
import { BaseResource, requireArrayResponse, requireNonEmpty, requireObject, } from "./base.js";
|
|
4
|
+
import { TrainedModel, } from "./trained-model.js";
|
|
4
5
|
const TRAIN_POLL_INTERVAL_MS = 5_000;
|
|
5
6
|
const TRAIN_DEFAULT_TIMEOUT_MS = 120_000;
|
|
6
7
|
function delay(ms) {
|
|
@@ -18,37 +19,64 @@ function modelIdsFromStatus(status) {
|
|
|
18
19
|
}
|
|
19
20
|
return modelIds;
|
|
20
21
|
}
|
|
22
|
+
/** Query of POST .../guess; repeated `timeseriesIdentifiers` as dataikuapi sends a list (pure; shared with `--plan`). */
|
|
23
|
+
export function mlTaskReguessQuery(opts) {
|
|
24
|
+
const query = new URLSearchParams();
|
|
25
|
+
if (opts.predictionType !== undefined)
|
|
26
|
+
query.set("predictionType", opts.predictionType);
|
|
27
|
+
if (opts.targetVariable !== undefined)
|
|
28
|
+
query.set("targetVariable", opts.targetVariable);
|
|
29
|
+
if (opts.timeVariable !== undefined)
|
|
30
|
+
query.set("timeVariable", opts.timeVariable);
|
|
31
|
+
for (const id of opts.timeseriesIdentifiers ?? [])
|
|
32
|
+
query.append("timeseriesIdentifiers", id);
|
|
33
|
+
if (opts.fullReguess !== undefined)
|
|
34
|
+
query.set("fullReguess", String(opts.fullReguess));
|
|
35
|
+
return query;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Task-creation body shared by `create` (existing analysis) and
|
|
39
|
+
* `createForDataset` (new analysis), with dataikuapi's defaults (pure; shared
|
|
40
|
+
* with `--plan`).
|
|
41
|
+
*/
|
|
42
|
+
export function mlTaskCreateBody(opts) {
|
|
43
|
+
if (opts.taskType !== "PREDICTION" && opts.taskType !== "CLUSTERING") {
|
|
44
|
+
throw new ClientValidationError("taskType must be PREDICTION or CLUSTERING.", "invalid_enum");
|
|
45
|
+
}
|
|
46
|
+
if (opts.taskType === "PREDICTION"
|
|
47
|
+
&& (typeof opts.targetVariable !== "string" || opts.targetVariable.trim().length === 0)) {
|
|
48
|
+
throw new ClientValidationError("targetVariable is required for PREDICTION ML tasks.", "missing_required_arg");
|
|
49
|
+
}
|
|
50
|
+
const forecast = opts.predictionType === "TIMESERIES_FORECAST";
|
|
51
|
+
if (forecast && (typeof opts.timeVariable !== "string" || opts.timeVariable.trim().length === 0)) {
|
|
52
|
+
throw new ClientValidationError("timeVariable is required for TIMESERIES_FORECAST ML tasks.", "missing_required_arg");
|
|
53
|
+
}
|
|
54
|
+
const backendType = opts.backendType ?? "PY_MEMORY";
|
|
55
|
+
const guessPolicy = opts.guessPolicy
|
|
56
|
+
?? (opts.taskType === "CLUSTERING" ? "KMEANS" : forecast ? "TIMESERIES_DEFAULT" : "DEFAULT");
|
|
57
|
+
requireNonEmpty(backendType, "backendType");
|
|
58
|
+
requireNonEmpty(guessPolicy, "guessPolicy");
|
|
59
|
+
if (opts.targetVariable !== undefined)
|
|
60
|
+
requireNonEmpty(opts.targetVariable, "targetVariable");
|
|
61
|
+
if (opts.predictionType !== undefined)
|
|
62
|
+
requireNonEmpty(opts.predictionType, "predictionType");
|
|
63
|
+
return {
|
|
64
|
+
taskType: opts.taskType,
|
|
65
|
+
...(opts.targetVariable !== undefined ? { targetVariable: opts.targetVariable, } : {}),
|
|
66
|
+
...(opts.predictionType !== undefined ? { predictionType: opts.predictionType, } : {}),
|
|
67
|
+
...(opts.timeVariable !== undefined ? { timeVariable: opts.timeVariable, } : {}),
|
|
68
|
+
...(opts.timeseriesIdentifiers !== undefined
|
|
69
|
+
? { timeseriesIdentifiers: opts.timeseriesIdentifiers, }
|
|
70
|
+
: {}),
|
|
71
|
+
backendType,
|
|
72
|
+
guessPolicy,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
21
75
|
export class MlTasksResource extends BaseResource {
|
|
22
76
|
/** Create a prediction or clustering task in an existing visual analysis. */
|
|
23
77
|
async create(opts) {
|
|
24
|
-
if (opts.taskType !== "PREDICTION" && opts.taskType !== "CLUSTERING") {
|
|
25
|
-
throw new ClientValidationError("taskType must be PREDICTION or CLUSTERING.", "invalid_enum");
|
|
26
|
-
}
|
|
27
|
-
if (opts.taskType === "PREDICTION"
|
|
28
|
-
&& (typeof opts.targetVariable !== "string" || opts.targetVariable.trim().length === 0)) {
|
|
29
|
-
throw new ClientValidationError("targetVariable is required for PREDICTION ML tasks.", "missing_required_arg");
|
|
30
|
-
}
|
|
31
78
|
const analysisId = encodeURIComponent(requireNonEmpty(opts.analysisId, "analysisId"));
|
|
32
|
-
|
|
33
|
-
const guessPolicy = opts.guessPolicy
|
|
34
|
-
?? (opts.taskType === "CLUSTERING" ? "KMEANS" : "DEFAULT");
|
|
35
|
-
requireNonEmpty(backendType, "backendType");
|
|
36
|
-
requireNonEmpty(guessPolicy, "guessPolicy");
|
|
37
|
-
if (opts.targetVariable !== undefined)
|
|
38
|
-
requireNonEmpty(opts.targetVariable, "targetVariable");
|
|
39
|
-
if (opts.predictionType !== undefined)
|
|
40
|
-
requireNonEmpty(opts.predictionType, "predictionType");
|
|
41
|
-
return this.client.post(`/public/api/projects/${this.enc(opts.projectKey)}/lab/${analysisId}/models/`, {
|
|
42
|
-
taskType: opts.taskType,
|
|
43
|
-
...(opts.targetVariable !== undefined
|
|
44
|
-
? { targetVariable: opts.targetVariable, }
|
|
45
|
-
: {}),
|
|
46
|
-
...(opts.predictionType !== undefined
|
|
47
|
-
? { predictionType: opts.predictionType, }
|
|
48
|
-
: {}),
|
|
49
|
-
backendType,
|
|
50
|
-
guessPolicy,
|
|
51
|
-
});
|
|
79
|
+
return this.client.post(`/public/api/projects/${this.enc(opts.projectKey)}/lab/${analysisId}/models/`, mlTaskCreateBody(opts));
|
|
52
80
|
}
|
|
53
81
|
/** Get the current guessing, training, and trained-model status of a task. */
|
|
54
82
|
async status(analysisId, mlTaskId, projectKey) {
|
|
@@ -211,6 +239,52 @@ export class MlTasksResource extends BaseResource {
|
|
|
211
239
|
async delete(analysisId, mlTaskId, projectKey) {
|
|
212
240
|
await this.client.del(`${this.taskPath(analysisId, mlTaskId, projectKey)}/`);
|
|
213
241
|
}
|
|
242
|
+
/** Every ML task of the project, with its visual analysis (GET /models/lab/). */
|
|
243
|
+
async list(projectKey) {
|
|
244
|
+
const res = await this.client.get(`/public/api/projects/${this.enc(projectKey)}/models/lab/`);
|
|
245
|
+
return requireArrayResponse(res.mlTasks, "mlTasks.list");
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Create a new visual analysis on `inputDataset` with one ML task
|
|
249
|
+
* (POST /models/lab/). Returns `{analysisId, mlTaskId}`; DSS guesses the
|
|
250
|
+
* settings asynchronously (watch `status().guessing`).
|
|
251
|
+
*/
|
|
252
|
+
async createForDataset(opts) {
|
|
253
|
+
return this.client.post(`/public/api/projects/${this.enc(opts.projectKey)}/models/lab/`, {
|
|
254
|
+
inputDataset: requireNonEmpty(opts.inputDataset, "inputDataset"),
|
|
255
|
+
...mlTaskCreateBody(opts),
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Re-guess the task settings: all of them, or (prediction tasks) after
|
|
260
|
+
* setting a new prediction type, target, time variable, or series
|
|
261
|
+
* identifiers — only the impacted settings unless `fullReguess`.
|
|
262
|
+
*/
|
|
263
|
+
async reguess(analysisId, mlTaskId, opts = {}, projectKey) {
|
|
264
|
+
const query = mlTaskReguessQuery(opts);
|
|
265
|
+
await this.client.post(`${this.taskPath(analysisId, mlTaskId, projectKey)}/guess${query.size > 0 ? `?${query}` : ""}`);
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Time series forecasting tasks: change the forecasting parameters
|
|
269
|
+
* (`forecastHorizon`, `validationHorizons`, `timestepParams`,
|
|
270
|
+
* `updateAlgorithmSettings`) and re-guess the impacted algorithm settings.
|
|
271
|
+
*/
|
|
272
|
+
async reguessForecasting(analysisId, mlTaskId, params, projectKey) {
|
|
273
|
+
await this.client.post(`${this.taskPath(analysisId, mlTaskId, projectKey)}/reguess-with-forecasting-params`, requireObject(params, "params"));
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* One trained lab model as a {@link TrainedModel}: diagnostics
|
|
277
|
+
* (subpopulation analyses, partial dependencies, timeseries residuals and
|
|
278
|
+
* per-series results), documentation, scoring exports, user metadata.
|
|
279
|
+
*/
|
|
280
|
+
model(analysisId, mlTaskId, modelId, projectKey) {
|
|
281
|
+
const id = encodeURIComponent(requireNonEmpty(modelId, "modelId"));
|
|
282
|
+
return new TrainedModel(this.client, `${this.taskPath(analysisId, mlTaskId, projectKey)}/models/${id}`);
|
|
283
|
+
}
|
|
284
|
+
/** GET a generated lab model documentation (docx) by the `exportId` of its finished future. */
|
|
285
|
+
async downloadModelDocumentation(exportId, projectKey) {
|
|
286
|
+
return this.client.stream(`/public/api/projects/${this.enc(projectKey)}/models/lab/documentations/${encodeURIComponent(requireNonEmpty(exportId, "exportId"))}`);
|
|
287
|
+
}
|
|
214
288
|
taskPath(analysisId, mlTaskId, projectKey) {
|
|
215
289
|
const analysis = encodeURIComponent(requireNonEmpty(analysisId, "analysisId"));
|
|
216
290
|
const task = encodeURIComponent(requireNonEmpty(mlTaskId, "mlTaskId"));
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { BaseResource } from "./base.js";
|
|
2
|
+
export type MlflowPredictionType = "REGRESSION" | "BINARY_CLASSIFICATION" | "MULTICLASS" | "OTHER";
|
|
3
|
+
export interface MlflowInferenceInfo {
|
|
4
|
+
runId: string;
|
|
5
|
+
predictionType: MlflowPredictionType;
|
|
6
|
+
/** Ordered classes; required for and only allowed with classification types. */
|
|
7
|
+
classes?: string[];
|
|
8
|
+
codeEnvName?: string;
|
|
9
|
+
target?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface MlflowDeployRunOptions {
|
|
12
|
+
runId: string;
|
|
13
|
+
savedModelId: string;
|
|
14
|
+
/** Version id; DSS overwrites an existing one. Defaults to a timestamp, as in dataikuapi. */
|
|
15
|
+
versionId?: string;
|
|
16
|
+
/** Model name, needed when the run logged several models (see `listModels`). */
|
|
17
|
+
modelName?: string;
|
|
18
|
+
/** Evaluation dataset; without it the version is deployed but not evaluated. */
|
|
19
|
+
evaluationDataset?: string;
|
|
20
|
+
targetColumnName?: string;
|
|
21
|
+
classLabels?: string[];
|
|
22
|
+
codeEnvName?: string;
|
|
23
|
+
/** Use the run's inference info (`setRunInferenceInfo`); default true. */
|
|
24
|
+
useInferenceInfo?: boolean;
|
|
25
|
+
activate?: boolean;
|
|
26
|
+
binaryClassificationThreshold?: number;
|
|
27
|
+
useOptimalThreshold?: boolean;
|
|
28
|
+
skipExpensiveReports?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface MlflowExperimentsDatasetOptions {
|
|
31
|
+
datasetName: string;
|
|
32
|
+
experimentIds?: string[];
|
|
33
|
+
viewType?: "ACTIVE_ONLY" | "DELETED_ONLY" | "ALL";
|
|
34
|
+
/** MLflow search expression. */
|
|
35
|
+
filter?: string;
|
|
36
|
+
orderBy?: string[];
|
|
37
|
+
format?: "LONG" | "JSON";
|
|
38
|
+
}
|
|
39
|
+
/** Body of POST set-run-inference-info, validated as dataikuapi does. */
|
|
40
|
+
export declare function inferenceInfoBody(info: MlflowInferenceInfo): Record<string, string>;
|
|
41
|
+
/**
|
|
42
|
+
* Query of POST deploy-run, as dataikuapi `deploy_run_model` sends it. The
|
|
43
|
+
* version id must be resolved first (`deployRun` defaults it to a timestamp).
|
|
44
|
+
*/
|
|
45
|
+
export declare function deployRunQuery(opts: MlflowDeployRunOptions & {
|
|
46
|
+
versionId: string;
|
|
47
|
+
}, projectKey: string): URLSearchParams;
|
|
48
|
+
/** Body of POST create-project-experiments-dataset with the documented defaults. */
|
|
49
|
+
export declare function experimentsDatasetBody(opts: MlflowExperimentsDatasetOptions): Record<string, unknown>;
|
|
50
|
+
/**
|
|
51
|
+
* DSS MLflow extension endpoints (`/api/2.0/mlflow/extension/*`): models of a
|
|
52
|
+
* run, inference info, deploying a run as a saved-model version, the
|
|
53
|
+
* experiments virtual dataset, and cleanup. Every call except `cleanDb`
|
|
54
|
+
* carries the `x-dku-mlflow-project-key` header naming the tracking project.
|
|
55
|
+
*/
|
|
56
|
+
export declare class MlflowExtensionResource extends BaseResource {
|
|
57
|
+
private projectHeader;
|
|
58
|
+
/** Models logged by a run (`[{runId, artifactPath}]`). */
|
|
59
|
+
listModels(runId: string, projectKey?: string): Promise<Array<Record<string, unknown>>>;
|
|
60
|
+
/** Record a run's prediction type (and classes, code env, target) for deployment and evaluation. */
|
|
61
|
+
setRunInferenceInfo(info: MlflowInferenceInfo, projectKey?: string): Promise<void>;
|
|
62
|
+
/** Deploy a run's model as a version of an existing saved model. */
|
|
63
|
+
deployRun(opts: MlflowDeployRunOptions, projectKey?: string): Promise<{
|
|
64
|
+
savedModelId: string;
|
|
65
|
+
versionId: string;
|
|
66
|
+
}>;
|
|
67
|
+
/** Create a virtual dataset exposing the project's experiment tracking data. */
|
|
68
|
+
createExperimentsDataset(opts: MlflowExperimentsDatasetOptions, projectKey?: string): Promise<void>;
|
|
69
|
+
/** Permanently delete the project's experiments and runs marked as deleted. */
|
|
70
|
+
garbageCollect(projectKey?: string): Promise<void>;
|
|
71
|
+
/** Delete all experiment tracking data (experiments, runs, metrics, ...) of a project (admin). */
|
|
72
|
+
cleanDb(projectKey?: string): Promise<void>;
|
|
73
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { ClientValidationError, } from "../errors.js";
|
|
2
|
+
import { BaseResource, } from "./base.js";
|
|
3
|
+
/** DSS hosts its MLflow tracking API next to the public API (dataikuapi `/dip/publicapi/api/2.0/mlflow`). */
|
|
4
|
+
const MLFLOW_EXTENSION_PATH = "/public/api/api/2.0/mlflow/extension";
|
|
5
|
+
const PREDICTION_TYPES = {
|
|
6
|
+
REGRESSION: true,
|
|
7
|
+
BINARY_CLASSIFICATION: true,
|
|
8
|
+
MULTICLASS: true,
|
|
9
|
+
OTHER: true,
|
|
10
|
+
};
|
|
11
|
+
/** Body of POST set-run-inference-info, validated as dataikuapi does. */
|
|
12
|
+
export function inferenceInfoBody(info) {
|
|
13
|
+
if (PREDICTION_TYPES[info.predictionType] !== true) {
|
|
14
|
+
throw new ClientValidationError(`predictionType must be one of ${Object.keys(PREDICTION_TYPES).join(", ")}.`, "invalid_enum");
|
|
15
|
+
}
|
|
16
|
+
const classification = info.predictionType === "BINARY_CLASSIFICATION"
|
|
17
|
+
|| info.predictionType === "MULTICLASS";
|
|
18
|
+
if (classification !== (info.classes !== undefined && info.classes.length > 0)) {
|
|
19
|
+
throw new ClientValidationError("classes are required for BINARY_CLASSIFICATION and MULTICLASS, and only allowed for them.", "validation_failed");
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
run_id: info.runId,
|
|
23
|
+
prediction_type: info.predictionType,
|
|
24
|
+
...(info.classes ? { classes: JSON.stringify(info.classes), } : {}),
|
|
25
|
+
...(info.codeEnvName ? { code_env_name: info.codeEnvName, } : {}),
|
|
26
|
+
...(info.target ? { target: info.target, } : {}),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Query of POST deploy-run, as dataikuapi `deploy_run_model` sends it. The
|
|
31
|
+
* version id must be resolved first (`deployRun` defaults it to a timestamp).
|
|
32
|
+
*/
|
|
33
|
+
export function deployRunQuery(opts, projectKey) {
|
|
34
|
+
const modelVersionInfo = {
|
|
35
|
+
...(opts.evaluationDataset ? { gatherFeaturesFromDataset: opts.evaluationDataset, } : {}),
|
|
36
|
+
...(opts.targetColumnName ? { targetColumnName: opts.targetColumnName, } : {}),
|
|
37
|
+
classLabels: (opts.classLabels ?? []).map((label) => ({ label, })),
|
|
38
|
+
...(opts.codeEnvName ? { pythonCodeEnvName: opts.codeEnvName, } : {}),
|
|
39
|
+
};
|
|
40
|
+
const query = new URLSearchParams({
|
|
41
|
+
projectKey,
|
|
42
|
+
runId: opts.runId,
|
|
43
|
+
smId: opts.savedModelId,
|
|
44
|
+
versionId: opts.versionId,
|
|
45
|
+
modelVersionInfo: JSON.stringify(modelVersionInfo),
|
|
46
|
+
activate: String(opts.activate ?? true),
|
|
47
|
+
binaryClassificationThreshold: String(opts.binaryClassificationThreshold ?? 0.5),
|
|
48
|
+
useOptimalThreshold: String(opts.useOptimalThreshold ?? true),
|
|
49
|
+
skipExpensiveReports: String(opts.skipExpensiveReports ?? false),
|
|
50
|
+
useInferenceInfo: String(opts.useInferenceInfo ?? true),
|
|
51
|
+
});
|
|
52
|
+
if (opts.modelName)
|
|
53
|
+
query.set("modelName", opts.modelName);
|
|
54
|
+
return query;
|
|
55
|
+
}
|
|
56
|
+
/** Body of POST create-project-experiments-dataset with the documented defaults. */
|
|
57
|
+
export function experimentsDatasetBody(opts) {
|
|
58
|
+
return {
|
|
59
|
+
datasetName: opts.datasetName,
|
|
60
|
+
experimentIds: opts.experimentIds ?? [],
|
|
61
|
+
viewType: opts.viewType ?? "ACTIVE_ONLY",
|
|
62
|
+
filter: opts.filter ?? "",
|
|
63
|
+
orderBy: opts.orderBy ?? [],
|
|
64
|
+
format: opts.format ?? "LONG",
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* DSS MLflow extension endpoints (`/api/2.0/mlflow/extension/*`): models of a
|
|
69
|
+
* run, inference info, deploying a run as a saved-model version, the
|
|
70
|
+
* experiments virtual dataset, and cleanup. Every call except `cleanDb`
|
|
71
|
+
* carries the `x-dku-mlflow-project-key` header naming the tracking project.
|
|
72
|
+
*/
|
|
73
|
+
export class MlflowExtensionResource extends BaseResource {
|
|
74
|
+
projectHeader(projectKey) {
|
|
75
|
+
return { headers: { "x-dku-mlflow-project-key": this.resolveProjectKey(projectKey), }, };
|
|
76
|
+
}
|
|
77
|
+
/** Models logged by a run (`[{runId, artifactPath}]`). */
|
|
78
|
+
async listModels(runId, projectKey) {
|
|
79
|
+
return this.client.get(`${MLFLOW_EXTENSION_PATH}/models/${encodeURIComponent(runId)}`, this.projectHeader(projectKey));
|
|
80
|
+
}
|
|
81
|
+
/** Record a run's prediction type (and classes, code env, target) for deployment and evaluation. */
|
|
82
|
+
async setRunInferenceInfo(info, projectKey) {
|
|
83
|
+
await this.client.post(`${MLFLOW_EXTENSION_PATH}/set-run-inference-info`, inferenceInfoBody(info), this.projectHeader(projectKey));
|
|
84
|
+
}
|
|
85
|
+
/** Deploy a run's model as a version of an existing saved model. */
|
|
86
|
+
async deployRun(opts, projectKey) {
|
|
87
|
+
const pk = this.resolveProjectKey(projectKey);
|
|
88
|
+
// dataikuapi defaults to a %Y_%m_%dT%H_%M_%S timestamp; version ids allow no dashes.
|
|
89
|
+
const versionId = opts.versionId ?? new Date().toISOString().slice(0, 19).replace(/[-:]/g, "_");
|
|
90
|
+
await this.client.post(`${MLFLOW_EXTENSION_PATH}/deploy-run?${deployRunQuery({ ...opts, versionId, }, pk)}`, undefined, this.projectHeader(pk));
|
|
91
|
+
return { savedModelId: opts.savedModelId, versionId, };
|
|
92
|
+
}
|
|
93
|
+
/** Create a virtual dataset exposing the project's experiment tracking data. */
|
|
94
|
+
async createExperimentsDataset(opts, projectKey) {
|
|
95
|
+
await this.client.post(`${MLFLOW_EXTENSION_PATH}/create-project-experiments-dataset`, experimentsDatasetBody(opts), this.projectHeader(projectKey));
|
|
96
|
+
}
|
|
97
|
+
/** Permanently delete the project's experiments and runs marked as deleted. */
|
|
98
|
+
async garbageCollect(projectKey) {
|
|
99
|
+
await this.client.post(`${MLFLOW_EXTENSION_PATH}/garbage-collect`, undefined, this.projectHeader(projectKey));
|
|
100
|
+
}
|
|
101
|
+
/** Delete all experiment tracking data (experiments, runs, metrics, ...) of a project (admin). */
|
|
102
|
+
async cleanDb(projectKey) {
|
|
103
|
+
await this.client.del(`${MLFLOW_EXTENSION_PATH}/clean-db/${this.enc(projectKey)}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -132,6 +132,12 @@ export declare class ProjectsResource extends BaseResource {
|
|
|
132
132
|
* absent from the payload are removed from the project.
|
|
133
133
|
*/
|
|
134
134
|
setMetadata(projectKey: string | undefined, metadata: ProjectMetadata): Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* Push the project to a Git remote already declared in DSS (per-project Git
|
|
137
|
+
* mode): POST /actions/push-to-git-remote?remote=. The project-git family
|
|
138
|
+
* covers branches, commits, pulls, and remotes.
|
|
139
|
+
*/
|
|
140
|
+
pushToGitRemote(remote: string, projectKey?: string): Promise<void>;
|
|
135
141
|
/** Get project-level tags (tag name → {color?}). */
|
|
136
142
|
tags(projectKey?: string): Promise<ProjectTags>;
|
|
137
143
|
/**
|
|
@@ -311,6 +311,14 @@ export class ProjectsResource extends BaseResource {
|
|
|
311
311
|
async setMetadata(projectKey, metadata) {
|
|
312
312
|
await this.client.putVoid(`/public/api/projects/${this.enc(projectKey)}/metadata`, metadata);
|
|
313
313
|
}
|
|
314
|
+
/**
|
|
315
|
+
* Push the project to a Git remote already declared in DSS (per-project Git
|
|
316
|
+
* mode): POST /actions/push-to-git-remote?remote=. The project-git family
|
|
317
|
+
* covers branches, commits, pulls, and remotes.
|
|
318
|
+
*/
|
|
319
|
+
async pushToGitRemote(remote, projectKey) {
|
|
320
|
+
await this.client.post(`/public/api/projects/${this.enc(projectKey)}/actions/push-to-git-remote?remote=${encodeURIComponent(remote)}`);
|
|
321
|
+
}
|
|
314
322
|
/** Get project-level tags (tag name → {color?}). */
|
|
315
323
|
async tags(projectKey) {
|
|
316
324
|
const enc = this.enc(projectKey);
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { RecipeCreateOptions, RecipeSchemaUpdateComputable } from "../schemas.js";
|
|
2
|
+
export declare function asString(value: unknown): string | undefined;
|
|
3
|
+
export declare function asStringArray(value: unknown): string[] | undefined;
|
|
4
|
+
export type JoinType = "LEFT" | "INNER" | "RIGHT" | "FULL";
|
|
5
|
+
export type JoinKeyPair = {
|
|
6
|
+
left: string;
|
|
7
|
+
right: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function parseJoinKeyPairs(values: string[], optionName?: string): JoinKeyPair[];
|
|
10
|
+
export declare function normalizeFuzzyDistance(value: unknown): string;
|
|
11
|
+
export declare function normalizeJoinType(value: unknown): JoinType;
|
|
12
|
+
export declare function recipeInputItems(recipe: Record<string, unknown>): Array<{
|
|
13
|
+
ref: string;
|
|
14
|
+
role: string;
|
|
15
|
+
}>;
|
|
16
|
+
/** Whether DSS can compute this recipe type's output schema (visual and SQL query recipes). */
|
|
17
|
+
export declare function recipeOutputSchemaIsComputable(recipeType: string): boolean;
|
|
18
|
+
/** The id DSS expects in actions/updateOutputSchema (dataikuapi RequiredSchemaUpdates.apply). */
|
|
19
|
+
export declare function schemaUpdateComputableId(computable: RecipeSchemaUpdateComputable): string;
|
|
20
|
+
/** A computed schema is worth writing when it has columns and differs from (or fills) the current one. */
|
|
21
|
+
export declare function schemaUpdateIsPending(computable: RecipeSchemaUpdateComputable): boolean;
|
|
22
|
+
/** Grouping keys, aggregates per column (DSS flag names), and the first/last ordering column. */
|
|
23
|
+
export interface GroupingPayloadConfig {
|
|
24
|
+
keys: string[];
|
|
25
|
+
aggregates: Record<string, string[]>;
|
|
26
|
+
orderBy?: string;
|
|
27
|
+
}
|
|
28
|
+
/** Grouping configuration from create options, or undefined when none was asked for. */
|
|
29
|
+
export declare function groupingPayloadConfig(opts: RecipeCreateOptions): GroupingPayloadConfig | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Apply grouping keys and aggregates to the payload DSS created: `keys` lists
|
|
32
|
+
* the group columns; each aggregated column's `values[]` entry gets its
|
|
33
|
+
* aggregate flags (and `orderColumn` for first/last).
|
|
34
|
+
*/
|
|
35
|
+
export declare function applyGroupingPayload(payload: Record<string, unknown>, config: GroupingPayloadConfig): Record<string, unknown>;
|
|
36
|
+
/**
|
|
37
|
+
* Prepare (shaker) steps from create options, in a fixed order: rename,
|
|
38
|
+
* fill empty, formula column, row filter, drop columns, keep columns. Later
|
|
39
|
+
* steps see renamed columns. Empty when no prepare option was given.
|
|
40
|
+
*/
|
|
41
|
+
export declare function prepareSteps(opts: RecipeCreateOptions): Record<string, unknown>[];
|
|
42
|
+
/**
|
|
43
|
+
* Pure request construction for POST /recipes/ (no DSS calls). Shared with
|
|
44
|
+
* `recipe create --plan` so the plan equals the request the command sends.
|
|
45
|
+
*/
|
|
46
|
+
export declare function buildRecipeCreateRequest(opts: RecipeCreateOptions, pk: string): {
|
|
47
|
+
creationSettings: Record<string, unknown>;
|
|
48
|
+
fuzzyDistance: string | undefined;
|
|
49
|
+
fuzzyKeys: JoinKeyPair[] | undefined;
|
|
50
|
+
fuzzyThreshold: number;
|
|
51
|
+
grouping: GroupingPayloadConfig | undefined;
|
|
52
|
+
inputDatasets: string[] | undefined;
|
|
53
|
+
inputs: Record<string, unknown>;
|
|
54
|
+
joinKeys: JoinKeyPair[] | undefined;
|
|
55
|
+
name: string;
|
|
56
|
+
normalizedJoinType: JoinType | undefined;
|
|
57
|
+
outputFolder: string | undefined;
|
|
58
|
+
outputs: Record<string, unknown>;
|
|
59
|
+
payload: string | undefined;
|
|
60
|
+
prepareSteps: Record<string, unknown>[];
|
|
61
|
+
rawConnection: string | undefined;
|
|
62
|
+
recipePrototype: Record<string, unknown>;
|
|
63
|
+
temporaryOutputDataset: string | undefined;
|
|
64
|
+
type: string;
|
|
65
|
+
};
|