Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAS: Fix discriminator field definition for Artifact #22

Merged
merged 2 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ metadata.sqlite.db

# Ignore go vendor and code coverage files
vendor
coverage.txt
coverage.*

# Robot Framework files
log.html
Expand Down
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}
}
}

isinyaaa marked this conversation as resolved.
Show resolved Hide resolved
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
Loading