@databricks/sdk-modelregistry 0.1.0-dev.3 → 0.1.0-dev.4

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/src/v1/client.ts DELETED
@@ -1,1393 +0,0 @@
1
- // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
-
3
- import {VERSION as AUTH_VERSION} from '@databricks/sdk-auth';
4
- import {createDefault} from '@databricks/sdk-core/clientinfo';
5
- import type {Logger} from '@databricks/sdk-core/logger';
6
- import {NoOpLogger} from '@databricks/sdk-core/logger';
7
- import type {CallOptions} from '@databricks/sdk-options/call';
8
- import type {ClientOptions} from '@databricks/sdk-options/client';
9
- import type {HttpClient} from '@databricks/sdk-core/http';
10
- import {newHttpClient} from './transport';
11
- import {
12
- buildHttpRequest,
13
- executeCall,
14
- executeHttpCall,
15
- marshalRequest,
16
- parseResponse,
17
- } from './utils';
18
- import pkgJson from '../../package.json' with {type: 'json'};
19
- import type {
20
- ApproveTransitionRequest,
21
- ApproveTransitionResponse,
22
- CreateCommentRequest,
23
- CreateCommentResponse,
24
- CreateModelVersionRequest,
25
- CreateModelVersionResponse,
26
- CreateRegisteredModelRequest,
27
- CreateRegisteredModelResponse,
28
- CreateRegistryWebhookRequest,
29
- CreateRegistryWebhookResponse,
30
- CreateTransitionRequest,
31
- CreateTransitionResponse,
32
- DeleteCommentRequest,
33
- DeleteCommentResponse,
34
- DeleteModelVersionRequest,
35
- DeleteModelVersionResponse,
36
- DeleteModelVersionTagRequest,
37
- DeleteModelVersionTagResponse,
38
- DeleteRegisteredModelRequest,
39
- DeleteRegisteredModelResponse,
40
- DeleteRegisteredModelTagRequest,
41
- DeleteRegisteredModelTagResponse,
42
- DeleteRegistryWebhookRequest,
43
- DeleteRegistryWebhookResponse,
44
- DeleteTransitionRequest,
45
- DeleteTransitionResponse,
46
- GetLatestVersionsResponse,
47
- GetModelVersionDownloadUriRequest,
48
- GetModelVersionDownloadUriResponse,
49
- GetModelVersionRequest,
50
- GetModelVersionResponse,
51
- GetRegisteredModelDatabricksRequest,
52
- GetRegisteredModelDatabricksResponse,
53
- ListLatestVersionsRequest,
54
- ListRegisteredModelsRequest,
55
- ListRegisteredModelsResponse,
56
- ListRegistryWebhooksRequest,
57
- ListRegistryWebhooksResponse,
58
- ListTransitionRequest,
59
- ListTransitionResponse,
60
- ModelVersion,
61
- RegisteredModel,
62
- RegistryWebhook,
63
- RejectTransitionRequest,
64
- RejectTransitionResponse,
65
- RenameRegisteredModelRequest,
66
- RenameRegisteredModelResponse,
67
- SearchModelVersionsRequest,
68
- SearchModelVersionsResponse,
69
- SearchRegisteredModelsRequest,
70
- SearchRegisteredModelsResponse,
71
- SetModelVersionTagRequest,
72
- SetModelVersionTagResponse,
73
- SetRegisteredModelTagRequest,
74
- SetRegisteredModelTagResponse,
75
- TestRegistryWebhookRequest,
76
- TestRegistryWebhookResponse,
77
- TransitionModelVersionStageDatabricksRequest,
78
- TransitionModelVersionStageDatabricksResponse,
79
- UpdateCommentRequest,
80
- UpdateCommentResponse,
81
- UpdateModelVersionRequest,
82
- UpdateModelVersionResponse,
83
- UpdateRegisteredModelRequest,
84
- UpdateRegisteredModelResponse,
85
- UpdateRegistryWebhookRequest,
86
- UpdateRegistryWebhookResponse,
87
- } from './model';
88
- import {
89
- marshalApproveTransitionRequestSchema,
90
- marshalCreateCommentRequestSchema,
91
- marshalCreateModelVersionRequestSchema,
92
- marshalCreateRegisteredModelRequestSchema,
93
- marshalCreateRegistryWebhookRequestSchema,
94
- marshalCreateTransitionRequestSchema,
95
- marshalListLatestVersionsRequestSchema,
96
- marshalRejectTransitionRequestSchema,
97
- marshalRenameRegisteredModelRequestSchema,
98
- marshalSetModelVersionTagRequestSchema,
99
- marshalSetRegisteredModelTagRequestSchema,
100
- marshalTestRegistryWebhookRequestSchema,
101
- marshalTransitionModelVersionStageDatabricksRequestSchema,
102
- marshalUpdateCommentRequestSchema,
103
- marshalUpdateModelVersionRequestSchema,
104
- marshalUpdateRegisteredModelRequestSchema,
105
- marshalUpdateRegistryWebhookRequestSchema,
106
- unmarshalApproveTransitionResponseSchema,
107
- unmarshalCreateCommentResponseSchema,
108
- unmarshalCreateModelVersionResponseSchema,
109
- unmarshalCreateRegisteredModelResponseSchema,
110
- unmarshalCreateRegistryWebhookResponseSchema,
111
- unmarshalCreateTransitionResponseSchema,
112
- unmarshalDeleteCommentResponseSchema,
113
- unmarshalDeleteModelVersionResponseSchema,
114
- unmarshalDeleteModelVersionTagResponseSchema,
115
- unmarshalDeleteRegisteredModelResponseSchema,
116
- unmarshalDeleteRegisteredModelTagResponseSchema,
117
- unmarshalDeleteRegistryWebhookResponseSchema,
118
- unmarshalDeleteTransitionResponseSchema,
119
- unmarshalGetLatestVersionsResponseSchema,
120
- unmarshalGetModelVersionDownloadUriResponseSchema,
121
- unmarshalGetModelVersionResponseSchema,
122
- unmarshalGetRegisteredModelDatabricksResponseSchema,
123
- unmarshalListRegisteredModelsResponseSchema,
124
- unmarshalListRegistryWebhooksResponseSchema,
125
- unmarshalListTransitionResponseSchema,
126
- unmarshalRejectTransitionResponseSchema,
127
- unmarshalRenameRegisteredModelResponseSchema,
128
- unmarshalSearchModelVersionsResponseSchema,
129
- unmarshalSearchRegisteredModelsResponseSchema,
130
- unmarshalSetModelVersionTagResponseSchema,
131
- unmarshalSetRegisteredModelTagResponseSchema,
132
- unmarshalTestRegistryWebhookResponseSchema,
133
- unmarshalTransitionModelVersionStageDatabricksResponseSchema,
134
- unmarshalUpdateCommentResponseSchema,
135
- unmarshalUpdateModelVersionResponseSchema,
136
- unmarshalUpdateRegisteredModelResponseSchema,
137
- unmarshalUpdateRegistryWebhookResponseSchema,
138
- } from './model';
139
-
140
- // Package identity segment for this client to be used in the User-Agent header.
141
- const PACKAGE_SEGMENT = {
142
- key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
143
- value: pkgJson.version,
144
- };
145
-
146
- export class ModelRegistryClient {
147
- private readonly host: string;
148
- // Workspace ID used to route workspace-level calls on unified hosts (SPOG).
149
- // When set, workspace-level methods send X-Databricks-Org-Id on every
150
- // request.
151
- private readonly workspaceId: string | undefined;
152
- private readonly httpClient: HttpClient;
153
- private readonly logger: Logger;
154
- // User-Agent header value. Composed once at construction from
155
- // createDefault() merged with this package's identity and the active
156
- // credential's name.
157
- private readonly userAgent: string;
158
-
159
- constructor(options: ClientOptions) {
160
- if (options.host === undefined) {
161
- throw new Error('Host is required.');
162
- }
163
- this.host = options.host.replace(/\/$/, '');
164
- this.workspaceId = options.workspaceId;
165
- this.logger = options.logger ?? new NoOpLogger();
166
- const info = createDefault()
167
- .with(PACKAGE_SEGMENT)
168
- .with({key: 'sdk-js-auth', value: AUTH_VERSION})
169
- .with({key: 'auth', value: options.credentials?.name() ?? 'default'});
170
- this.userAgent = info.toString();
171
- this.httpClient = newHttpClient(options);
172
- }
173
-
174
- /** Approves a model version stage transition request. */
175
- async approveTransitionRequest(
176
- req: ApproveTransitionRequest,
177
- options?: CallOptions
178
- ): Promise<ApproveTransitionResponse> {
179
- const url = `${this.host}/api/2.0/mlflow/transition-requests/approve`;
180
- const body = marshalRequest(req, marshalApproveTransitionRequestSchema);
181
- let resp: ApproveTransitionResponse | undefined;
182
- const call = async (callSignal?: AbortSignal): Promise<void> => {
183
- const headers = new Headers({'Content-Type': 'application/json'});
184
- if (this.workspaceId !== undefined) {
185
- headers.set('X-Databricks-Org-Id', this.workspaceId);
186
- }
187
- headers.set('User-Agent', this.userAgent);
188
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
189
- const respBody = await executeHttpCall({
190
- request: httpReq,
191
- httpClient: this.httpClient,
192
- logger: this.logger,
193
- });
194
- resp = parseResponse(respBody, unmarshalApproveTransitionResponseSchema);
195
- };
196
- await executeCall(call, options);
197
- if (resp === undefined) {
198
- throw new Error('operation completed without a result.');
199
- }
200
- return resp;
201
- }
202
-
203
- /**
204
- * Posts a comment on a model version. A comment can be submitted either by a user or programmatically to display
205
- * relevant information about the model. For example, test results or deployment errors.
206
- */
207
- async createComment(
208
- req: CreateCommentRequest,
209
- options?: CallOptions
210
- ): Promise<CreateCommentResponse> {
211
- const url = `${this.host}/api/2.0/mlflow/comments/create`;
212
- const body = marshalRequest(req, marshalCreateCommentRequestSchema);
213
- let resp: CreateCommentResponse | undefined;
214
- const call = async (callSignal?: AbortSignal): Promise<void> => {
215
- const headers = new Headers({'Content-Type': 'application/json'});
216
- if (this.workspaceId !== undefined) {
217
- headers.set('X-Databricks-Org-Id', this.workspaceId);
218
- }
219
- headers.set('User-Agent', this.userAgent);
220
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
221
- const respBody = await executeHttpCall({
222
- request: httpReq,
223
- httpClient: this.httpClient,
224
- logger: this.logger,
225
- });
226
- resp = parseResponse(respBody, unmarshalCreateCommentResponseSchema);
227
- };
228
- await executeCall(call, options);
229
- if (resp === undefined) {
230
- throw new Error('operation completed without a result.');
231
- }
232
- return resp;
233
- }
234
-
235
- /**
236
- * **NOTE:** This endpoint is in Public Preview.
237
- * Creates a registry webhook.
238
- */
239
- async createRegistryWebhook(
240
- req: CreateRegistryWebhookRequest,
241
- options?: CallOptions
242
- ): Promise<CreateRegistryWebhookResponse> {
243
- const url = `${this.host}/api/2.0/mlflow/registry-webhooks/create`;
244
- const body = marshalRequest(req, marshalCreateRegistryWebhookRequestSchema);
245
- let resp: CreateRegistryWebhookResponse | undefined;
246
- const call = async (callSignal?: AbortSignal): Promise<void> => {
247
- const headers = new Headers({'Content-Type': 'application/json'});
248
- if (this.workspaceId !== undefined) {
249
- headers.set('X-Databricks-Org-Id', this.workspaceId);
250
- }
251
- headers.set('User-Agent', this.userAgent);
252
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
253
- const respBody = await executeHttpCall({
254
- request: httpReq,
255
- httpClient: this.httpClient,
256
- logger: this.logger,
257
- });
258
- resp = parseResponse(
259
- respBody,
260
- unmarshalCreateRegistryWebhookResponseSchema
261
- );
262
- };
263
- await executeCall(call, options);
264
- if (resp === undefined) {
265
- throw new Error('operation completed without a result.');
266
- }
267
- return resp;
268
- }
269
-
270
- /** Creates a model version stage transition request. */
271
- async createTransitionRequest(
272
- req: CreateTransitionRequest,
273
- options?: CallOptions
274
- ): Promise<CreateTransitionResponse> {
275
- const url = `${this.host}/api/2.0/mlflow/transition-requests/create`;
276
- const body = marshalRequest(req, marshalCreateTransitionRequestSchema);
277
- let resp: CreateTransitionResponse | undefined;
278
- const call = async (callSignal?: AbortSignal): Promise<void> => {
279
- const headers = new Headers({'Content-Type': 'application/json'});
280
- if (this.workspaceId !== undefined) {
281
- headers.set('X-Databricks-Org-Id', this.workspaceId);
282
- }
283
- headers.set('User-Agent', this.userAgent);
284
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
285
- const respBody = await executeHttpCall({
286
- request: httpReq,
287
- httpClient: this.httpClient,
288
- logger: this.logger,
289
- });
290
- resp = parseResponse(respBody, unmarshalCreateTransitionResponseSchema);
291
- };
292
- await executeCall(call, options);
293
- if (resp === undefined) {
294
- throw new Error('operation completed without a result.');
295
- }
296
- return resp;
297
- }
298
-
299
- /** Deletes a comment on a model version. */
300
- async deleteComment(
301
- req: DeleteCommentRequest,
302
- options?: CallOptions
303
- ): Promise<DeleteCommentResponse> {
304
- const url = `${this.host}/api/2.0/mlflow/comments/delete`;
305
- const params = new URLSearchParams();
306
- if (req.id !== undefined) {
307
- params.append('id', req.id);
308
- }
309
- const query = params.toString();
310
- const fullUrl = query !== '' ? `${url}?${query}` : url;
311
- let resp: DeleteCommentResponse | undefined;
312
- const call = async (callSignal?: AbortSignal): Promise<void> => {
313
- const headers = new Headers();
314
- if (this.workspaceId !== undefined) {
315
- headers.set('X-Databricks-Org-Id', this.workspaceId);
316
- }
317
- headers.set('User-Agent', this.userAgent);
318
- const httpReq = buildHttpRequest('DELETE', fullUrl, headers, callSignal);
319
- const respBody = await executeHttpCall({
320
- request: httpReq,
321
- httpClient: this.httpClient,
322
- logger: this.logger,
323
- });
324
- resp = parseResponse(respBody, unmarshalDeleteCommentResponseSchema);
325
- };
326
- await executeCall(call, options);
327
- if (resp === undefined) {
328
- throw new Error('operation completed without a result.');
329
- }
330
- return resp;
331
- }
332
-
333
- /**
334
- * **NOTE:** This endpoint is in Public Preview.
335
- * Deletes a registry webhook.
336
- */
337
- async deleteRegistryWebhook(
338
- req: DeleteRegistryWebhookRequest,
339
- options?: CallOptions
340
- ): Promise<DeleteRegistryWebhookResponse> {
341
- const url = `${this.host}/api/2.0/mlflow/registry-webhooks/delete`;
342
- const params = new URLSearchParams();
343
- if (req.id !== undefined) {
344
- params.append('id', req.id);
345
- }
346
- const query = params.toString();
347
- const fullUrl = query !== '' ? `${url}?${query}` : url;
348
- let resp: DeleteRegistryWebhookResponse | undefined;
349
- const call = async (callSignal?: AbortSignal): Promise<void> => {
350
- const headers = new Headers();
351
- if (this.workspaceId !== undefined) {
352
- headers.set('X-Databricks-Org-Id', this.workspaceId);
353
- }
354
- headers.set('User-Agent', this.userAgent);
355
- const httpReq = buildHttpRequest('DELETE', fullUrl, headers, callSignal);
356
- const respBody = await executeHttpCall({
357
- request: httpReq,
358
- httpClient: this.httpClient,
359
- logger: this.logger,
360
- });
361
- resp = parseResponse(
362
- respBody,
363
- unmarshalDeleteRegistryWebhookResponseSchema
364
- );
365
- };
366
- await executeCall(call, options);
367
- if (resp === undefined) {
368
- throw new Error('operation completed without a result.');
369
- }
370
- return resp;
371
- }
372
-
373
- /** Cancels a model version stage transition request. */
374
- async deleteTransitionRequest(
375
- req: DeleteTransitionRequest,
376
- options?: CallOptions
377
- ): Promise<DeleteTransitionResponse> {
378
- const url = `${this.host}/api/2.0/mlflow/transition-requests/delete`;
379
- const params = new URLSearchParams();
380
- if (req.name !== undefined) {
381
- params.append('name', req.name);
382
- }
383
- if (req.version !== undefined) {
384
- params.append('version', req.version);
385
- }
386
- if (req.stage !== undefined) {
387
- params.append('stage', req.stage);
388
- }
389
- if (req.creator !== undefined) {
390
- params.append('creator', req.creator);
391
- }
392
- if (req.comment !== undefined) {
393
- params.append('comment', req.comment);
394
- }
395
- const query = params.toString();
396
- const fullUrl = query !== '' ? `${url}?${query}` : url;
397
- let resp: DeleteTransitionResponse | undefined;
398
- const call = async (callSignal?: AbortSignal): Promise<void> => {
399
- const headers = new Headers();
400
- if (this.workspaceId !== undefined) {
401
- headers.set('X-Databricks-Org-Id', this.workspaceId);
402
- }
403
- headers.set('User-Agent', this.userAgent);
404
- const httpReq = buildHttpRequest('DELETE', fullUrl, headers, callSignal);
405
- const respBody = await executeHttpCall({
406
- request: httpReq,
407
- httpClient: this.httpClient,
408
- logger: this.logger,
409
- });
410
- resp = parseResponse(respBody, unmarshalDeleteTransitionResponseSchema);
411
- };
412
- await executeCall(call, options);
413
- if (resp === undefined) {
414
- throw new Error('operation completed without a result.');
415
- }
416
- return resp;
417
- }
418
-
419
- /**
420
- * Get the details of a model.
421
- * This is a <Databricks> workspace version of the [MLflow endpoint](https://www.mlflow.org/docs/latest/rest-api.html#get-registeredmodel)
422
- * that also returns the model's <Databricks> workspace ID and the permission level of the requesting user on the model.
423
- */
424
- async getRegisteredModelDatabricks(
425
- req: GetRegisteredModelDatabricksRequest,
426
- options?: CallOptions
427
- ): Promise<GetRegisteredModelDatabricksResponse> {
428
- const url = `${this.host}/api/2.0/mlflow/databricks/registered-models/get`;
429
- const params = new URLSearchParams();
430
- if (req.name !== undefined) {
431
- params.append('name', req.name);
432
- }
433
- const query = params.toString();
434
- const fullUrl = query !== '' ? `${url}?${query}` : url;
435
- let resp: GetRegisteredModelDatabricksResponse | undefined;
436
- const call = async (callSignal?: AbortSignal): Promise<void> => {
437
- const headers = new Headers();
438
- if (this.workspaceId !== undefined) {
439
- headers.set('X-Databricks-Org-Id', this.workspaceId);
440
- }
441
- headers.set('User-Agent', this.userAgent);
442
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
443
- const respBody = await executeHttpCall({
444
- request: httpReq,
445
- httpClient: this.httpClient,
446
- logger: this.logger,
447
- });
448
- resp = parseResponse(
449
- respBody,
450
- unmarshalGetRegisteredModelDatabricksResponseSchema
451
- );
452
- };
453
- await executeCall(call, options);
454
- if (resp === undefined) {
455
- throw new Error('operation completed without a result.');
456
- }
457
- return resp;
458
- }
459
-
460
- /**
461
- * **NOTE:** This endpoint is in Public Preview.
462
- * Lists all registry webhooks.
463
- */
464
- async listRegistryWebhooks(
465
- req: ListRegistryWebhooksRequest,
466
- options?: CallOptions
467
- ): Promise<ListRegistryWebhooksResponse> {
468
- const url = `${this.host}/api/2.0/mlflow/registry-webhooks/list`;
469
- const params = new URLSearchParams();
470
- if (req.modelName !== undefined) {
471
- params.append('model_name', req.modelName);
472
- }
473
- if (req.events !== undefined) {
474
- params.append('events', String(req.events));
475
- }
476
- if (req.pageToken !== undefined) {
477
- params.append('page_token', req.pageToken);
478
- }
479
- if (req.maxResults !== undefined) {
480
- params.append('max_results', String(req.maxResults));
481
- }
482
- const query = params.toString();
483
- const fullUrl = query !== '' ? `${url}?${query}` : url;
484
- let resp: ListRegistryWebhooksResponse | undefined;
485
- const call = async (callSignal?: AbortSignal): Promise<void> => {
486
- const headers = new Headers();
487
- if (this.workspaceId !== undefined) {
488
- headers.set('X-Databricks-Org-Id', this.workspaceId);
489
- }
490
- headers.set('User-Agent', this.userAgent);
491
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
492
- const respBody = await executeHttpCall({
493
- request: httpReq,
494
- httpClient: this.httpClient,
495
- logger: this.logger,
496
- });
497
- resp = parseResponse(
498
- respBody,
499
- unmarshalListRegistryWebhooksResponseSchema
500
- );
501
- };
502
- await executeCall(call, options);
503
- if (resp === undefined) {
504
- throw new Error('operation completed without a result.');
505
- }
506
- return resp;
507
- }
508
-
509
- async *listRegistryWebhooksIter(
510
- req: ListRegistryWebhooksRequest,
511
- options?: CallOptions
512
- ): AsyncGenerator<RegistryWebhook> {
513
- const pageReq: ListRegistryWebhooksRequest = {...req};
514
- for (;;) {
515
- const resp = await this.listRegistryWebhooks(pageReq, options);
516
- for (const item of resp.webhooks ?? []) {
517
- yield item;
518
- }
519
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
520
- return;
521
- }
522
- pageReq.pageToken = resp.nextPageToken;
523
- }
524
- }
525
-
526
- /** Gets a list of all open stage transition requests for the model version. */
527
- async listTransitionsRequest(
528
- req: ListTransitionRequest,
529
- options?: CallOptions
530
- ): Promise<ListTransitionResponse> {
531
- const url = `${this.host}/api/2.0/mlflow/transition-requests/list`;
532
- const params = new URLSearchParams();
533
- if (req.name !== undefined) {
534
- params.append('name', req.name);
535
- }
536
- if (req.version !== undefined) {
537
- params.append('version', req.version);
538
- }
539
- const query = params.toString();
540
- const fullUrl = query !== '' ? `${url}?${query}` : url;
541
- let resp: ListTransitionResponse | undefined;
542
- const call = async (callSignal?: AbortSignal): Promise<void> => {
543
- const headers = new Headers();
544
- if (this.workspaceId !== undefined) {
545
- headers.set('X-Databricks-Org-Id', this.workspaceId);
546
- }
547
- headers.set('User-Agent', this.userAgent);
548
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
549
- const respBody = await executeHttpCall({
550
- request: httpReq,
551
- httpClient: this.httpClient,
552
- logger: this.logger,
553
- });
554
- resp = parseResponse(respBody, unmarshalListTransitionResponseSchema);
555
- };
556
- await executeCall(call, options);
557
- if (resp === undefined) {
558
- throw new Error('operation completed without a result.');
559
- }
560
- return resp;
561
- }
562
-
563
- /** Rejects a model version stage transition request. */
564
- async rejectTransitionRequest(
565
- req: RejectTransitionRequest,
566
- options?: CallOptions
567
- ): Promise<RejectTransitionResponse> {
568
- const url = `${this.host}/api/2.0/mlflow/transition-requests/reject`;
569
- const body = marshalRequest(req, marshalRejectTransitionRequestSchema);
570
- let resp: RejectTransitionResponse | undefined;
571
- const call = async (callSignal?: AbortSignal): Promise<void> => {
572
- const headers = new Headers({'Content-Type': 'application/json'});
573
- if (this.workspaceId !== undefined) {
574
- headers.set('X-Databricks-Org-Id', this.workspaceId);
575
- }
576
- headers.set('User-Agent', this.userAgent);
577
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
578
- const respBody = await executeHttpCall({
579
- request: httpReq,
580
- httpClient: this.httpClient,
581
- logger: this.logger,
582
- });
583
- resp = parseResponse(respBody, unmarshalRejectTransitionResponseSchema);
584
- };
585
- await executeCall(call, options);
586
- if (resp === undefined) {
587
- throw new Error('operation completed without a result.');
588
- }
589
- return resp;
590
- }
591
-
592
- /**
593
- * **NOTE:** This endpoint is in Public Preview.
594
- * Tests a registry webhook.
595
- */
596
- async testRegistryWebhook(
597
- req: TestRegistryWebhookRequest,
598
- options?: CallOptions
599
- ): Promise<TestRegistryWebhookResponse> {
600
- const url = `${this.host}/api/2.0/mlflow/registry-webhooks/test`;
601
- const body = marshalRequest(req, marshalTestRegistryWebhookRequestSchema);
602
- let resp: TestRegistryWebhookResponse | undefined;
603
- const call = async (callSignal?: AbortSignal): Promise<void> => {
604
- const headers = new Headers({'Content-Type': 'application/json'});
605
- if (this.workspaceId !== undefined) {
606
- headers.set('X-Databricks-Org-Id', this.workspaceId);
607
- }
608
- headers.set('User-Agent', this.userAgent);
609
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
610
- const respBody = await executeHttpCall({
611
- request: httpReq,
612
- httpClient: this.httpClient,
613
- logger: this.logger,
614
- });
615
- resp = parseResponse(
616
- respBody,
617
- unmarshalTestRegistryWebhookResponseSchema
618
- );
619
- };
620
- await executeCall(call, options);
621
- if (resp === undefined) {
622
- throw new Error('operation completed without a result.');
623
- }
624
- return resp;
625
- }
626
-
627
- /**
628
- * Transition a model version's stage.
629
- * This is a <Databricks> workspace version of the [MLflow endpoint](https://www.mlflow.org/docs/latest/rest-api.html#transition-modelversion-stage)
630
- * that also accepts a comment associated with the transition to be recorded.
631
- */
632
- async transitionModelVersionStageDatabricks(
633
- req: TransitionModelVersionStageDatabricksRequest,
634
- options?: CallOptions
635
- ): Promise<TransitionModelVersionStageDatabricksResponse> {
636
- const url = `${this.host}/api/2.0/mlflow/databricks/model-versions/transition-stage`;
637
- const body = marshalRequest(
638
- req,
639
- marshalTransitionModelVersionStageDatabricksRequestSchema
640
- );
641
- let resp: TransitionModelVersionStageDatabricksResponse | undefined;
642
- const call = async (callSignal?: AbortSignal): Promise<void> => {
643
- const headers = new Headers({'Content-Type': 'application/json'});
644
- if (this.workspaceId !== undefined) {
645
- headers.set('X-Databricks-Org-Id', this.workspaceId);
646
- }
647
- headers.set('User-Agent', this.userAgent);
648
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
649
- const respBody = await executeHttpCall({
650
- request: httpReq,
651
- httpClient: this.httpClient,
652
- logger: this.logger,
653
- });
654
- resp = parseResponse(
655
- respBody,
656
- unmarshalTransitionModelVersionStageDatabricksResponseSchema
657
- );
658
- };
659
- await executeCall(call, options);
660
- if (resp === undefined) {
661
- throw new Error('operation completed without a result.');
662
- }
663
- return resp;
664
- }
665
-
666
- /** Post an edit to a comment on a model version. */
667
- async updateComment(
668
- req: UpdateCommentRequest,
669
- options?: CallOptions
670
- ): Promise<UpdateCommentResponse> {
671
- const url = `${this.host}/api/2.0/mlflow/comments/update`;
672
- const body = marshalRequest(req, marshalUpdateCommentRequestSchema);
673
- let resp: UpdateCommentResponse | undefined;
674
- const call = async (callSignal?: AbortSignal): Promise<void> => {
675
- const headers = new Headers({'Content-Type': 'application/json'});
676
- if (this.workspaceId !== undefined) {
677
- headers.set('X-Databricks-Org-Id', this.workspaceId);
678
- }
679
- headers.set('User-Agent', this.userAgent);
680
- const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
681
- const respBody = await executeHttpCall({
682
- request: httpReq,
683
- httpClient: this.httpClient,
684
- logger: this.logger,
685
- });
686
- resp = parseResponse(respBody, unmarshalUpdateCommentResponseSchema);
687
- };
688
- await executeCall(call, options);
689
- if (resp === undefined) {
690
- throw new Error('operation completed without a result.');
691
- }
692
- return resp;
693
- }
694
-
695
- /**
696
- * **NOTE:** This endpoint is in Public Preview.
697
- * Updates a registry webhook.
698
- */
699
- async updateRegistryWebhook(
700
- req: UpdateRegistryWebhookRequest,
701
- options?: CallOptions
702
- ): Promise<UpdateRegistryWebhookResponse> {
703
- const url = `${this.host}/api/2.0/mlflow/registry-webhooks/update`;
704
- const body = marshalRequest(req, marshalUpdateRegistryWebhookRequestSchema);
705
- let resp: UpdateRegistryWebhookResponse | undefined;
706
- const call = async (callSignal?: AbortSignal): Promise<void> => {
707
- const headers = new Headers({'Content-Type': 'application/json'});
708
- if (this.workspaceId !== undefined) {
709
- headers.set('X-Databricks-Org-Id', this.workspaceId);
710
- }
711
- headers.set('User-Agent', this.userAgent);
712
- const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
713
- const respBody = await executeHttpCall({
714
- request: httpReq,
715
- httpClient: this.httpClient,
716
- logger: this.logger,
717
- });
718
- resp = parseResponse(
719
- respBody,
720
- unmarshalUpdateRegistryWebhookResponseSchema
721
- );
722
- };
723
- await executeCall(call, options);
724
- if (resp === undefined) {
725
- throw new Error('operation completed without a result.');
726
- }
727
- return resp;
728
- }
729
-
730
- /** Creates a model version. */
731
- async createModelVersion(
732
- req: CreateModelVersionRequest,
733
- options?: CallOptions
734
- ): Promise<CreateModelVersionResponse> {
735
- const url = `${this.host}/api/2.0/mlflow/model-versions/create`;
736
- const body = marshalRequest(req, marshalCreateModelVersionRequestSchema);
737
- let resp: CreateModelVersionResponse | undefined;
738
- const call = async (callSignal?: AbortSignal): Promise<void> => {
739
- const headers = new Headers({'Content-Type': 'application/json'});
740
- if (this.workspaceId !== undefined) {
741
- headers.set('X-Databricks-Org-Id', this.workspaceId);
742
- }
743
- headers.set('User-Agent', this.userAgent);
744
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
745
- const respBody = await executeHttpCall({
746
- request: httpReq,
747
- httpClient: this.httpClient,
748
- logger: this.logger,
749
- });
750
- resp = parseResponse(respBody, unmarshalCreateModelVersionResponseSchema);
751
- };
752
- await executeCall(call, options);
753
- if (resp === undefined) {
754
- throw new Error('operation completed without a result.');
755
- }
756
- return resp;
757
- }
758
-
759
- /**
760
- * Creates a new registered model with the name specified in the request body.
761
- * Throws `RESOURCE_ALREADY_EXISTS` if a registered model with the given name exists.
762
- */
763
- async createRegisteredModel(
764
- req: CreateRegisteredModelRequest,
765
- options?: CallOptions
766
- ): Promise<CreateRegisteredModelResponse> {
767
- const url = `${this.host}/api/2.0/mlflow/registered-models/create`;
768
- const body = marshalRequest(req, marshalCreateRegisteredModelRequestSchema);
769
- let resp: CreateRegisteredModelResponse | undefined;
770
- const call = async (callSignal?: AbortSignal): Promise<void> => {
771
- const headers = new Headers({'Content-Type': 'application/json'});
772
- if (this.workspaceId !== undefined) {
773
- headers.set('X-Databricks-Org-Id', this.workspaceId);
774
- }
775
- headers.set('User-Agent', this.userAgent);
776
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
777
- const respBody = await executeHttpCall({
778
- request: httpReq,
779
- httpClient: this.httpClient,
780
- logger: this.logger,
781
- });
782
- resp = parseResponse(
783
- respBody,
784
- unmarshalCreateRegisteredModelResponseSchema
785
- );
786
- };
787
- await executeCall(call, options);
788
- if (resp === undefined) {
789
- throw new Error('operation completed without a result.');
790
- }
791
- return resp;
792
- }
793
-
794
- /** Deletes a model version. */
795
- async deleteModelVersion(
796
- req: DeleteModelVersionRequest,
797
- options?: CallOptions
798
- ): Promise<DeleteModelVersionResponse> {
799
- const url = `${this.host}/api/2.0/mlflow/model-versions/delete`;
800
- const params = new URLSearchParams();
801
- if (req.name !== undefined) {
802
- params.append('name', req.name);
803
- }
804
- if (req.version !== undefined) {
805
- params.append('version', req.version);
806
- }
807
- const query = params.toString();
808
- const fullUrl = query !== '' ? `${url}?${query}` : url;
809
- let resp: DeleteModelVersionResponse | undefined;
810
- const call = async (callSignal?: AbortSignal): Promise<void> => {
811
- const headers = new Headers();
812
- if (this.workspaceId !== undefined) {
813
- headers.set('X-Databricks-Org-Id', this.workspaceId);
814
- }
815
- headers.set('User-Agent', this.userAgent);
816
- const httpReq = buildHttpRequest('DELETE', fullUrl, headers, callSignal);
817
- const respBody = await executeHttpCall({
818
- request: httpReq,
819
- httpClient: this.httpClient,
820
- logger: this.logger,
821
- });
822
- resp = parseResponse(respBody, unmarshalDeleteModelVersionResponseSchema);
823
- };
824
- await executeCall(call, options);
825
- if (resp === undefined) {
826
- throw new Error('operation completed without a result.');
827
- }
828
- return resp;
829
- }
830
-
831
- /** Deletes a model version tag. */
832
- async deleteModelVersionTag(
833
- req: DeleteModelVersionTagRequest,
834
- options?: CallOptions
835
- ): Promise<DeleteModelVersionTagResponse> {
836
- const url = `${this.host}/api/2.0/mlflow/model-versions/delete-tag`;
837
- const params = new URLSearchParams();
838
- if (req.name !== undefined) {
839
- params.append('name', req.name);
840
- }
841
- if (req.version !== undefined) {
842
- params.append('version', req.version);
843
- }
844
- if (req.key !== undefined) {
845
- params.append('key', req.key);
846
- }
847
- const query = params.toString();
848
- const fullUrl = query !== '' ? `${url}?${query}` : url;
849
- let resp: DeleteModelVersionTagResponse | undefined;
850
- const call = async (callSignal?: AbortSignal): Promise<void> => {
851
- const headers = new Headers();
852
- if (this.workspaceId !== undefined) {
853
- headers.set('X-Databricks-Org-Id', this.workspaceId);
854
- }
855
- headers.set('User-Agent', this.userAgent);
856
- const httpReq = buildHttpRequest('DELETE', fullUrl, headers, callSignal);
857
- const respBody = await executeHttpCall({
858
- request: httpReq,
859
- httpClient: this.httpClient,
860
- logger: this.logger,
861
- });
862
- resp = parseResponse(
863
- respBody,
864
- unmarshalDeleteModelVersionTagResponseSchema
865
- );
866
- };
867
- await executeCall(call, options);
868
- if (resp === undefined) {
869
- throw new Error('operation completed without a result.');
870
- }
871
- return resp;
872
- }
873
-
874
- /** Deletes a registered model. */
875
- async deleteRegisteredModel(
876
- req: DeleteRegisteredModelRequest,
877
- options?: CallOptions
878
- ): Promise<DeleteRegisteredModelResponse> {
879
- const url = `${this.host}/api/2.0/mlflow/registered-models/delete`;
880
- const params = new URLSearchParams();
881
- if (req.name !== undefined) {
882
- params.append('name', req.name);
883
- }
884
- const query = params.toString();
885
- const fullUrl = query !== '' ? `${url}?${query}` : url;
886
- let resp: DeleteRegisteredModelResponse | undefined;
887
- const call = async (callSignal?: AbortSignal): Promise<void> => {
888
- const headers = new Headers();
889
- if (this.workspaceId !== undefined) {
890
- headers.set('X-Databricks-Org-Id', this.workspaceId);
891
- }
892
- headers.set('User-Agent', this.userAgent);
893
- const httpReq = buildHttpRequest('DELETE', fullUrl, headers, callSignal);
894
- const respBody = await executeHttpCall({
895
- request: httpReq,
896
- httpClient: this.httpClient,
897
- logger: this.logger,
898
- });
899
- resp = parseResponse(
900
- respBody,
901
- unmarshalDeleteRegisteredModelResponseSchema
902
- );
903
- };
904
- await executeCall(call, options);
905
- if (resp === undefined) {
906
- throw new Error('operation completed without a result.');
907
- }
908
- return resp;
909
- }
910
-
911
- /** Deletes the tag for a registered model. */
912
- async deleteRegisteredModelTag(
913
- req: DeleteRegisteredModelTagRequest,
914
- options?: CallOptions
915
- ): Promise<DeleteRegisteredModelTagResponse> {
916
- const url = `${this.host}/api/2.0/mlflow/registered-models/delete-tag`;
917
- const params = new URLSearchParams();
918
- if (req.name !== undefined) {
919
- params.append('name', req.name);
920
- }
921
- if (req.key !== undefined) {
922
- params.append('key', req.key);
923
- }
924
- const query = params.toString();
925
- const fullUrl = query !== '' ? `${url}?${query}` : url;
926
- let resp: DeleteRegisteredModelTagResponse | undefined;
927
- const call = async (callSignal?: AbortSignal): Promise<void> => {
928
- const headers = new Headers();
929
- if (this.workspaceId !== undefined) {
930
- headers.set('X-Databricks-Org-Id', this.workspaceId);
931
- }
932
- headers.set('User-Agent', this.userAgent);
933
- const httpReq = buildHttpRequest('DELETE', fullUrl, headers, callSignal);
934
- const respBody = await executeHttpCall({
935
- request: httpReq,
936
- httpClient: this.httpClient,
937
- logger: this.logger,
938
- });
939
- resp = parseResponse(
940
- respBody,
941
- unmarshalDeleteRegisteredModelTagResponseSchema
942
- );
943
- };
944
- await executeCall(call, options);
945
- if (resp === undefined) {
946
- throw new Error('operation completed without a result.');
947
- }
948
- return resp;
949
- }
950
-
951
- /** Get a model version. */
952
- async getModelVersion(
953
- req: GetModelVersionRequest,
954
- options?: CallOptions
955
- ): Promise<GetModelVersionResponse> {
956
- const url = `${this.host}/api/2.0/mlflow/model-versions/get`;
957
- const params = new URLSearchParams();
958
- if (req.name !== undefined) {
959
- params.append('name', req.name);
960
- }
961
- if (req.version !== undefined) {
962
- params.append('version', req.version);
963
- }
964
- const query = params.toString();
965
- const fullUrl = query !== '' ? `${url}?${query}` : url;
966
- let resp: GetModelVersionResponse | undefined;
967
- const call = async (callSignal?: AbortSignal): Promise<void> => {
968
- const headers = new Headers();
969
- if (this.workspaceId !== undefined) {
970
- headers.set('X-Databricks-Org-Id', this.workspaceId);
971
- }
972
- headers.set('User-Agent', this.userAgent);
973
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
974
- const respBody = await executeHttpCall({
975
- request: httpReq,
976
- httpClient: this.httpClient,
977
- logger: this.logger,
978
- });
979
- resp = parseResponse(respBody, unmarshalGetModelVersionResponseSchema);
980
- };
981
- await executeCall(call, options);
982
- if (resp === undefined) {
983
- throw new Error('operation completed without a result.');
984
- }
985
- return resp;
986
- }
987
-
988
- /** Gets a URI to download the model version. */
989
- async getModelVersionDownloadUri(
990
- req: GetModelVersionDownloadUriRequest,
991
- options?: CallOptions
992
- ): Promise<GetModelVersionDownloadUriResponse> {
993
- const url = `${this.host}/api/2.0/mlflow/model-versions/get-download-uri`;
994
- const params = new URLSearchParams();
995
- if (req.name !== undefined) {
996
- params.append('name', req.name);
997
- }
998
- if (req.version !== undefined) {
999
- params.append('version', req.version);
1000
- }
1001
- const query = params.toString();
1002
- const fullUrl = query !== '' ? `${url}?${query}` : url;
1003
- let resp: GetModelVersionDownloadUriResponse | undefined;
1004
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1005
- const headers = new Headers();
1006
- if (this.workspaceId !== undefined) {
1007
- headers.set('X-Databricks-Org-Id', this.workspaceId);
1008
- }
1009
- headers.set('User-Agent', this.userAgent);
1010
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
1011
- const respBody = await executeHttpCall({
1012
- request: httpReq,
1013
- httpClient: this.httpClient,
1014
- logger: this.logger,
1015
- });
1016
- resp = parseResponse(
1017
- respBody,
1018
- unmarshalGetModelVersionDownloadUriResponseSchema
1019
- );
1020
- };
1021
- await executeCall(call, options);
1022
- if (resp === undefined) {
1023
- throw new Error('operation completed without a result.');
1024
- }
1025
- return resp;
1026
- }
1027
-
1028
- /** Gets the latest version of a registered model. */
1029
- async listLatestVersions(
1030
- req: ListLatestVersionsRequest,
1031
- options?: CallOptions
1032
- ): Promise<GetLatestVersionsResponse> {
1033
- const url = `${this.host}/api/2.0/mlflow/registered-models/get-latest-versions`;
1034
- const body = marshalRequest(req, marshalListLatestVersionsRequestSchema);
1035
- let resp: GetLatestVersionsResponse | undefined;
1036
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1037
- const headers = new Headers({'Content-Type': 'application/json'});
1038
- if (this.workspaceId !== undefined) {
1039
- headers.set('X-Databricks-Org-Id', this.workspaceId);
1040
- }
1041
- headers.set('User-Agent', this.userAgent);
1042
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
1043
- const respBody = await executeHttpCall({
1044
- request: httpReq,
1045
- httpClient: this.httpClient,
1046
- logger: this.logger,
1047
- });
1048
- resp = parseResponse(respBody, unmarshalGetLatestVersionsResponseSchema);
1049
- };
1050
- await executeCall(call, options);
1051
- if (resp === undefined) {
1052
- throw new Error('operation completed without a result.');
1053
- }
1054
- return resp;
1055
- }
1056
-
1057
- /** Lists all available registered models, up to the limit specified in __max_results__. */
1058
- async listRegisteredModels(
1059
- req: ListRegisteredModelsRequest,
1060
- options?: CallOptions
1061
- ): Promise<ListRegisteredModelsResponse> {
1062
- const url = `${this.host}/api/2.0/mlflow/registered-models/list`;
1063
- const params = new URLSearchParams();
1064
- if (req.maxResults !== undefined) {
1065
- params.append('max_results', String(req.maxResults));
1066
- }
1067
- if (req.pageToken !== undefined) {
1068
- params.append('page_token', req.pageToken);
1069
- }
1070
- const query = params.toString();
1071
- const fullUrl = query !== '' ? `${url}?${query}` : url;
1072
- let resp: ListRegisteredModelsResponse | undefined;
1073
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1074
- const headers = new Headers();
1075
- if (this.workspaceId !== undefined) {
1076
- headers.set('X-Databricks-Org-Id', this.workspaceId);
1077
- }
1078
- headers.set('User-Agent', this.userAgent);
1079
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
1080
- const respBody = await executeHttpCall({
1081
- request: httpReq,
1082
- httpClient: this.httpClient,
1083
- logger: this.logger,
1084
- });
1085
- resp = parseResponse(
1086
- respBody,
1087
- unmarshalListRegisteredModelsResponseSchema
1088
- );
1089
- };
1090
- await executeCall(call, options);
1091
- if (resp === undefined) {
1092
- throw new Error('operation completed without a result.');
1093
- }
1094
- return resp;
1095
- }
1096
-
1097
- async *listRegisteredModelsIter(
1098
- req: ListRegisteredModelsRequest,
1099
- options?: CallOptions
1100
- ): AsyncGenerator<RegisteredModel> {
1101
- const pageReq: ListRegisteredModelsRequest = {...req};
1102
- for (;;) {
1103
- const resp = await this.listRegisteredModels(pageReq, options);
1104
- for (const item of resp.registeredModels ?? []) {
1105
- yield item;
1106
- }
1107
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
1108
- return;
1109
- }
1110
- pageReq.pageToken = resp.nextPageToken;
1111
- }
1112
- }
1113
-
1114
- /** Renames a registered model. */
1115
- async renameRegisteredModel(
1116
- req: RenameRegisteredModelRequest,
1117
- options?: CallOptions
1118
- ): Promise<RenameRegisteredModelResponse> {
1119
- const url = `${this.host}/api/2.0/mlflow/registered-models/rename`;
1120
- const body = marshalRequest(req, marshalRenameRegisteredModelRequestSchema);
1121
- let resp: RenameRegisteredModelResponse | undefined;
1122
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1123
- const headers = new Headers({'Content-Type': 'application/json'});
1124
- if (this.workspaceId !== undefined) {
1125
- headers.set('X-Databricks-Org-Id', this.workspaceId);
1126
- }
1127
- headers.set('User-Agent', this.userAgent);
1128
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
1129
- const respBody = await executeHttpCall({
1130
- request: httpReq,
1131
- httpClient: this.httpClient,
1132
- logger: this.logger,
1133
- });
1134
- resp = parseResponse(
1135
- respBody,
1136
- unmarshalRenameRegisteredModelResponseSchema
1137
- );
1138
- };
1139
- await executeCall(call, options);
1140
- if (resp === undefined) {
1141
- throw new Error('operation completed without a result.');
1142
- }
1143
- return resp;
1144
- }
1145
-
1146
- /** Searches for specific model versions based on the supplied __filter__. */
1147
- async searchModelVersions(
1148
- req: SearchModelVersionsRequest,
1149
- options?: CallOptions
1150
- ): Promise<SearchModelVersionsResponse> {
1151
- const url = `${this.host}/api/2.0/mlflow/model-versions/search`;
1152
- const params = new URLSearchParams();
1153
- if (req.filter !== undefined) {
1154
- params.append('filter', req.filter);
1155
- }
1156
- if (req.maxResults !== undefined) {
1157
- params.append('max_results', String(req.maxResults));
1158
- }
1159
- if (req.orderBy !== undefined) {
1160
- params.append('order_by', String(req.orderBy));
1161
- }
1162
- if (req.pageToken !== undefined) {
1163
- params.append('page_token', req.pageToken);
1164
- }
1165
- const query = params.toString();
1166
- const fullUrl = query !== '' ? `${url}?${query}` : url;
1167
- let resp: SearchModelVersionsResponse | undefined;
1168
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1169
- const headers = new Headers();
1170
- if (this.workspaceId !== undefined) {
1171
- headers.set('X-Databricks-Org-Id', this.workspaceId);
1172
- }
1173
- headers.set('User-Agent', this.userAgent);
1174
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
1175
- const respBody = await executeHttpCall({
1176
- request: httpReq,
1177
- httpClient: this.httpClient,
1178
- logger: this.logger,
1179
- });
1180
- resp = parseResponse(
1181
- respBody,
1182
- unmarshalSearchModelVersionsResponseSchema
1183
- );
1184
- };
1185
- await executeCall(call, options);
1186
- if (resp === undefined) {
1187
- throw new Error('operation completed without a result.');
1188
- }
1189
- return resp;
1190
- }
1191
-
1192
- async *searchModelVersionsIter(
1193
- req: SearchModelVersionsRequest,
1194
- options?: CallOptions
1195
- ): AsyncGenerator<ModelVersion> {
1196
- const pageReq: SearchModelVersionsRequest = {...req};
1197
- for (;;) {
1198
- const resp = await this.searchModelVersions(pageReq, options);
1199
- for (const item of resp.modelVersions ?? []) {
1200
- yield item;
1201
- }
1202
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
1203
- return;
1204
- }
1205
- pageReq.pageToken = resp.nextPageToken;
1206
- }
1207
- }
1208
-
1209
- /** Search for registered models based on the specified __filter__. */
1210
- async searchRegisteredModels(
1211
- req: SearchRegisteredModelsRequest,
1212
- options?: CallOptions
1213
- ): Promise<SearchRegisteredModelsResponse> {
1214
- const url = `${this.host}/api/2.0/mlflow/registered-models/search`;
1215
- const params = new URLSearchParams();
1216
- if (req.filter !== undefined) {
1217
- params.append('filter', req.filter);
1218
- }
1219
- if (req.maxResults !== undefined) {
1220
- params.append('max_results', String(req.maxResults));
1221
- }
1222
- if (req.orderBy !== undefined) {
1223
- params.append('order_by', String(req.orderBy));
1224
- }
1225
- if (req.pageToken !== undefined) {
1226
- params.append('page_token', req.pageToken);
1227
- }
1228
- const query = params.toString();
1229
- const fullUrl = query !== '' ? `${url}?${query}` : url;
1230
- let resp: SearchRegisteredModelsResponse | undefined;
1231
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1232
- const headers = new Headers();
1233
- if (this.workspaceId !== undefined) {
1234
- headers.set('X-Databricks-Org-Id', this.workspaceId);
1235
- }
1236
- headers.set('User-Agent', this.userAgent);
1237
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
1238
- const respBody = await executeHttpCall({
1239
- request: httpReq,
1240
- httpClient: this.httpClient,
1241
- logger: this.logger,
1242
- });
1243
- resp = parseResponse(
1244
- respBody,
1245
- unmarshalSearchRegisteredModelsResponseSchema
1246
- );
1247
- };
1248
- await executeCall(call, options);
1249
- if (resp === undefined) {
1250
- throw new Error('operation completed without a result.');
1251
- }
1252
- return resp;
1253
- }
1254
-
1255
- async *searchRegisteredModelsIter(
1256
- req: SearchRegisteredModelsRequest,
1257
- options?: CallOptions
1258
- ): AsyncGenerator<RegisteredModel> {
1259
- const pageReq: SearchRegisteredModelsRequest = {...req};
1260
- for (;;) {
1261
- const resp = await this.searchRegisteredModels(pageReq, options);
1262
- for (const item of resp.registeredModels ?? []) {
1263
- yield item;
1264
- }
1265
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
1266
- return;
1267
- }
1268
- pageReq.pageToken = resp.nextPageToken;
1269
- }
1270
- }
1271
-
1272
- /** Sets a model version tag. */
1273
- async setModelVersionTag(
1274
- req: SetModelVersionTagRequest,
1275
- options?: CallOptions
1276
- ): Promise<SetModelVersionTagResponse> {
1277
- const url = `${this.host}/api/2.0/mlflow/model-versions/set-tag`;
1278
- const body = marshalRequest(req, marshalSetModelVersionTagRequestSchema);
1279
- let resp: SetModelVersionTagResponse | undefined;
1280
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1281
- const headers = new Headers({'Content-Type': 'application/json'});
1282
- if (this.workspaceId !== undefined) {
1283
- headers.set('X-Databricks-Org-Id', this.workspaceId);
1284
- }
1285
- headers.set('User-Agent', this.userAgent);
1286
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
1287
- const respBody = await executeHttpCall({
1288
- request: httpReq,
1289
- httpClient: this.httpClient,
1290
- logger: this.logger,
1291
- });
1292
- resp = parseResponse(respBody, unmarshalSetModelVersionTagResponseSchema);
1293
- };
1294
- await executeCall(call, options);
1295
- if (resp === undefined) {
1296
- throw new Error('operation completed without a result.');
1297
- }
1298
- return resp;
1299
- }
1300
-
1301
- /** Sets a tag on a registered model. */
1302
- async setRegisteredModelTag(
1303
- req: SetRegisteredModelTagRequest,
1304
- options?: CallOptions
1305
- ): Promise<SetRegisteredModelTagResponse> {
1306
- const url = `${this.host}/api/2.0/mlflow/registered-models/set-tag`;
1307
- const body = marshalRequest(req, marshalSetRegisteredModelTagRequestSchema);
1308
- let resp: SetRegisteredModelTagResponse | undefined;
1309
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1310
- const headers = new Headers({'Content-Type': 'application/json'});
1311
- if (this.workspaceId !== undefined) {
1312
- headers.set('X-Databricks-Org-Id', this.workspaceId);
1313
- }
1314
- headers.set('User-Agent', this.userAgent);
1315
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
1316
- const respBody = await executeHttpCall({
1317
- request: httpReq,
1318
- httpClient: this.httpClient,
1319
- logger: this.logger,
1320
- });
1321
- resp = parseResponse(
1322
- respBody,
1323
- unmarshalSetRegisteredModelTagResponseSchema
1324
- );
1325
- };
1326
- await executeCall(call, options);
1327
- if (resp === undefined) {
1328
- throw new Error('operation completed without a result.');
1329
- }
1330
- return resp;
1331
- }
1332
-
1333
- /** Updates the model version. */
1334
- async updateModelVersion(
1335
- req: UpdateModelVersionRequest,
1336
- options?: CallOptions
1337
- ): Promise<UpdateModelVersionResponse> {
1338
- const url = `${this.host}/api/2.0/mlflow/model-versions/update`;
1339
- const body = marshalRequest(req, marshalUpdateModelVersionRequestSchema);
1340
- let resp: UpdateModelVersionResponse | undefined;
1341
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1342
- const headers = new Headers({'Content-Type': 'application/json'});
1343
- if (this.workspaceId !== undefined) {
1344
- headers.set('X-Databricks-Org-Id', this.workspaceId);
1345
- }
1346
- headers.set('User-Agent', this.userAgent);
1347
- const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
1348
- const respBody = await executeHttpCall({
1349
- request: httpReq,
1350
- httpClient: this.httpClient,
1351
- logger: this.logger,
1352
- });
1353
- resp = parseResponse(respBody, unmarshalUpdateModelVersionResponseSchema);
1354
- };
1355
- await executeCall(call, options);
1356
- if (resp === undefined) {
1357
- throw new Error('operation completed without a result.');
1358
- }
1359
- return resp;
1360
- }
1361
-
1362
- /** Updates a registered model. */
1363
- async updateRegisteredModel(
1364
- req: UpdateRegisteredModelRequest,
1365
- options?: CallOptions
1366
- ): Promise<UpdateRegisteredModelResponse> {
1367
- const url = `${this.host}/api/2.0/mlflow/registered-models/update`;
1368
- const body = marshalRequest(req, marshalUpdateRegisteredModelRequestSchema);
1369
- let resp: UpdateRegisteredModelResponse | undefined;
1370
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1371
- const headers = new Headers({'Content-Type': 'application/json'});
1372
- if (this.workspaceId !== undefined) {
1373
- headers.set('X-Databricks-Org-Id', this.workspaceId);
1374
- }
1375
- headers.set('User-Agent', this.userAgent);
1376
- const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
1377
- const respBody = await executeHttpCall({
1378
- request: httpReq,
1379
- httpClient: this.httpClient,
1380
- logger: this.logger,
1381
- });
1382
- resp = parseResponse(
1383
- respBody,
1384
- unmarshalUpdateRegisteredModelResponseSchema
1385
- );
1386
- };
1387
- await executeCall(call, options);
1388
- if (resp === undefined) {
1389
- throw new Error('operation completed without a result.');
1390
- }
1391
- return resp;
1392
- }
1393
- }