Skip to content

Commit

Permalink
Merge branch 'main' into dsuhinin/move-get-model-version-endpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Software Developer <[email protected]>
  • Loading branch information
dsuhinin authored Dec 17, 2024
2 parents bcfad6d + 813c4fc commit 5da129e
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 2 deletions.
2 changes: 1 addition & 1 deletion magefiles/generate/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ var ServiceInfoMap = map[string]ServiceGenerationInfo{
// "searchRegisteredModels",
"getLatestVersions",
// "createModelVersion",
// "updateModelVersion",
"updateModelVersion",
// "transitionModelVersionStage",
"deleteModelVersion",
"getModelVersion",
Expand Down
5 changes: 5 additions & 0 deletions mlflow_go/store/model_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
GetModelVersion,
GetRegisteredModel,
RenameRegisteredModel,
UpdateModelVersion,
UpdateRegisteredModel,
)

Expand Down Expand Up @@ -92,6 +93,10 @@ def get_model_version(self, name, version):
)
return ModelVersion.from_proto(response.model_version)

def update_model_version(self, name, version, description=None):
request = UpdateModelVersion(name=name, version=str(version), description=description)
self.service.call_endpoint(get_lib().ModelRegistryServiceUpdateModelVersion, request)


def ModelRegistryStore(cls):
return type(cls.__name__, (_ModelRegistryStore, cls), {})
Expand Down
1 change: 1 addition & 0 deletions pkg/contract/service/model_registry.g.go

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

8 changes: 8 additions & 0 deletions pkg/lib/model_registry.g.go

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

11 changes: 10 additions & 1 deletion pkg/model_registry/service/model_versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,20 @@ func (m *ModelRegistryService) GetModelVersion(
}

modelVersion, err := m.store.GetModelVersion(ctx, input.GetName(), version, true)

Check failure on line 103 in pkg/model_registry/service/model_versions.go

View workflow job for this annotation

GitHub Actions / lint / Lint

declared and not used: err (typecheck)
return &protos.GetModelVersion_Response{
ModelVersion: modelVersion.ToProto(),
}, nil
}

