Skip to content

Commit

Permalink
[Exporter] Don't export model serving endpoints with foundational mod…
Browse files Browse the repository at this point in the history
…els (#3845)

## Changes
<!-- Summary of your changes that are easy to understand -->

We need to skip model serving endpoints that serve foundational models
because they are provided by Databricks and we don't have ability to
create serving endpoint for foundational models.

## Tests
<!-- 
How is this tested? Please see the checklist below and also describe any
other relevant tests
-->

- [x] `make test` run locally
- [ ] relevant change in `docs/` folder
- [ ] covered with integration tests in `internal/acceptance`
- [ ] relevant acceptance tests are passing
- [ ] using Go SDK
  • Loading branch information
alexott authored Aug 2, 2024
1 parent 5258611 commit 7a28f57
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
5 changes: 3 additions & 2 deletions exporter/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2303,8 +2303,9 @@ func TestImportingModelServing(t *testing.T) {
},
},
{
Method: "GET",
Resource: "/api/2.0/serving-endpoints/abc?",
Method: "GET",
Resource: "/api/2.0/serving-endpoints/abc?",
ReuseRequest: true,
Response: serving.ServingEndpointDetailed{
Name: "abc",
Id: "1234",
Expand Down
18 changes: 18 additions & 0 deletions exporter/importables.go
Original file line number Diff line number Diff line change
Expand Up @@ -2156,6 +2156,12 @@ var resourcesMap map[string]importable = map[string]importable{
return err
}
for offset, endpoint := range endpointsList {
if endpoint.Config != nil && endpoint.Config.ServedEntities != nil && len(endpoint.Config.ServedEntities) > 0 {
if endpoint.Config.ServedEntities[0].FoundationModel != nil {
log.Printf("[INFO] skipping endpoint %s that is foundation model", endpoint.Name)
continue
}
}
ic.EmitIfUpdatedAfterMillis(&resource{
Resource: "databricks_model_serving",
ID: endpoint.Name,
Expand Down Expand Up @@ -2228,6 +2234,18 @@ var resourcesMap map[string]importable = map[string]importable{
}
return nil
},
Ignore: func(ic *importContext, r *resource) bool {
// We need to ignore endpoints that are foundation models
endpoint, err := ic.workspaceClient.ServingEndpoints.GetByName(ic.Context, r.ID)
if err != nil {
log.Printf("[WARN] Can't get endpoint by name %s: %s", r.ID, err)
return false
}
res := (endpoint.Config != nil && endpoint.Config.ServedEntities != nil &&
len(endpoint.Config.ServedEntities) > 0 && endpoint.Config.ServedEntities[0].FoundationModel != nil)
log.Printf("[DEBUG] Ignore serving endpoint %s? %t", r.ID, res)
return res
},
ShouldOmitField: func(ic *importContext, pathString string, as *schema.Schema, d *schema.ResourceData) bool {
if pathString == "config.0.traffic_config" || pathString == "config.0.auto_capture_config.0.enabled" ||
(pathString == "config.0.auto_capture_config.0.table_name_prefix" && d.Get(pathString).(string) != "") {
Expand Down

0 comments on commit 7a28f57

Please sign in to comment.