Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions knip.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@databricks/sdk-genie",
"@databricks/sdk-jobs",
"@databricks/sdk-postgres",
"@databricks/sdk-modelserving",
"@databricks/sdk-uc-tables",
"@databricks/sdk-vectorsearch",
"@databricks/sdk-options",
Expand Down
1 change: 1 addition & 0 deletions packages/appkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"@databricks/sdk-files": "0.52.0",
"@databricks/sdk-genie": "0.54.0",
"@databricks/sdk-jobs": "0.57.0",
"@databricks/sdk-modelserving": "0.53.0",
"@databricks/sdk-uc-tables": "0.52.0",
"@databricks/sdk-vectorsearch": "0.51.0",
"@databricks/sdk-options": "0.51.0",
Expand Down
1 change: 1 addition & 0 deletions packages/appkit/src/testing/mock-workspace-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const FACADE_SERVICES = [
"tables",
"postgres",
"statementExecution",
"modelServing",
"servingEndpoints",
"currentUser",
] as const;
Expand Down
1 change: 1 addition & 0 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"@databricks/sdk-files": "0.52.0",
"@databricks/sdk-genie": "0.54.0",
"@databricks/sdk-jobs": "0.57.0",
"@databricks/sdk-modelserving": "0.53.0",
"@databricks/sdk-uc-tables": "0.52.0",
"@databricks/sdk-vectorsearch": "0.51.0",
"@databricks/sdk-options": "0.51.0",
Expand Down
12 changes: 12 additions & 0 deletions packages/shared/src/workspace-client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import {
type GenieClient,
buildJobsClient,
type JobsClient,
buildModelServingClient,
type ModelServingClient,
buildFilesClient,
type FilesClient,
buildTablesClient,
Expand All @@ -46,6 +48,7 @@ export class AppKitWorkspaceClient implements WorkspaceClient {
#currentUser?: ScimClient;
#genie?: GenieClient;
#jobs?: JobsClient;
#modelServing?: ModelServingClient;
#files?: FilesClient;
#vectorSearch?: VectorSearchClient;
#tables?: TablesClient;
Expand Down Expand Up @@ -119,6 +122,15 @@ export class AppKitWorkspaceClient implements WorkspaceClient {
return this.#statementExecution;
}

// Modular serving endpoints client. A new accessor because `servingEndpoints`
// is the legacy client's public type and can't change.
get modelServing(): ModelServingClient {
if (!this.#modelServing) {
this.#modelServing = buildModelServingClient(this.#opts);
}
return this.#modelServing;
}

get servingEndpoints() {
return this.#getLegacy().servingEndpoints;
}
Expand Down
22 changes: 22 additions & 0 deletions packages/shared/src/workspace-client/modular.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import { type ProfileOptions, resolve } from "@databricks/sdk-core/profiles";
import type { FilesClient } from "@databricks/sdk-files/v2";
import type { GenieClient } from "@databricks/sdk-genie/v1";
import type { JobsClient } from "@databricks/sdk-jobs/v2";
import type { ModelServingClient } from "@databricks/sdk-modelserving/v1";
import type { ClientOptions } from "@databricks/sdk-options/client";
import type { PostgresClient } from "@databricks/sdk-postgres/v1";
import { ScimClient } from "@databricks/sdk-scim/v1";
Expand Down Expand Up @@ -616,6 +617,19 @@ export function buildVectorSearchClient(
);
}

/** Build a modular Model Serving (serving endpoints) client from wrapper options. */
export function buildModelServingClient(
opts: WorkspaceClientOptions,
): ModelServingClient {
return lazyClient(
() =>
import("@databricks/sdk-modelserving/v1").then(
(m) => m.ModelServingClient,
),
mapToClientOptions(opts),
);
}

/** Build a modular Unity Catalog Tables client from wrapper options. */
export function buildTablesClient(opts: WorkspaceClientOptions): TablesClient {
return lazyClient(
Expand Down Expand Up @@ -646,6 +660,7 @@ export type {
} from "@databricks/sdk-files/v2";
export type { GenieClient } from "@databricks/sdk-genie/v1";
export type { JobsClient } from "@databricks/sdk-jobs/v2";
export type { ModelServingClient } from "@databricks/sdk-modelserving/v1";
export type { PostgresClient } from "@databricks/sdk-postgres/v1";
export type { ScimClient } from "@databricks/sdk-scim/v1";
export type { StatementExecutionClient } from "@databricks/sdk-statementexecution/v1";
Expand Down Expand Up @@ -692,6 +707,13 @@ export type {
SubmitRunRequest,
SubmitRunResponse,
} from "@databricks/sdk-jobs/v2";
export type {
GetInferenceEndpointRequest,
InferenceEndpoint,
InferenceEndpointDetailed,
ListInferenceEndpointsRequest,
ListInferenceEndpointsResponse,
} from "@databricks/sdk-modelserving/v1";
export type {
EndpointHealth,
EndpointInfo,
Expand Down
32 changes: 32 additions & 0 deletions packages/shared/src/workspace-client/tests/modular.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ vi.mock("@databricks/sdk-genie/v1", () => ({
};
}),
}));
vi.mock("@databricks/sdk-modelserving/v1", () => ({
ModelServingClient: vi.fn().mockImplementation((opts) => {
ctorOpts.push(opts);
return { opts, getInferenceEndpoint: async () => ({}) };
}),
}));
vi.mock("@databricks/sdk-postgres/v1", () => ({
PostgresClient: vi.fn().mockImplementation((opts) => {
ctorOpts.push(opts);
Expand Down Expand Up @@ -125,6 +131,7 @@ vi.mock("node:child_process", () => ({
import { ApiError } from "../errors";
import {
buildGenieClient,
buildModelServingClient,
buildWarehousesClient,
buildPostgresClient,
buildWorkspaceAuth,
Expand Down Expand Up @@ -352,6 +359,31 @@ describe("modular mapToClientOptions (via buildWarehousesClient)", () => {
expect(Reflect.get(client, "then")).toBeUndefined();
});

test("modelServing normalizes the host and passes SP M2M credentials", async () => {
process.env.DATABRICKS_HOST = "envhost.cloud.databricks.com";
process.env.DATABRICKS_CLIENT_ID = "sp-client-id";
process.env.DATABRICKS_CLIENT_SECRET = "sp-secret";
await buildModelServingClient({}).getInferenceEndpoint({} as never);
expect(ctorOpts[0].host).toBe("https://envhost.cloud.databricks.com");
expect((ctorOpts[0].credentials as { name: () => string }).name()).toBe(
"oauth-m2m",
);
});

test("modelServing (asUser) uses the OBO token as PAT, not the SP env creds", async () => {
process.env.DATABRICKS_CLIENT_ID = "sp-client-id";
process.env.DATABRICKS_CLIENT_SECRET = "sp-secret";
await buildModelServingClient({
token: "user-token",
host: "https://x",
}).getInferenceEndpoint({} as never);
expect(ctorOpts[0].credentials).toMatchObject({
kind: "pat",
token: "user-token",
});
expect(m2mOpts).toEqual([]);
});

test("postgres normalizes the host and passes SP M2M credentials", async () => {
process.env.DATABRICKS_HOST = "envhost.cloud.databricks.com";
process.env.DATABRICKS_CLIENT_ID = "sp-client-id";
Expand Down
4 changes: 4 additions & 0 deletions packages/shared/src/workspace-client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import type {
ScimClient,
GenieClient,
JobsClient,
ModelServingClient,
FilesClient,
TablesClient,
VectorSearchClient,
Expand Down Expand Up @@ -71,6 +72,9 @@ export interface WorkspaceClient extends WorkspaceAuth {
/** Statement Execution (modular SDK). */
readonly statementExecution: StatementExecutionClient;

/** Serving endpoints (modular SDK). `servingEndpoints` below stays legacy-typed. */
readonly modelServing: ModelServingClient;

/** Serving Endpoints. */
readonly servingEndpoints: LegacyWorkspaceClient["servingEndpoints"];

Expand Down
19 changes: 19 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading