Skip to content

Commit

Permalink
fix REST api to use ModelVersionUpdate in PATCH method
Browse files Browse the repository at this point in the history
Signed-off-by: Matteo Mortari <[email protected]>
  • Loading branch information
tarilabs authored and isinyaaa committed Mar 8, 2024
1 parent e95a979 commit 7b0dca0
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 100 deletions.
2 changes: 1 addition & 1 deletion api/openapi/model-registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/ModelVersion"
$ref: "#/components/schemas/ModelVersionUpdate"
required: true
tags:
- ModelRegistryService
Expand Down
2 changes: 1 addition & 1 deletion internal/server/openapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ type ModelRegistryServiceAPIServicer interface {
GetServingEnvironments(context.Context, string, model.OrderByField, model.SortOrder, string) (ImplResponse, error)
UpdateInferenceService(context.Context, string, model.InferenceServiceUpdate) (ImplResponse, error)
UpdateModelArtifact(context.Context, string, model.ModelArtifactUpdate) (ImplResponse, error)
UpdateModelVersion(context.Context, string, model.ModelVersion) (ImplResponse, error)
UpdateModelVersion(context.Context, string, model.ModelVersionUpdate) (ImplResponse, error)
UpdateRegisteredModel(context.Context, string, model.RegisteredModelUpdate) (ImplResponse, error)
UpdateServingEnvironment(context.Context, string, model.ServingEnvironmentUpdate) (ImplResponse, error)
}
10 changes: 5 additions & 5 deletions internal/server/openapi/api_model_registry_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -870,22 +870,22 @@ func (c *ModelRegistryServiceAPIController) UpdateModelArtifact(w http.ResponseW
// UpdateModelVersion - Update a ModelVersion
func (c *ModelRegistryServiceAPIController) UpdateModelVersion(w http.ResponseWriter, r *http.Request) {
modelversionIdParam := chi.URLParam(r, "modelversionId")
modelVersionParam := model.ModelVersion{}
modelVersionUpdateParam := model.ModelVersionUpdate{}
d := json.NewDecoder(r.Body)
d.DisallowUnknownFields()
if err := d.Decode(&modelVersionParam); err != nil {
if err := d.Decode(&modelVersionUpdateParam); err != nil {
c.errorHandler(w, r, &ParsingError{Err: err}, nil)
return
}
if err := AssertModelVersionRequired(modelVersionParam); err != nil {
if err := AssertModelVersionUpdateRequired(modelVersionUpdateParam); err != nil {
c.errorHandler(w, r, err, nil)
return
}
if err := AssertModelVersionConstraints(modelVersionParam); err != nil {
if err := AssertModelVersionUpdateConstraints(modelVersionUpdateParam); err != nil {
c.errorHandler(w, r, err, nil)
return
}
result, err := c.service.UpdateModelVersion(r.Context(), modelversionIdParam, modelVersionParam)
result, err := c.service.UpdateModelVersion(r.Context(), modelversionIdParam, modelVersionUpdateParam)
// If an error occurred, encode the error with the status code
if err != nil {
c.errorHandler(w, r, err, &result)
Expand Down
15 changes: 7 additions & 8 deletions internal/server/openapi/api_model_registry_service_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,14 +476,13 @@ func (s *ModelRegistryServiceAPIService) UpdateModelArtifact(ctx context.Context
}

// UpdateModelVersion - Update a ModelVersion
func (s *ModelRegistryServiceAPIService) UpdateModelVersion(ctx context.Context, modelversionId string, modelVersion model.ModelVersion) (ImplResponse, error) {
// TODO: this API is getting model.ModelVersion instead of model.ModelVersionUpdate.
// c, err := s.converter.ConvertModelVersionUpdate(&modelVersion)
// if err != nil {
// return Response(500, model.Error{Message: err.Error()}), nil
// }
// modelVersion.Id = &modelversionId
result, err := s.coreApi.UpsertModelVersion(&modelVersion, nil)
func (s *ModelRegistryServiceAPIService) UpdateModelVersion(ctx context.Context, modelversionId string, modelVersionUpdate model.ModelVersionUpdate) (ImplResponse, error) {
modelVersion, err := s.converter.ConvertModelVersionUpdate(&modelVersionUpdate)
if err != nil {
return Response(500, model.Error{Message: err.Error()}), nil
}
modelVersion.Id = &modelversionId
result, err := s.coreApi.UpsertModelVersion(modelVersion, nil)
if err != nil {
return Response(500, model.Error{Message: err.Error()}), nil
}
Expand Down
152 changes: 76 additions & 76 deletions internal/server/openapi/type_asserts.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,23 @@ func AssertArtifactStateConstraints(obj model.ArtifactState) error {
return nil
}

// AssertBaseArtifactCreateRequired checks if the required fields are not zero-ed
func AssertBaseArtifactCreateRequired(obj model.BaseArtifactCreate) error {
// AssertBaseArtifactRequired checks if the required fields are not zero-ed
func AssertBaseArtifactRequired(obj model.BaseArtifact) error {
return nil
}

// AssertBaseArtifactCreateConstraints checks if the values respects the defined constraints
func AssertBaseArtifactCreateConstraints(obj model.BaseArtifactCreate) error {
// AssertBaseArtifactConstraints checks if the values respects the defined constraints
func AssertBaseArtifactConstraints(obj model.BaseArtifact) error {
return nil
}

// AssertBaseArtifactRequired checks if the required fields are not zero-ed
func AssertBaseArtifactRequired(obj model.BaseArtifact) error {
// AssertBaseArtifactCreateRequired checks if the required fields are not zero-ed
func AssertBaseArtifactCreateRequired(obj model.BaseArtifactCreate) error {
return nil
}

// AssertBaseArtifactConstraints checks if the values respects the defined constraints
func AssertBaseArtifactConstraints(obj model.BaseArtifact) error {
// AssertBaseArtifactCreateConstraints checks if the values respects the defined constraints
func AssertBaseArtifactCreateConstraints(obj model.BaseArtifactCreate) error {
return nil
}

Expand All @@ -92,23 +92,23 @@ func AssertBaseArtifactUpdateConstraints(obj model.BaseArtifactUpdate) error {
return nil
}

// AssertBaseExecutionCreateRequired checks if the required fields are not zero-ed
func AssertBaseExecutionCreateRequired(obj model.BaseExecutionCreate) error {
// AssertBaseExecutionRequired checks if the required fields are not zero-ed
func AssertBaseExecutionRequired(obj model.BaseExecution) error {
return nil
}

// AssertBaseExecutionCreateConstraints checks if the values respects the defined constraints
func AssertBaseExecutionCreateConstraints(obj model.BaseExecutionCreate) error {
// AssertBaseExecutionConstraints checks if the values respects the defined constraints
func AssertBaseExecutionConstraints(obj model.BaseExecution) error {
return nil
}

// AssertBaseExecutionRequired checks if the required fields are not zero-ed
func AssertBaseExecutionRequired(obj model.BaseExecution) error {
// AssertBaseExecutionCreateRequired checks if the required fields are not zero-ed
func AssertBaseExecutionCreateRequired(obj model.BaseExecutionCreate) error {
return nil
}

// AssertBaseExecutionConstraints checks if the values respects the defined constraints
func AssertBaseExecutionConstraints(obj model.BaseExecution) error {
// AssertBaseExecutionCreateConstraints checks if the values respects the defined constraints
func AssertBaseExecutionCreateConstraints(obj model.BaseExecutionCreate) error {
return nil
}

Expand All @@ -122,23 +122,23 @@ func AssertBaseExecutionUpdateConstraints(obj model.BaseExecutionUpdate) error {
return nil
}

// AssertBaseResourceCreateRequired checks if the required fields are not zero-ed
func AssertBaseResourceCreateRequired(obj model.BaseResourceCreate) error {
// AssertBaseResourceRequired checks if the required fields are not zero-ed
func AssertBaseResourceRequired(obj model.BaseResource) error {
return nil
}

// AssertBaseResourceCreateConstraints checks if the values respects the defined constraints
func AssertBaseResourceCreateConstraints(obj model.BaseResourceCreate) error {
// AssertBaseResourceConstraints checks if the values respects the defined constraints
func AssertBaseResourceConstraints(obj model.BaseResource) error {
return nil
}

// AssertBaseResourceRequired checks if the required fields are not zero-ed
func AssertBaseResourceRequired(obj model.BaseResource) error {
// AssertBaseResourceCreateRequired checks if the required fields are not zero-ed
func AssertBaseResourceCreateRequired(obj model.BaseResourceCreate) error {
return nil
}

// AssertBaseResourceConstraints checks if the values respects the defined constraints
func AssertBaseResourceConstraints(obj model.BaseResource) error {
// AssertBaseResourceCreateConstraints checks if the values respects the defined constraints
func AssertBaseResourceCreateConstraints(obj model.BaseResourceCreate) error {
return nil
}

Expand Down Expand Up @@ -222,8 +222,8 @@ func AssertExecutionStateConstraints(obj model.ExecutionState) error {
return nil
}

// AssertInferenceServiceCreateRequired checks if the required fields are not zero-ed
func AssertInferenceServiceCreateRequired(obj model.InferenceServiceCreate) error {
// AssertInferenceServiceRequired checks if the required fields are not zero-ed
func AssertInferenceServiceRequired(obj model.InferenceService) error {
elements := map[string]interface{}{
"registeredModelId": obj.RegisteredModelId,
"servingEnvironmentId": obj.ServingEnvironmentId,
Expand All @@ -237,13 +237,13 @@ func AssertInferenceServiceCreateRequired(obj model.InferenceServiceCreate) erro
return nil
}

// AssertInferenceServiceCreateConstraints checks if the values respects the defined constraints
func AssertInferenceServiceCreateConstraints(obj model.InferenceServiceCreate) error {
// AssertInferenceServiceConstraints checks if the values respects the defined constraints
func AssertInferenceServiceConstraints(obj model.InferenceService) error {
return nil
}

// AssertInferenceServiceRequired checks if the required fields are not zero-ed
func AssertInferenceServiceRequired(obj model.InferenceService) error {
// AssertInferenceServiceCreateRequired checks if the required fields are not zero-ed
func AssertInferenceServiceCreateRequired(obj model.InferenceServiceCreate) error {
elements := map[string]interface{}{
"registeredModelId": obj.RegisteredModelId,
"servingEnvironmentId": obj.ServingEnvironmentId,
Expand All @@ -257,8 +257,8 @@ func AssertInferenceServiceRequired(obj model.InferenceService) error {
return nil
}

// AssertInferenceServiceConstraints checks if the values respects the defined constraints
func AssertInferenceServiceConstraints(obj model.InferenceService) error {
// AssertInferenceServiceCreateConstraints checks if the values respects the defined constraints
func AssertInferenceServiceCreateConstraints(obj model.InferenceServiceCreate) error {
return nil
}

Expand Down Expand Up @@ -456,16 +456,6 @@ func AssertMetadataValueConstraints(obj model.MetadataValue) error {
return nil
}

// AssertModelArtifactCreateRequired checks if the required fields are not zero-ed
func AssertModelArtifactCreateRequired(obj model.ModelArtifactCreate) error {
return nil
}

// AssertModelArtifactCreateConstraints checks if the values respects the defined constraints
func AssertModelArtifactCreateConstraints(obj model.ModelArtifactCreate) error {
return nil
}

// AssertModelArtifactRequired checks if the required fields are not zero-ed
func AssertModelArtifactRequired(obj model.ModelArtifact) error {
elements := map[string]interface{}{
Expand All @@ -485,6 +475,16 @@ func AssertModelArtifactConstraints(obj model.ModelArtifact) error {
return nil
}

// AssertModelArtifactCreateRequired checks if the required fields are not zero-ed
func AssertModelArtifactCreateRequired(obj model.ModelArtifactCreate) error {
return nil
}

// AssertModelArtifactCreateConstraints checks if the values respects the defined constraints
func AssertModelArtifactCreateConstraints(obj model.ModelArtifactCreate) error {
return nil
}

// AssertModelArtifactListRequired checks if the required fields are not zero-ed
func AssertModelArtifactListRequired(obj model.ModelArtifactList) error {
elements := map[string]interface{}{
Expand Down Expand Up @@ -521,6 +521,16 @@ func AssertModelArtifactUpdateConstraints(obj model.ModelArtifactUpdate) error {
return nil
}

// AssertModelVersionRequired checks if the required fields are not zero-ed
func AssertModelVersionRequired(obj model.ModelVersion) error {
return nil
}

// AssertModelVersionConstraints checks if the values respects the defined constraints
func AssertModelVersionConstraints(obj model.ModelVersion) error {
return nil
}

// AssertModelVersionCreateRequired checks if the required fields are not zero-ed
func AssertModelVersionCreateRequired(obj model.ModelVersionCreate) error {
elements := map[string]interface{}{
Expand All @@ -540,16 +550,6 @@ func AssertModelVersionCreateConstraints(obj model.ModelVersionCreate) error {
return nil
}

// AssertModelVersionRequired checks if the required fields are not zero-ed
func AssertModelVersionRequired(obj model.ModelVersion) error {
return nil
}

// AssertModelVersionConstraints checks if the values respects the defined constraints
func AssertModelVersionConstraints(obj model.ModelVersion) error {
return nil
}

// AssertModelVersionListRequired checks if the required fields are not zero-ed
func AssertModelVersionListRequired(obj model.ModelVersionList) error {
elements := map[string]interface{}{
Expand Down Expand Up @@ -606,23 +606,23 @@ func AssertOrderByFieldConstraints(obj model.OrderByField) error {
return nil
}

// AssertRegisteredModelCreateRequired checks if the required fields are not zero-ed
func AssertRegisteredModelCreateRequired(obj model.RegisteredModelCreate) error {
// AssertRegisteredModelRequired checks if the required fields are not zero-ed
func AssertRegisteredModelRequired(obj model.RegisteredModel) error {
return nil
}

// AssertRegisteredModelCreateConstraints checks if the values respects the defined constraints
func AssertRegisteredModelCreateConstraints(obj model.RegisteredModelCreate) error {
// AssertRegisteredModelConstraints checks if the values respects the defined constraints
func AssertRegisteredModelConstraints(obj model.RegisteredModel) error {
return nil
}

// AssertRegisteredModelRequired checks if the required fields are not zero-ed
func AssertRegisteredModelRequired(obj model.RegisteredModel) error {
// AssertRegisteredModelCreateRequired checks if the required fields are not zero-ed
func AssertRegisteredModelCreateRequired(obj model.RegisteredModelCreate) error {
return nil
}

// AssertRegisteredModelConstraints checks if the values respects the defined constraints
func AssertRegisteredModelConstraints(obj model.RegisteredModel) error {
// AssertRegisteredModelCreateConstraints checks if the values respects the defined constraints
func AssertRegisteredModelCreateConstraints(obj model.RegisteredModelCreate) error {
return nil
}

Expand Down Expand Up @@ -672,8 +672,8 @@ func AssertRegisteredModelUpdateConstraints(obj model.RegisteredModelUpdate) err
return nil
}

// AssertServeModelCreateRequired checks if the required fields are not zero-ed
func AssertServeModelCreateRequired(obj model.ServeModelCreate) error {
// AssertServeModelRequired checks if the required fields are not zero-ed
func AssertServeModelRequired(obj model.ServeModel) error {
elements := map[string]interface{}{
"modelVersionId": obj.ModelVersionId,
}
Expand All @@ -686,13 +686,13 @@ func AssertServeModelCreateRequired(obj model.ServeModelCreate) error {
return nil
}

// AssertServeModelCreateConstraints checks if the values respects the defined constraints
func AssertServeModelCreateConstraints(obj model.ServeModelCreate) error {
// AssertServeModelConstraints checks if the values respects the defined constraints
func AssertServeModelConstraints(obj model.ServeModel) error {
return nil
}

// AssertServeModelRequired checks if the required fields are not zero-ed
func AssertServeModelRequired(obj model.ServeModel) error {
// AssertServeModelCreateRequired checks if the required fields are not zero-ed
func AssertServeModelCreateRequired(obj model.ServeModelCreate) error {
elements := map[string]interface{}{
"modelVersionId": obj.ModelVersionId,
}
Expand All @@ -705,8 +705,8 @@ func AssertServeModelRequired(obj model.ServeModel) error {
return nil
}

// AssertServeModelConstraints checks if the values respects the defined constraints
func AssertServeModelConstraints(obj model.ServeModel) error {
// AssertServeModelCreateConstraints checks if the values respects the defined constraints
func AssertServeModelCreateConstraints(obj model.ServeModelCreate) error {
return nil
}

Expand Down Expand Up @@ -746,23 +746,23 @@ func AssertServeModelUpdateConstraints(obj model.ServeModelUpdate) error {
return nil
}

// AssertServingEnvironmentCreateRequired checks if the required fields are not zero-ed
func AssertServingEnvironmentCreateRequired(obj model.ServingEnvironmentCreate) error {
// AssertServingEnvironmentRequired checks if the required fields are not zero-ed
func AssertServingEnvironmentRequired(obj model.ServingEnvironment) error {
return nil
}

// AssertServingEnvironmentCreateConstraints checks if the values respects the defined constraints
func AssertServingEnvironmentCreateConstraints(obj model.ServingEnvironmentCreate) error {
// AssertServingEnvironmentConstraints checks if the values respects the defined constraints
func AssertServingEnvironmentConstraints(obj model.ServingEnvironment) error {
return nil
}

// AssertServingEnvironmentRequired checks if the required fields are not zero-ed
func AssertServingEnvironmentRequired(obj model.ServingEnvironment) error {
// AssertServingEnvironmentCreateRequired checks if the required fields are not zero-ed
func AssertServingEnvironmentCreateRequired(obj model.ServingEnvironmentCreate) error {
return nil
}

// AssertServingEnvironmentConstraints checks if the values respects the defined constraints
func AssertServingEnvironmentConstraints(obj model.ServingEnvironment) error {
// AssertServingEnvironmentCreateConstraints checks if the values respects the defined constraints
func AssertServingEnvironmentCreateConstraints(obj model.ServingEnvironmentCreate) error {
return nil
}

Expand Down
Loading

0 comments on commit 7b0dca0

Please sign in to comment.