Skip to content

Commit

Permalink
OAS: fix discriminator field for Artifact
Browse files Browse the repository at this point in the history
Signed-off-by: Isabella Basso do Amaral <[email protected]>
  • Loading branch information
isinyaaa committed Feb 27, 2024
1 parent 3496eff commit e8bfc1e
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 180 deletions.
40 changes: 18 additions & 22 deletions api/openapi/model-registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -971,24 +971,26 @@ components:
ModelArtifact:
description: An ML model artifact.
type: object
required:
- artifactType
properties:
artifactType:
type: string
default: "model-artifact"
allOf:
- $ref: "#/components/schemas/BaseArtifact"
- $ref: "#/components/schemas/ModelArtifactCreate"
- type: object
properties:
artifactType:
type: string
default: "model-artifact"
DocArtifact:
description: A document.
type: object
required:
- artifactType
properties:
artifactType:
type: string
default: "doc-artifact"
allOf:
- $ref: "#/components/schemas/BaseArtifact"
- type: object
properties:
artifactType:
type: string
default: "doc-artifact"
RegisteredModel:
description: A registered model in model registry. A registered model has ModelVersion children.
allOf:
Expand Down Expand Up @@ -1105,12 +1107,12 @@ components:
discriminator:
propertyName: metadataType
mapping:
MetadataBoolValue: '#/components/schemas/MetadataBoolValue'
MetadataDoubleValue: '#/components/schemas/MetadataDoubleValue'
MetadataIntValue: '#/components/schemas/MetadataIntValue'
MetadataProtoValue: '#/components/schemas/MetadataProtoValue'
MetadataStringValue: '#/components/schemas/MetadataStringValue'
MetadataStructValue: '#/components/schemas/MetadataStructValue'
MetadataBoolValue: "#/components/schemas/MetadataBoolValue"
MetadataDoubleValue: "#/components/schemas/MetadataDoubleValue"
MetadataIntValue: "#/components/schemas/MetadataIntValue"
MetadataProtoValue: "#/components/schemas/MetadataProtoValue"
MetadataStringValue: "#/components/schemas/MetadataStringValue"
MetadataStructValue: "#/components/schemas/MetadataStructValue"
description: A value in properties.
MetadataIntValue:
description: An integer (int64) property value.
Expand Down Expand Up @@ -1345,12 +1347,6 @@ components:
allOf:
- $ref: "#/components/schemas/BaseArtifactCreate"
- $ref: "#/components/schemas/BaseResource"
- required:
- artifactType
type: object
properties:
artifactType:
type: string
ServingEnvironmentList:
description: List of ServingEnvironments.
type: object
Expand Down
36 changes: 18 additions & 18 deletions internal/converter/generated/mlmd_openapi_converter.gen.go

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

22 changes: 11 additions & 11 deletions internal/converter/generated/openapi_converter.gen.go

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

18 changes: 0 additions & 18 deletions internal/server/openapi/type_asserts.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,6 @@ import (

// AssertArtifactRequired checks if the required fields are not zero-ed
func AssertArtifactRequired(obj model.Artifact) error {
// FIXME(manual): Artifact.ArtifactType is not present on client models
// elements := map[string]interface{}{
// "artifactType": obj.ArtifactType,
// }
// for name, el := range elements {
// if isZero := IsZeroValue(el); isZero {
// return &RequiredError{Field: name}
// }
// }
return nil
}

Expand Down Expand Up @@ -83,15 +74,6 @@ func AssertBaseArtifactCreateConstraints(obj model.BaseArtifactCreate) error {

// AssertBaseArtifactRequired checks if the required fields are not zero-ed
func AssertBaseArtifactRequired(obj model.BaseArtifact) error {
elements := map[string]interface{}{
"artifactType": obj.ArtifactType,
}
for name, el := range elements {
if isZero := IsZeroValue(el); isZero {
return &RequiredError{Field: name}
}
}

return nil
}

Expand Down
25 changes: 0 additions & 25 deletions patches/type_asserts.patch
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,6 @@ diff --git a/internal/server/openapi/type_asserts.go b/internal/server/openapi/t
index b001018..9907fbc 100644
--- a/internal/server/openapi/type_asserts.go
+++ b/internal/server/openapi/type_asserts.go
@@ -18,15 +18,15 @@ import (

// AssertArtifactRequired checks if the required fields are not zero-ed
func AssertArtifactRequired(obj model.Artifact) error {
- elements := map[string]interface{}{
- "artifactType": obj.ArtifactType,
- }
- for name, el := range elements {
- if isZero := IsZeroValue(el); isZero {
- return &RequiredError{Field: name}
- }
- }
-
+ // FIXME(manual): Artifact.ArtifactType is not present on client models
+ // elements := map[string]interface{}{
+ // "artifactType": obj.ArtifactType,
+ // }
+ // for name, el := range elements {
+ // if isZero := IsZeroValue(el); isZero {
+ // return &RequiredError{Field: name}
+ // }
+ // }
return nil
}

@@ -449,21 +449,22 @@ func AssertMetadataStructValueConstraints(obj model.MetadataStructValue) error {

// AssertMetadataValueRequired checks if the required fields are not zero-ed
Expand Down
29 changes: 1 addition & 28 deletions pkg/openapi/model_base_artifact.go

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

Loading

0 comments on commit e8bfc1e

Please sign in to comment.