databricks / databricks-sdk-go

Databricks SDK for Go
https://docs.databricks.com/dev-tools/sdk-go.html
Apache License 2.0
48 stars 41 forks source link

[ISSUE] Does Workspace client use route optimized endpoints #951

Open moritzmeister opened 3 months ago

moritzmeister commented 3 months ago

Description We have a bunch of route optimized model serving endpoints that we query using the go sdk. Route optimized endpints have essentially two hosts, the regular workspace host and the host for the optimized routing.

When setting up the workspace client, we use the regular workspace host. So now we are wondering if the query method then actually uses the route optimized endpoint?

We saw that even for a route optimized endpoint it's possible to call the non-optimized host/endpoint.

Reproduction

package main

import (
    "context"
    "encoding/json"
    "fmt"
    "io"
    "os"

    "github.com/databricks/databricks-sdk-go"
    "github.com/databricks/databricks-sdk-go/service/serving"
)

func main() {
    w := databricks.Must(databricks.NewWorkspaceClient(&databricks.Config{
        Host:         "https://host.cloud.databricks.com/",
        ClientSecret: "",
        ClientID:     "",
    }))

    // Open the JSON file
    file, err := os.Open("data.json")
    if err != nil {
        fmt.Println("Error opening file:", err)
        return
    }
    defer file.Close()

    // Read the file's content
    byteValue, err := io.ReadAll(file)
    if err != nil {
        fmt.Println("Error reading file:", err)
        return
    }

    // Unmarshal the JSON content into the struct
    var dataframe serving.DataframeSplitInput
    err = json.Unmarshal(byteValue, &dataframe)
    if err != nil {
        fmt.Println("Error unmarshalling JSON:", err)
        return
    }

    // Print the struct to verify the content
    fmt.Printf("%+v\n", dataframe)

    request := serving.QueryEndpointInput{
        Name:           "model_name",
        DataframeSplit: &dataframe,
    }

    response, err := w.ServingEndpoints.Query(context.Background(), request)
    if err != nil {
        panic(err)
    }
    fmt.Println(response.Predictions)
}

Expected behavior Use optimized endpoint host when the model serving is route optimized.

Other Information