func (m *ModelRegistryService) UpdateModelVersion(
ctx context.Context, input *protos.UpdateModelVersion,
) (*protos.UpdateModelVersion_Response, *contract.Error) {
modelVersion, err := m.store.UpdateModelVersion(ctx, input.GetName(), input.GetVersion(), input.GetDescription())
if err != nil {
return nil, err
}

return &protos.GetModelVersion_Response{
return &protos.UpdateModelVersion_Response{
ModelVersion: modelVersion.ToProto(),
}, nil
}
24 changes: 24 additions & 0 deletions pkg/model_registry/store/sql/model_versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,3 +378,27 @@ func (m *ModelRegistrySQLStore) DeleteModelVersion(ctx context.Context, name, ve

return nil
}

func (m *ModelRegistrySQLStore) UpdateModelVersion(
ctx context.Context, name, version, description string,
) (*entities.ModelVersion, *contract.Error) {
modelVersion, err := m.GetModelVersion(ctx, name, version)

Check failure on line 385 in pkg/model_registry/store/sql/model_versions.go

View workflow job for this annotation

GitHub Actions / lint / Lint

not enough arguments in call to m.GetModelVersion

Check failure on line 385 in pkg/model_registry/store/sql/model_versions.go

View workflow job for this annotation

GitHub Actions / lint / Lint

not enough arguments in call to m.GetModelVersion

Check failure on line 385 in pkg/model_registry/store/sql/model_versions.go

View workflow job for this annotation

GitHub Actions / test / Test Go (macos-latest)

not enough arguments in call to m.GetModelVersion

Check failure on line 385 in pkg/model_registry/store/sql/model_versions.go

View workflow job for this annotation

GitHub Actions / build / Build Python wheel (darwin, amd64)

not enough arguments in call to m.GetModelVersion

Check failure on line 385 in pkg/model_registry/store/sql/model_versions.go

View workflow job for this annotation

GitHub Actions / test / Test Python (macos-latest, 3.9)

not enough arguments in call to m.GetModelVersion

Check failure on line 385 in pkg/model_registry/store/sql/model_versions.go

View workflow job for this annotation

GitHub Actions / build / Build Python wheel (darwin, arm64)

not enough arguments in call to m.GetModelVersion

Check failure on line 385 in pkg/model_registry/store/sql/model_versions.go

View workflow job for this annotation

GitHub Actions / test / Test Python (macos-latest, 3.10)

not enough arguments in call to m.GetModelVersion

Check failure on line 385 in pkg/model_registry/store/sql/model_versions.go

View workflow job for this annotation

GitHub Actions / build / Build Python wheel (linux, amd64)

not enough arguments in call to m.GetModelVersion

Check failure on line 385 in pkg/model_registry/store/sql/model_versions.go

View workflow job for this annotation

GitHub Actions / test / Test Python (macos-latest, 3.11)

not enough arguments in call to m.GetModelVersion

Check failure on line 385 in pkg/model_registry/store/sql/model_versions.go

View workflow job for this annotation

GitHub Actions / test / Test Python (macos-latest, 3.12)

not enough arguments in call to m.GetModelVersion

Check failure on line 385 in pkg/model_registry/store/sql/model_versions.go

View workflow job for this annotation

GitHub Actions / test / Test Python (ubuntu-latest, 3.9)

not enough arguments in call to m.GetModelVersion

Check failure on line 385 in pkg/model_registry/store/sql/model_versions.go

View workflow job for this annotation

GitHub Actions / test / Test Python (ubuntu-latest, 3.10)

not enough arguments in call to m.GetModelVersion

Check failure on line 385 in pkg/model_registry/store/sql/model_versions.go

View workflow job for this annotation

GitHub Actions / test / Test Python (ubuntu-latest, 3.11)

not enough arguments in call to m.GetModelVersion

Check failure on line 385 in pkg/model_registry/store/sql/model_versions.go

View workflow job for this annotation

GitHub Actions / test / Test Python (ubuntu-latest, 3.12)

not enough arguments in call to m.GetModelVersion

Check failure on line 385 in pkg/model_registry/store/sql/model_versions.go

View workflow job for this annotation

GitHub Actions / test / Test Python (windows-latest, 3.9)

not enough arguments in call to m.GetModelVersion

Check failure on line 385 in pkg/model_registry/store/sql/model_versions.go

View workflow job for this annotation

GitHub Actions / test / Test Python (windows-latest, 3.10)

not enough arguments in call to m.GetModelVersion

Check failure on line 385 in pkg/model_registry/store/sql/model_versions.go

View workflow job for this annotation

GitHub Actions / test / Test Python (windows-latest, 3.11)

not enough arguments in call to m.GetModelVersion
if err != nil {
return nil, err
}

if err := m.db.WithContext(ctx).Model(
&models.ModelVersion{},
).Where(
"name = ?", modelVersion.Name,
).Where(
"version = ?", modelVersion.Version,
).Updates(&models.ModelVersion{
Description: sql.NullString{String: description, Valid: description != ""},
LastUpdatedTime: time.Now().UnixMilli(),
}).Error; err != nil {
return nil, contract.NewErrorWith(protos.ErrorCode_INTERNAL_ERROR, "error updating model version", err)
}

return modelVersion, nil
}
1 change: 1 addition & 0 deletions pkg/model_registry/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ type ModelRegistryStore interface {
DeleteRegisteredModel(ctx context.Context, name string) *contract.Error
GetModelVersion(ctx context.Context, name, version string, eager bool) (*entities.ModelVersion, *contract.Error)
DeleteModelVersion(ctx context.Context, name, version string) *contract.Error
UpdateModelVersion(ctx context.Context, name, version, description string) (*entities.ModelVersion, *contract.Error)
}
11 changes: 11 additions & 0 deletions pkg/server/routes/model_registry.g.go

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

0 comments on commit 5da129e

Please sign in to comment.