From ddbd6aedb9a2fad0d201b420121049c38bd3b9d4 Mon Sep 17 00:00:00 2001 From: Andrea Lamparelli Date: Mon, 26 Feb 2024 13:49:58 +0100 Subject: [PATCH] Fix metadata OpenAPI spec (#17) * fix: OpenAPI metadata discriminator Signed-off-by: tarilabs * wiring factories and default values missed in codegen Signed-off-by: tarilabs * introduce openapi defaults Signed-off-by: tarilabs * fix TestMetadataValue* Signed-off-by: Andrea Lamparelli * fix: type assert generation Signed-off-by: Andrea Lamparelli * upgrade openapi spec version to v1alpha2 Signed-off-by: Andrea Lamparelli --------- Signed-off-by: tarilabs Signed-off-by: Andrea Lamparelli Co-authored-by: tarilabs --- api/openapi/model-registry.yaml | 96 ++++++-- docs/logical_model.md | 24 +- .../generated/openapi_converter.gen.go | 55 +---- .../converter/mlmd_converter_util_test.go | 17 +- .../converter/mlmd_openapi_converter_util.go | 58 +++-- .../converter/openapi_mlmd_converter_util.go | 10 +- .../openapi/api_model_registry_service.go | 72 +++--- internal/server/openapi/type_asserts.go | 78 ++++++ patches/type_asserts.patch | 40 ++- pkg/core/core_test.go | 230 +++++------------- pkg/openapi/api_model_registry_service.go | 72 +++--- pkg/openapi/client.go | 4 +- pkg/openapi/configuration.go | 2 +- pkg/openapi/model_artifact.go | 2 +- pkg/openapi/model_artifact_list.go | 2 +- pkg/openapi/model_artifact_state.go | 2 +- pkg/openapi/model_base_artifact.go | 2 +- pkg/openapi/model_base_artifact_create.go | 2 +- pkg/openapi/model_base_artifact_update.go | 2 +- pkg/openapi/model_base_execution.go | 2 +- pkg/openapi/model_base_execution_create.go | 2 +- pkg/openapi/model_base_execution_update.go | 2 +- pkg/openapi/model_base_resource.go | 2 +- pkg/openapi/model_base_resource_create.go | 2 +- pkg/openapi/model_base_resource_list.go | 2 +- pkg/openapi/model_base_resource_update.go | 2 +- pkg/openapi/model_doc_artifact.go | 2 +- pkg/openapi/model_error.go | 2 +- pkg/openapi/model_execution_state.go | 2 +- pkg/openapi/model_inference_service.go | 2 +- pkg/openapi/model_inference_service_create.go | 2 +- pkg/openapi/model_inference_service_list.go | 2 +- pkg/openapi/model_inference_service_state.go | 2 +- pkg/openapi/model_inference_service_update.go | 2 +- pkg/openapi/model_metadata_bool_value.go | 60 +++-- pkg/openapi/model_metadata_double_value.go | 60 +++-- pkg/openapi/model_metadata_int_value.go | 60 +++-- pkg/openapi/model_metadata_proto_value.go | 93 +++---- pkg/openapi/model_metadata_string_value.go | 60 +++-- pkg/openapi/model_metadata_struct_value.go | 60 +++-- pkg/openapi/model_metadata_value.go | 128 +++++----- pkg/openapi/model_model_artifact.go | 2 +- pkg/openapi/model_model_artifact_create.go | 2 +- pkg/openapi/model_model_artifact_list.go | 2 +- pkg/openapi/model_model_artifact_update.go | 2 +- pkg/openapi/model_model_version.go | 2 +- pkg/openapi/model_model_version_create.go | 2 +- pkg/openapi/model_model_version_list.go | 2 +- pkg/openapi/model_model_version_state.go | 2 +- pkg/openapi/model_model_version_update.go | 2 +- pkg/openapi/model_order_by_field.go | 2 +- pkg/openapi/model_registered_model.go | 2 +- pkg/openapi/model_registered_model_create.go | 2 +- pkg/openapi/model_registered_model_list.go | 2 +- pkg/openapi/model_registered_model_state.go | 2 +- pkg/openapi/model_registered_model_update.go | 2 +- pkg/openapi/model_serve_model.go | 2 +- pkg/openapi/model_serve_model_create.go | 2 +- pkg/openapi/model_serve_model_list.go | 2 +- pkg/openapi/model_serve_model_update.go | 2 +- pkg/openapi/model_serving_environment.go | 2 +- .../model_serving_environment_create.go | 2 +- pkg/openapi/model_serving_environment_list.go | 2 +- .../model_serving_environment_update.go | 2 +- pkg/openapi/model_sort_order.go | 2 +- pkg/openapi/response.go | 2 +- pkg/openapi/utils.go | 2 +- scripts/gen_type_asserts.sh | 4 + test/robot/MRkeywords.resource | 22 +- test/scripts/rest.sh | 8 +- 70 files changed, 786 insertions(+), 621 deletions(-) diff --git a/api/openapi/model-registry.yaml b/api/openapi/model-registry.yaml index 7fd4d0651..a808ff4fe 100644 --- a/api/openapi/model-registry.yaml +++ b/api/openapi/model-registry.yaml @@ -1,7 +1,7 @@ openapi: 3.0.3 info: title: Model Registry REST API - version: v1alpha1 + version: v1alpha2 description: REST API for Model Registry to create and manage ML model metadata license: name: Apache 2.0 @@ -10,7 +10,7 @@ servers: - url: "https://localhost:8080" - url: "http://localhost:8080" paths: - /api/model_registry/v1alpha1/model_artifact: + /api/model_registry/v1alpha2/model_artifact: summary: Path used to search for a modelartifact. description: >- The REST endpoint/path used to search for a `ModelArtifact` entity. This path contains a `GET` operation to perform the find task. @@ -35,7 +35,7 @@ paths: - $ref: "#/components/parameters/name" - $ref: "#/components/parameters/externalID" - $ref: "#/components/parameters/parentResourceID" - /api/model_registry/v1alpha1/model_artifacts: + /api/model_registry/v1alpha2/model_artifacts: summary: Path used to manage the list of modelartifacts. description: >- The REST endpoint/path used to list and create zero or more `ModelArtifact` entities. This path contains a `GET` and `POST` operation to perform the list and create tasks, respectively. @@ -83,7 +83,7 @@ paths: operationId: createModelArtifact summary: Create a ModelArtifact description: Creates a new instance of a `ModelArtifact`. - "/api/model_registry/v1alpha1/model_artifacts/{modelartifactId}": + "/api/model_registry/v1alpha2/model_artifacts/{modelartifactId}": summary: Path used to manage a single ModelArtifact. description: >- The REST endpoint/path used to get, update, and delete single instances of an `ModelArtifact`. This path contains `GET`, `PUT`, and `DELETE` operations used to perform the get, update, and delete tasks, respectively. @@ -133,7 +133,7 @@ paths: type: string in: path required: true - /api/model_registry/v1alpha1/model_versions: + /api/model_registry/v1alpha2/model_versions: summary: Path used to manage the list of modelversions. description: >- The REST endpoint/path used to list and create zero or more `ModelVersion` entities. This path contains a `GET` and `POST` operation to perform the list and create tasks, respectively. @@ -177,7 +177,7 @@ paths: operationId: createModelVersion summary: Create a ModelVersion description: Creates a new instance of a `ModelVersion`. - "/api/model_registry/v1alpha1/model_versions/{modelversionId}": + "/api/model_registry/v1alpha2/model_versions/{modelversionId}": summary: Path used to manage a single ModelVersion. description: >- The REST endpoint/path used to get, update, and delete single instances of an `ModelVersion`. This path contains `GET`, `PUT`, and `DELETE` operations used to perform the get, update, and delete tasks, respectively. @@ -227,7 +227,7 @@ paths: type: string in: path required: true - /api/model_registry/v1alpha1/registered_model: + /api/model_registry/v1alpha2/registered_model: summary: Path used to search for a registeredmodel. description: >- The REST endpoint/path used to search for a `RegisteredModel` entity. This path contains a `GET` operation to perform the find task. @@ -249,7 +249,7 @@ paths: parameters: - $ref: "#/components/parameters/name" - $ref: "#/components/parameters/externalID" - /api/model_registry/v1alpha1/registered_models: + /api/model_registry/v1alpha2/registered_models: summary: Path used to manage the list of registeredmodels. description: >- The REST endpoint/path used to list and create zero or more `RegisteredModel` entities. This path contains a `GET` and `POST` operation to perform the list and create tasks, respectively. @@ -293,7 +293,7 @@ paths: operationId: createRegisteredModel summary: Create a RegisteredModel description: Creates a new instance of a `RegisteredModel`. - "/api/model_registry/v1alpha1/registered_models/{registeredmodelId}": + "/api/model_registry/v1alpha2/registered_models/{registeredmodelId}": summary: Path used to manage a single RegisteredModel. description: >- The REST endpoint/path used to get, update, and delete single instances of an `RegisteredModel`. This path contains `GET`, `PUT`, and `DELETE` operations used to perform the get, update, and delete tasks, respectively. @@ -343,7 +343,7 @@ paths: type: string in: path required: true - "/api/model_registry/v1alpha1/model_versions/{modelversionId}/artifacts": + "/api/model_registry/v1alpha2/model_versions/{modelversionId}/artifacts": summary: Path used to manage the list of artifacts for a modelversion. description: >- The REST endpoint/path used to list and create zero or more `Artifact` entities for a `ModelVersion`. This path contains a `GET` and `POST` operation to perform the list and create tasks, respectively. @@ -401,7 +401,7 @@ paths: type: string in: path required: true - "/api/model_registry/v1alpha1/registered_models/{registeredmodelId}/versions": + "/api/model_registry/v1alpha2/registered_models/{registeredmodelId}/versions": summary: Path used to manage the list of modelversions for a registeredmodel. description: >- The REST endpoint/path used to list and create zero or more `ModelVersion` entities for a `RegisteredModel`. This path contains a `GET` and `POST` operation to perform the list and create tasks, respectively. @@ -458,7 +458,7 @@ paths: type: string in: path required: true - /api/model_registry/v1alpha1/inference_service: + /api/model_registry/v1alpha2/inference_service: summary: Path used to manage an instance of inferenceservice. description: >- The REST endpoint/path used to list and create zero or more `InferenceService` entities. This path contains a `GET` and `POST` operation to perform the list and create tasks, respectively. @@ -483,7 +483,7 @@ paths: - $ref: "#/components/parameters/name" - $ref: "#/components/parameters/externalID" - $ref: "#/components/parameters/parentResourceID" - "/api/model_registry/v1alpha1/inference_services/{inferenceserviceId}": + "/api/model_registry/v1alpha2/inference_services/{inferenceserviceId}": summary: Path used to manage a single InferenceService. description: >- The REST endpoint/path used to get, update, and delete single instances of an `InferenceService`. This path contains `GET`, `PUT`, and `DELETE` operations used to perform the get, update, and delete tasks, respectively. @@ -533,7 +533,7 @@ paths: type: string in: path required: true - /api/model_registry/v1alpha1/inference_services: + /api/model_registry/v1alpha2/inference_services: summary: Path used to manage the list of inferenceservices. description: >- The REST endpoint/path used to list and create zero or more `InferenceService` entities. This path contains a `GET` and `POST` operation to perform the list and create tasks, respectively. @@ -581,7 +581,7 @@ paths: operationId: createInferenceService summary: Create a InferenceService description: Creates a new instance of a `InferenceService`. - /api/model_registry/v1alpha1/serving_environment: + /api/model_registry/v1alpha2/serving_environment: summary: Path used to find a servingenvironment. description: >- The REST endpoint/path used to search for a `ServingEnvironment` entity. This path contains a `GET` operation to perform the find task. @@ -603,7 +603,7 @@ paths: parameters: - $ref: "#/components/parameters/name" - $ref: "#/components/parameters/externalID" - /api/model_registry/v1alpha1/serving_environments: + /api/model_registry/v1alpha2/serving_environments: summary: Path used to manage the list of servingenvironments. description: >- The REST endpoint/path used to list and create zero or more `ServingEnvironment` entities. This path contains a `GET` and `POST` operation to perform the list and create tasks, respectively. @@ -647,7 +647,7 @@ paths: operationId: createServingEnvironment summary: Create a ServingEnvironment description: Creates a new instance of a `ServingEnvironment`. - "/api/model_registry/v1alpha1/serving_environments/{servingenvironmentId}": + "/api/model_registry/v1alpha2/serving_environments/{servingenvironmentId}": summary: Path used to manage a single ServingEnvironment. description: >- The REST endpoint/path used to get, update, and delete single instances of an `ServingEnvironment`. This path contains `GET`, `PUT`, and `DELETE` operations used to perform the get, update, and delete tasks, respectively. @@ -697,7 +697,7 @@ paths: type: string in: path required: true - "/api/model_registry/v1alpha1/serving_environments/{servingenvironmentId}/inference_services": + "/api/model_registry/v1alpha2/serving_environments/{servingenvironmentId}/inference_services": summary: Path used to manage the list of `InferenceServices` for a `ServingEnvironment`. description: >- The REST endpoint/path used to list and create zero or more `InferenceService` entities for a `ServingEnvironment`. This path contains a `GET` and `POST` operation to perform the list and create tasks, respectively. @@ -754,7 +754,7 @@ paths: type: string in: path required: true - "/api/model_registry/v1alpha1/inference_services/{inferenceserviceId}/serves": + "/api/model_registry/v1alpha2/inference_services/{inferenceserviceId}/serves": summary: Path used to manage the list of `ServeModels` for a `InferenceService`. description: >- The REST endpoint/path used to list and create zero or more `ServeModel` entities for a `InferenceService`. This path contains a `GET` and `POST` operation to perform the list and create tasks, respectively. @@ -811,7 +811,7 @@ paths: type: string in: path required: true - "/api/model_registry/v1alpha1/inference_services/{inferenceserviceId}/model": + "/api/model_registry/v1alpha2/inference_services/{inferenceserviceId}/model": summary: Path used to manage a `RegisteredModel` associated with an `InferenceService`. description: >- The REST endpoint/path used to list the `RegisteredModel` entity for an `InferenceService`. This path contains a `GET` operation to perform the get task. @@ -837,7 +837,7 @@ paths: type: string in: path required: true - "/api/model_registry/v1alpha1/inference_services/{inferenceserviceId}/version": + "/api/model_registry/v1alpha2/inference_services/{inferenceserviceId}/version": summary: Path used to get the current `ModelVersion` associated with an `InferenceService`. description: >- The REST endpoint/path used to get the current `ModelVersion` entity for a `InferenceService`. This path contains a `GET` operation to perform the get task. @@ -863,7 +863,7 @@ paths: type: string in: path required: true - /api/model_registry/v1alpha1/model_version: + /api/model_registry/v1alpha2/model_version: summary: Path used to search for a modelversion. description: >- The REST endpoint/path used to search for a `ModelVersion` entity. This path contains a `GET` operation to perform the find task. @@ -1102,37 +1102,78 @@ components: - $ref: "#/components/schemas/MetadataStructValue" - $ref: "#/components/schemas/MetadataProtoValue" - $ref: "#/components/schemas/MetadataBoolValue" + 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' description: A value in properties. MetadataIntValue: description: An integer (int64) property value. type: object + required: + - metadataType + - int_value properties: int_value: format: int64 type: string + metadataType: + type: string + example: MetadataIntValue + default: MetadataIntValue MetadataDoubleValue: description: A double property value. type: object + required: + - metadataType + - double_value properties: double_value: format: double type: number + metadataType: + type: string + example: MetadataDoubleValue + default: MetadataDoubleValue MetadataStringValue: description: A string property value. type: object + required: + - metadataType + - string_value properties: string_value: type: string + metadataType: + type: string + example: MetadataStringValue + default: MetadataStringValue MetadataStructValue: description: A struct property value. type: object + required: + - metadataType + - struct_value properties: struct_value: description: Base64 encoded bytes for struct value type: string + metadataType: + type: string + example: MetadataStructValue + default: MetadataStructValue MetadataProtoValue: description: A proto property value. type: object + required: + - metadataType + - type + - proto_value properties: type: description: url describing proto value @@ -1140,12 +1181,23 @@ components: proto_value: description: Base64 encoded bytes for proto value type: string + metadataType: + type: string + example: MetadataProtoValue + default: MetadataProtoValue MetadataBoolValue: description: A bool property value. type: object + required: + - metadataType + - bool_value properties: bool_value: type: boolean + metadataType: + type: string + example: MetadataBoolValue + default: MetadataBoolValue BaseResource: allOf: - $ref: "#/components/schemas/BaseResourceCreate" diff --git a/docs/logical_model.md b/docs/logical_model.md index 5e6afbe29..9f6ea57da 100644 --- a/docs/logical_model.md +++ b/docs/logical_model.md @@ -87,7 +87,7 @@ resulting in: ``` curl --silent -X 'GET' \ - "$MR_HOSTNAME/api/model_registry/v1alpha1/registered_models/1" \ + "$MR_HOSTNAME/api/model_registry/v1alpha2/registered_models/1" \ -H 'accept: application/json' | jq { "createTimeSinceEpoch": "1707765353963", @@ -99,7 +99,7 @@ curl --silent -X 'GET' \ } curl --silent -X 'GET' \ - "$MR_HOSTNAME/api/model_registry/v1alpha1/registered_models/1/versions?pageSize=100&orderBy=ID&sortOrder=DESC&nextPageToken=" \ + "$MR_HOSTNAME/api/model_registry/v1alpha2/registered_models/1/versions?pageSize=100&orderBy=ID&sortOrder=DESC&nextPageToken=" \ -H 'accept: application/json' | jq { "items": [ @@ -120,7 +120,7 @@ curl --silent -X 'GET' \ } curl --silent -X 'GET' \ - "$MR_HOSTNAME/api/model_registry/v1alpha1/model_versions/2/artifacts" \ + "$MR_HOSTNAME/api/model_registry/v1alpha2/model_versions/2/artifacts" \ -H 'accept: application/json' | jq { "items": [ @@ -167,7 +167,7 @@ resulting in: ``` curl --silent -X 'GET' \ - "$MR_HOSTNAME/api/model_registry/v1alpha1/registered_models/3" \ + "$MR_HOSTNAME/api/model_registry/v1alpha2/registered_models/3" \ -H 'accept: application/json' | jq { "createTimeSinceEpoch": "1707765756856", @@ -179,7 +179,7 @@ curl --silent -X 'GET' \ } curl --silent -X 'GET' \ - "$MR_HOSTNAME/api/model_registry/v1alpha1/registered_models/3/versions?pageSize=100&orderBy=ID&sortOrder=DESC&nextPageToken=" \ + "$MR_HOSTNAME/api/model_registry/v1alpha2/registered_models/3/versions?pageSize=100&orderBy=ID&sortOrder=DESC&nextPageToken=" \ -H 'accept: application/json' | jq { "items": [ @@ -200,7 +200,7 @@ curl --silent -X 'GET' \ } curl --silent -X 'GET' \ - "$MR_HOSTNAME/api/model_registry/v1alpha1/model_versions/4/artifacts" \ + "$MR_HOSTNAME/api/model_registry/v1alpha2/model_versions/4/artifacts" \ -H 'accept: application/json' | jq { "items": [ @@ -247,7 +247,7 @@ resulting in: ``` curl --silent -X 'GET' \ - "$MR_HOSTNAME/api/model_registry/v1alpha1/registered_models/5" \ + "$MR_HOSTNAME/api/model_registry/v1alpha2/registered_models/5" \ -H 'accept: application/json' | jq { "createTimeSinceEpoch": "1707765990857", @@ -259,7 +259,7 @@ curl --silent -X 'GET' \ } curl --silent -X 'GET' \ - "$MR_HOSTNAME/api/model_registry/v1alpha1/registered_models/5/versions?pageSize=100&orderBy=ID&sortOrder=DESC&nextPageToken=" \ + "$MR_HOSTNAME/api/model_registry/v1alpha2/registered_models/5/versions?pageSize=100&orderBy=ID&sortOrder=DESC&nextPageToken=" \ -H 'accept: application/json' | jq { "items": [ @@ -290,7 +290,7 @@ curl --silent -X 'GET' \ } curl --silent -X 'GET' \ - "$MR_HOSTNAME/api/model_registry/v1alpha1/model_versions/6/artifacts" \ + "$MR_HOSTNAME/api/model_registry/v1alpha2/model_versions/6/artifacts" \ -H 'accept: application/json' | jq { "items": [ @@ -362,7 +362,7 @@ resulting in: ``` curl --silent -X 'GET' \ - "$MR_HOSTNAME/api/model_registry/v1alpha1/registered_models/7" \ + "$MR_HOSTNAME/api/model_registry/v1alpha2/registered_models/7" \ -H 'accept: application/json' | jq { "createTimeSinceEpoch": "1707766117250", @@ -374,7 +374,7 @@ curl --silent -X 'GET' \ } curl --silent -X 'GET' \ - "$MR_HOSTNAME/api/model_registry/v1alpha1/registered_models/7/versions?pageSize=100&orderBy=ID&sortOrder=DESC&nextPageToken=" \ + "$MR_HOSTNAME/api/model_registry/v1alpha2/registered_models/7/versions?pageSize=100&orderBy=ID&sortOrder=DESC&nextPageToken=" \ -H 'accept: application/json' | jq { "items": [ @@ -395,7 +395,7 @@ curl --silent -X 'GET' \ } curl --silent -X 'GET' \ - "$MR_HOSTNAME/api/model_registry/v1alpha1/model_versions/8/artifacts" \ + "$MR_HOSTNAME/api/model_registry/v1alpha2/model_versions/8/artifacts" \ -H 'accept: application/json' | jq { "items": [ diff --git a/internal/converter/generated/openapi_converter.gen.go b/internal/converter/generated/openapi_converter.gen.go index eaa00c46e..e313815b9 100755 --- a/internal/converter/generated/openapi_converter.gen.go +++ b/internal/converter/generated/openapi_converter.gen.go @@ -703,12 +703,8 @@ func (c *OpenAPIConverterImpl) pOpenapiMetadataBoolValueToPOpenapiMetadataBoolVa var pOpenapiMetadataBoolValue *openapi.MetadataBoolValue if source != nil { var openapiMetadataBoolValue openapi.MetadataBoolValue - var pBool *bool - if (*source).BoolValue != nil { - xbool := *(*source).BoolValue - pBool = &xbool - } - openapiMetadataBoolValue.BoolValue = pBool + openapiMetadataBoolValue.BoolValue = (*source).BoolValue + openapiMetadataBoolValue.MetadataType = (*source).MetadataType pOpenapiMetadataBoolValue = &openapiMetadataBoolValue } return pOpenapiMetadataBoolValue @@ -717,12 +713,8 @@ func (c *OpenAPIConverterImpl) pOpenapiMetadataDoubleValueToPOpenapiMetadataDoub var pOpenapiMetadataDoubleValue *openapi.MetadataDoubleValue if source != nil { var openapiMetadataDoubleValue openapi.MetadataDoubleValue - var pFloat64 *float64 - if (*source).DoubleValue != nil { - xfloat64 := *(*source).DoubleValue - pFloat64 = &xfloat64 - } - openapiMetadataDoubleValue.DoubleValue = pFloat64 + openapiMetadataDoubleValue.DoubleValue = (*source).DoubleValue + openapiMetadataDoubleValue.MetadataType = (*source).MetadataType pOpenapiMetadataDoubleValue = &openapiMetadataDoubleValue } return pOpenapiMetadataDoubleValue @@ -731,12 +723,8 @@ func (c *OpenAPIConverterImpl) pOpenapiMetadataIntValueToPOpenapiMetadataIntValu var pOpenapiMetadataIntValue *openapi.MetadataIntValue if source != nil { var openapiMetadataIntValue openapi.MetadataIntValue - var pString *string - if (*source).IntValue != nil { - xstring := *(*source).IntValue - pString = &xstring - } - openapiMetadataIntValue.IntValue = pString + openapiMetadataIntValue.IntValue = (*source).IntValue + openapiMetadataIntValue.MetadataType = (*source).MetadataType pOpenapiMetadataIntValue = &openapiMetadataIntValue } return pOpenapiMetadataIntValue @@ -745,18 +733,9 @@ func (c *OpenAPIConverterImpl) pOpenapiMetadataProtoValueToPOpenapiMetadataProto var pOpenapiMetadataProtoValue *openapi.MetadataProtoValue if source != nil { var openapiMetadataProtoValue openapi.MetadataProtoValue - var pString *string - if (*source).Type != nil { - xstring := *(*source).Type - pString = &xstring - } - openapiMetadataProtoValue.Type = pString - var pString2 *string - if (*source).ProtoValue != nil { - xstring2 := *(*source).ProtoValue - pString2 = &xstring2 - } - openapiMetadataProtoValue.ProtoValue = pString2 + openapiMetadataProtoValue.Type = (*source).Type + openapiMetadataProtoValue.ProtoValue = (*source).ProtoValue + openapiMetadataProtoValue.MetadataType = (*source).MetadataType pOpenapiMetadataProtoValue = &openapiMetadataProtoValue } return pOpenapiMetadataProtoValue @@ -765,12 +744,8 @@ func (c *OpenAPIConverterImpl) pOpenapiMetadataStringValueToPOpenapiMetadataStri var pOpenapiMetadataStringValue *openapi.MetadataStringValue if source != nil { var openapiMetadataStringValue openapi.MetadataStringValue - var pString *string - if (*source).StringValue != nil { - xstring := *(*source).StringValue - pString = &xstring - } - openapiMetadataStringValue.StringValue = pString + openapiMetadataStringValue.StringValue = (*source).StringValue + openapiMetadataStringValue.MetadataType = (*source).MetadataType pOpenapiMetadataStringValue = &openapiMetadataStringValue } return pOpenapiMetadataStringValue @@ -779,12 +754,8 @@ func (c *OpenAPIConverterImpl) pOpenapiMetadataStructValueToPOpenapiMetadataStru var pOpenapiMetadataStructValue *openapi.MetadataStructValue if source != nil { var openapiMetadataStructValue openapi.MetadataStructValue - var pString *string - if (*source).StructValue != nil { - xstring := *(*source).StructValue - pString = &xstring - } - openapiMetadataStructValue.StructValue = pString + openapiMetadataStructValue.StructValue = (*source).StructValue + openapiMetadataStructValue.MetadataType = (*source).MetadataType pOpenapiMetadataStructValue = &openapiMetadataStructValue } return pOpenapiMetadataStructValue diff --git a/internal/converter/mlmd_converter_util_test.go b/internal/converter/mlmd_converter_util_test.go index 5eddc08aa..91f44fee0 100644 --- a/internal/converter/mlmd_converter_util_test.go +++ b/internal/converter/mlmd_converter_util_test.go @@ -66,7 +66,7 @@ func TestMetadataValueBool(t *testing.T) { data := make(map[string]openapi.MetadataValue) key := "my bool" mdValue := true - data[key] = openapi.MetadataBoolValueAsMetadataValue(&openapi.MetadataBoolValue{BoolValue: &mdValue}) + data[key] = openapi.MetadataBoolValueAsMetadataValue(NewMetadataBoolValue(mdValue)) roundTripAndAssert(t, data, key) } @@ -75,7 +75,7 @@ func TestMetadataValueInt(t *testing.T) { data := make(map[string]openapi.MetadataValue) key := "my int" mdValue := "987" - data[key] = openapi.MetadataIntValueAsMetadataValue(&openapi.MetadataIntValue{IntValue: &mdValue}) + data[key] = openapi.MetadataIntValueAsMetadataValue(NewMetadataIntValue(mdValue)) roundTripAndAssert(t, data, key) } @@ -84,7 +84,7 @@ func TestMetadataValueIntFailure(t *testing.T) { data := make(map[string]openapi.MetadataValue) key := "my int" mdValue := "not a number" - data[key] = openapi.MetadataIntValueAsMetadataValue(&openapi.MetadataIntValue{IntValue: &mdValue}) + data[key] = openapi.MetadataIntValueAsMetadataValue(NewMetadataIntValue(mdValue)) assertion := setup(t) asGRPC, err := MapOpenAPICustomProperties(&data) @@ -97,7 +97,7 @@ func TestMetadataValueDouble(t *testing.T) { data := make(map[string]openapi.MetadataValue) key := "my double" mdValue := 3.1415 - data[key] = openapi.MetadataDoubleValueAsMetadataValue(&openapi.MetadataDoubleValue{DoubleValue: &mdValue}) + data[key] = openapi.MetadataDoubleValueAsMetadataValue(NewMetadataDoubleValue(mdValue)) roundTripAndAssert(t, data, key) } @@ -106,7 +106,7 @@ func TestMetadataValueString(t *testing.T) { data := make(map[string]openapi.MetadataValue) key := "my string" mdValue := "Hello, World!" - data[key] = openapi.MetadataStringValueAsMetadataValue(&openapi.MetadataStringValue{StringValue: &mdValue}) + data[key] = openapi.MetadataStringValueAsMetadataValue(NewMetadataStringValue(mdValue)) roundTripAndAssert(t, data, key) } @@ -123,7 +123,7 @@ func TestMetadataValueStruct(t *testing.T) { t.Error(err) } b64 := base64.StdEncoding.EncodeToString(asJSON) - data[key] = openapi.MetadataStructValueAsMetadataValue(&openapi.MetadataStructValue{StructValue: &b64}) + data[key] = openapi.MetadataStructValueAsMetadataValue(NewMetadataStructValue(b64)) roundTripAndAssert(t, data, key) } @@ -141,10 +141,7 @@ func TestMetadataValueProtoUnsupported(t *testing.T) { } b64 := base64.StdEncoding.EncodeToString(asJSON) typeDef := "map[string]openapi.MetadataValue" - data[key] = openapi.MetadataProtoValueAsMetadataValue(&openapi.MetadataProtoValue{ - Type: &typeDef, - ProtoValue: &b64, - }) + data[key] = openapi.MetadataProtoValueAsMetadataValue(NewMetadataProtoValue(typeDef, b64)) assertion := setup(t) asGRPC, err := MapOpenAPICustomProperties(&data) diff --git a/internal/converter/mlmd_openapi_converter_util.go b/internal/converter/mlmd_openapi_converter_util.go index 4dec4f502..3c3bc4e41 100644 --- a/internal/converter/mlmd_openapi_converter_util.go +++ b/internal/converter/mlmd_openapi_converter_util.go @@ -4,6 +4,7 @@ import ( "encoding/base64" "encoding/json" "fmt" + "strconv" "strings" "github.com/kubeflow/model-registry/internal/constants" @@ -11,6 +12,43 @@ import ( "github.com/kubeflow/model-registry/pkg/openapi" ) +func NewMetadataStringValue(value string) *openapi.MetadataStringValue { + result := openapi.NewMetadataStringValueWithDefaults() + result.StringValue = value + return result +} + +func NewMetadataBoolValue(value bool) *openapi.MetadataBoolValue { + result := openapi.NewMetadataBoolValueWithDefaults() + result.BoolValue = value + return result +} + +func NewMetadataDoubleValue(value float64) *openapi.MetadataDoubleValue { + result := openapi.NewMetadataDoubleValueWithDefaults() + result.DoubleValue = value + return result +} + +func NewMetadataIntValue(value string) *openapi.MetadataIntValue { + result := openapi.NewMetadataIntValueWithDefaults() + result.IntValue = value + return result +} + +func NewMetadataStructValue(value string) *openapi.MetadataStructValue { + result := openapi.NewMetadataStructValueWithDefaults() + result.StructValue = value + return result +} + +func NewMetadataProtoValue(typeDef string, value string) *openapi.MetadataProtoValue { + result := openapi.NewMetadataProtoValueWithDefaults() + result.Type = typeDef + result.ProtoValue = value + return result +} + // MapMLMDCustomProperties maps MLMD custom properties model to OpenAPI one func MapMLMDCustomProperties(source map[string]*proto.Value) (map[string]openapi.MetadataValue, error) { data := make(map[string]openapi.MetadataValue) @@ -21,21 +59,13 @@ func MapMLMDCustomProperties(source map[string]*proto.Value) (map[string]openapi switch typedValue := v.Value.(type) { case *proto.Value_BoolValue: - customValue.MetadataBoolValue = &openapi.MetadataBoolValue{ - BoolValue: &typedValue.BoolValue, - } + customValue.MetadataBoolValue = NewMetadataBoolValue(typedValue.BoolValue) case *proto.Value_IntValue: - customValue.MetadataIntValue = &openapi.MetadataIntValue{ - IntValue: Int64ToString(&typedValue.IntValue), - } + customValue.MetadataIntValue = NewMetadataIntValue(strconv.FormatInt(typedValue.IntValue, 10)) case *proto.Value_DoubleValue: - customValue.MetadataDoubleValue = &openapi.MetadataDoubleValue{ - DoubleValue: &typedValue.DoubleValue, - } + customValue.MetadataDoubleValue = NewMetadataDoubleValue(typedValue.DoubleValue) case *proto.Value_StringValue: - customValue.MetadataStringValue = &openapi.MetadataStringValue{ - StringValue: &typedValue.StringValue, - } + customValue.MetadataStringValue = NewMetadataStringValue(typedValue.StringValue) case *proto.Value_StructValue: sv := typedValue.StructValue asMap := sv.AsMap() @@ -44,9 +74,7 @@ func MapMLMDCustomProperties(source map[string]*proto.Value) (map[string]openapi return nil, err } b64 := base64.StdEncoding.EncodeToString(asJSON) - customValue.MetadataStructValue = &openapi.MetadataStructValue{ - StructValue: &b64, - } + customValue.MetadataStructValue = NewMetadataStructValue(b64) default: return nil, fmt.Errorf("type mapping not found for %s:%v", key, v) } diff --git a/internal/converter/openapi_mlmd_converter_util.go b/internal/converter/openapi_mlmd_converter_util.go index 5f730ea97..4edd1d158 100644 --- a/internal/converter/openapi_mlmd_converter_util.go +++ b/internal/converter/openapi_mlmd_converter_util.go @@ -60,23 +60,23 @@ func MapOpenAPICustomProperties(source *map[string]openapi.MetadataValue) (map[s switch { // bool value case v.MetadataBoolValue != nil: - value.Value = &proto.Value_BoolValue{BoolValue: *v.MetadataBoolValue.BoolValue} + value.Value = &proto.Value_BoolValue{BoolValue: v.MetadataBoolValue.BoolValue} // int value case v.MetadataIntValue != nil: - intValue, err := StringToInt64(v.MetadataIntValue.IntValue) + intValue, err := StringToInt64(&v.MetadataIntValue.IntValue) if err != nil { return nil, fmt.Errorf("unable to decode as int64 %w for key %s", err, key) } value.Value = &proto.Value_IntValue{IntValue: *intValue} // double value case v.MetadataDoubleValue != nil: - value.Value = &proto.Value_DoubleValue{DoubleValue: *v.MetadataDoubleValue.DoubleValue} + value.Value = &proto.Value_DoubleValue{DoubleValue: v.MetadataDoubleValue.DoubleValue} // string value case v.MetadataStringValue != nil: - value.Value = &proto.Value_StringValue{StringValue: *v.MetadataStringValue.StringValue} + value.Value = &proto.Value_StringValue{StringValue: v.MetadataStringValue.StringValue} // struct value case v.MetadataStructValue != nil: - data, err := base64.StdEncoding.DecodeString(*v.MetadataStructValue.StructValue) + data, err := base64.StdEncoding.DecodeString(v.MetadataStructValue.StructValue) if err != nil { return nil, fmt.Errorf("unable to decode %w for key %s", err, key) } diff --git a/internal/server/openapi/api_model_registry_service.go b/internal/server/openapi/api_model_registry_service.go index ae8c15f7b..d42b46b61 100644 --- a/internal/server/openapi/api_model_registry_service.go +++ b/internal/server/openapi/api_model_registry_service.go @@ -3,7 +3,7 @@ * * REST API for Model Registry to create and manage ML model metadata * - * API version: v1alpha1 + * API version: v1alpha2 * Generated by: OpenAPI Generator (https://openapi-generator.tech) */ @@ -54,177 +54,177 @@ func (c *ModelRegistryServiceAPIController) Routes() Routes { return Routes{ "CreateEnvironmentInferenceService": Route{ strings.ToUpper("Post"), - "/api/model_registry/v1alpha1/serving_environments/{servingenvironmentId}/inference_services", + "/api/model_registry/v1alpha2/serving_environments/{servingenvironmentId}/inference_services", c.CreateEnvironmentInferenceService, }, "CreateInferenceService": Route{ strings.ToUpper("Post"), - "/api/model_registry/v1alpha1/inference_services", + "/api/model_registry/v1alpha2/inference_services", c.CreateInferenceService, }, "CreateInferenceServiceServe": Route{ strings.ToUpper("Post"), - "/api/model_registry/v1alpha1/inference_services/{inferenceserviceId}/serves", + "/api/model_registry/v1alpha2/inference_services/{inferenceserviceId}/serves", c.CreateInferenceServiceServe, }, "CreateModelArtifact": Route{ strings.ToUpper("Post"), - "/api/model_registry/v1alpha1/model_artifacts", + "/api/model_registry/v1alpha2/model_artifacts", c.CreateModelArtifact, }, "CreateModelVersion": Route{ strings.ToUpper("Post"), - "/api/model_registry/v1alpha1/model_versions", + "/api/model_registry/v1alpha2/model_versions", c.CreateModelVersion, }, "CreateModelVersionArtifact": Route{ strings.ToUpper("Post"), - "/api/model_registry/v1alpha1/model_versions/{modelversionId}/artifacts", + "/api/model_registry/v1alpha2/model_versions/{modelversionId}/artifacts", c.CreateModelVersionArtifact, }, "CreateRegisteredModel": Route{ strings.ToUpper("Post"), - "/api/model_registry/v1alpha1/registered_models", + "/api/model_registry/v1alpha2/registered_models", c.CreateRegisteredModel, }, "CreateRegisteredModelVersion": Route{ strings.ToUpper("Post"), - "/api/model_registry/v1alpha1/registered_models/{registeredmodelId}/versions", + "/api/model_registry/v1alpha2/registered_models/{registeredmodelId}/versions", c.CreateRegisteredModelVersion, }, "CreateServingEnvironment": Route{ strings.ToUpper("Post"), - "/api/model_registry/v1alpha1/serving_environments", + "/api/model_registry/v1alpha2/serving_environments", c.CreateServingEnvironment, }, "FindInferenceService": Route{ strings.ToUpper("Get"), - "/api/model_registry/v1alpha1/inference_service", + "/api/model_registry/v1alpha2/inference_service", c.FindInferenceService, }, "FindModelArtifact": Route{ strings.ToUpper("Get"), - "/api/model_registry/v1alpha1/model_artifact", + "/api/model_registry/v1alpha2/model_artifact", c.FindModelArtifact, }, "FindModelVersion": Route{ strings.ToUpper("Get"), - "/api/model_registry/v1alpha1/model_version", + "/api/model_registry/v1alpha2/model_version", c.FindModelVersion, }, "FindRegisteredModel": Route{ strings.ToUpper("Get"), - "/api/model_registry/v1alpha1/registered_model", + "/api/model_registry/v1alpha2/registered_model", c.FindRegisteredModel, }, "FindServingEnvironment": Route{ strings.ToUpper("Get"), - "/api/model_registry/v1alpha1/serving_environment", + "/api/model_registry/v1alpha2/serving_environment", c.FindServingEnvironment, }, "GetEnvironmentInferenceServices": Route{ strings.ToUpper("Get"), - "/api/model_registry/v1alpha1/serving_environments/{servingenvironmentId}/inference_services", + "/api/model_registry/v1alpha2/serving_environments/{servingenvironmentId}/inference_services", c.GetEnvironmentInferenceServices, }, "GetInferenceService": Route{ strings.ToUpper("Get"), - "/api/model_registry/v1alpha1/inference_services/{inferenceserviceId}", + "/api/model_registry/v1alpha2/inference_services/{inferenceserviceId}", c.GetInferenceService, }, "GetInferenceServiceModel": Route{ strings.ToUpper("Get"), - "/api/model_registry/v1alpha1/inference_services/{inferenceserviceId}/model", + "/api/model_registry/v1alpha2/inference_services/{inferenceserviceId}/model", c.GetInferenceServiceModel, }, "GetInferenceServiceServes": Route{ strings.ToUpper("Get"), - "/api/model_registry/v1alpha1/inference_services/{inferenceserviceId}/serves", + "/api/model_registry/v1alpha2/inference_services/{inferenceserviceId}/serves", c.GetInferenceServiceServes, }, "GetInferenceServiceVersion": Route{ strings.ToUpper("Get"), - "/api/model_registry/v1alpha1/inference_services/{inferenceserviceId}/version", + "/api/model_registry/v1alpha2/inference_services/{inferenceserviceId}/version", c.GetInferenceServiceVersion, }, "GetInferenceServices": Route{ strings.ToUpper("Get"), - "/api/model_registry/v1alpha1/inference_services", + "/api/model_registry/v1alpha2/inference_services", c.GetInferenceServices, }, "GetModelArtifact": Route{ strings.ToUpper("Get"), - "/api/model_registry/v1alpha1/model_artifacts/{modelartifactId}", + "/api/model_registry/v1alpha2/model_artifacts/{modelartifactId}", c.GetModelArtifact, }, "GetModelArtifacts": Route{ strings.ToUpper("Get"), - "/api/model_registry/v1alpha1/model_artifacts", + "/api/model_registry/v1alpha2/model_artifacts", c.GetModelArtifacts, }, "GetModelVersion": Route{ strings.ToUpper("Get"), - "/api/model_registry/v1alpha1/model_versions/{modelversionId}", + "/api/model_registry/v1alpha2/model_versions/{modelversionId}", c.GetModelVersion, }, "GetModelVersionArtifacts": Route{ strings.ToUpper("Get"), - "/api/model_registry/v1alpha1/model_versions/{modelversionId}/artifacts", + "/api/model_registry/v1alpha2/model_versions/{modelversionId}/artifacts", c.GetModelVersionArtifacts, }, "GetModelVersions": Route{ strings.ToUpper("Get"), - "/api/model_registry/v1alpha1/model_versions", + "/api/model_registry/v1alpha2/model_versions", c.GetModelVersions, }, "GetRegisteredModel": Route{ strings.ToUpper("Get"), - "/api/model_registry/v1alpha1/registered_models/{registeredmodelId}", + "/api/model_registry/v1alpha2/registered_models/{registeredmodelId}", c.GetRegisteredModel, }, "GetRegisteredModelVersions": Route{ strings.ToUpper("Get"), - "/api/model_registry/v1alpha1/registered_models/{registeredmodelId}/versions", + "/api/model_registry/v1alpha2/registered_models/{registeredmodelId}/versions", c.GetRegisteredModelVersions, }, "GetRegisteredModels": Route{ strings.ToUpper("Get"), - "/api/model_registry/v1alpha1/registered_models", + "/api/model_registry/v1alpha2/registered_models", c.GetRegisteredModels, }, "GetServingEnvironment": Route{ strings.ToUpper("Get"), - "/api/model_registry/v1alpha1/serving_environments/{servingenvironmentId}", + "/api/model_registry/v1alpha2/serving_environments/{servingenvironmentId}", c.GetServingEnvironment, }, "GetServingEnvironments": Route{ strings.ToUpper("Get"), - "/api/model_registry/v1alpha1/serving_environments", + "/api/model_registry/v1alpha2/serving_environments", c.GetServingEnvironments, }, "UpdateInferenceService": Route{ strings.ToUpper("Patch"), - "/api/model_registry/v1alpha1/inference_services/{inferenceserviceId}", + "/api/model_registry/v1alpha2/inference_services/{inferenceserviceId}", c.UpdateInferenceService, }, "UpdateModelArtifact": Route{ strings.ToUpper("Patch"), - "/api/model_registry/v1alpha1/model_artifacts/{modelartifactId}", + "/api/model_registry/v1alpha2/model_artifacts/{modelartifactId}", c.UpdateModelArtifact, }, "UpdateModelVersion": Route{ strings.ToUpper("Patch"), - "/api/model_registry/v1alpha1/model_versions/{modelversionId}", + "/api/model_registry/v1alpha2/model_versions/{modelversionId}", c.UpdateModelVersion, }, "UpdateRegisteredModel": Route{ strings.ToUpper("Patch"), - "/api/model_registry/v1alpha1/registered_models/{registeredmodelId}", + "/api/model_registry/v1alpha2/registered_models/{registeredmodelId}", c.UpdateRegisteredModel, }, "UpdateServingEnvironment": Route{ strings.ToUpper("Patch"), - "/api/model_registry/v1alpha1/serving_environments/{servingenvironmentId}", + "/api/model_registry/v1alpha2/serving_environments/{servingenvironmentId}", c.UpdateServingEnvironment, }, } diff --git a/internal/server/openapi/type_asserts.go b/internal/server/openapi/type_asserts.go index 80ad5e98b..9907fbc91 100644 --- a/internal/server/openapi/type_asserts.go +++ b/internal/server/openapi/type_asserts.go @@ -328,6 +328,16 @@ func AssertInferenceServiceUpdateConstraints(obj model.InferenceServiceUpdate) e // AssertMetadataBoolValueRequired checks if the required fields are not zero-ed func AssertMetadataBoolValueRequired(obj model.MetadataBoolValue) error { + elements := map[string]interface{}{ + "bool_value": obj.BoolValue, + "metadataType": obj.MetadataType, + } + for name, el := range elements { + if isZero := IsZeroValue(el); isZero { + return &RequiredError{Field: name} + } + } + return nil } @@ -338,6 +348,16 @@ func AssertMetadataBoolValueConstraints(obj model.MetadataBoolValue) error { // AssertMetadataDoubleValueRequired checks if the required fields are not zero-ed func AssertMetadataDoubleValueRequired(obj model.MetadataDoubleValue) error { + elements := map[string]interface{}{ + "double_value": obj.DoubleValue, + "metadataType": obj.MetadataType, + } + for name, el := range elements { + if isZero := IsZeroValue(el); isZero { + return &RequiredError{Field: name} + } + } + return nil } @@ -348,6 +368,16 @@ func AssertMetadataDoubleValueConstraints(obj model.MetadataDoubleValue) error { // AssertMetadataIntValueRequired checks if the required fields are not zero-ed func AssertMetadataIntValueRequired(obj model.MetadataIntValue) error { + elements := map[string]interface{}{ + "int_value": obj.IntValue, + "metadataType": obj.MetadataType, + } + for name, el := range elements { + if isZero := IsZeroValue(el); isZero { + return &RequiredError{Field: name} + } + } + return nil } @@ -358,6 +388,17 @@ func AssertMetadataIntValueConstraints(obj model.MetadataIntValue) error { // AssertMetadataProtoValueRequired checks if the required fields are not zero-ed func AssertMetadataProtoValueRequired(obj model.MetadataProtoValue) error { + elements := map[string]interface{}{ + "type": obj.Type, + "proto_value": obj.ProtoValue, + "metadataType": obj.MetadataType, + } + for name, el := range elements { + if isZero := IsZeroValue(el); isZero { + return &RequiredError{Field: name} + } + } + return nil } @@ -368,6 +409,16 @@ func AssertMetadataProtoValueConstraints(obj model.MetadataProtoValue) error { // AssertMetadataStringValueRequired checks if the required fields are not zero-ed func AssertMetadataStringValueRequired(obj model.MetadataStringValue) error { + elements := map[string]interface{}{ + "string_value": obj.StringValue, + "metadataType": obj.MetadataType, + } + for name, el := range elements { + if isZero := IsZeroValue(el); isZero { + return &RequiredError{Field: name} + } + } + return nil } @@ -378,6 +429,16 @@ func AssertMetadataStringValueConstraints(obj model.MetadataStringValue) error { // AssertMetadataStructValueRequired checks if the required fields are not zero-ed func AssertMetadataStructValueRequired(obj model.MetadataStructValue) error { + elements := map[string]interface{}{ + "struct_value": obj.StructValue, + "metadataType": obj.MetadataType, + } + for name, el := range elements { + if isZero := IsZeroValue(el); isZero { + return &RequiredError{Field: name} + } + } + return nil } @@ -388,6 +449,23 @@ func AssertMetadataStructValueConstraints(obj model.MetadataStructValue) error { // AssertMetadataValueRequired checks if the required fields are not zero-ed func AssertMetadataValueRequired(obj model.MetadataValue) error { + // FIXME(manual): Wrong autogenerated logic, just one elem should be non-zero. + // elements := map[string]interface{}{ + // "int_value": obj.IntValue, + // "metadataType": obj.MetadataType, + // "double_value": obj.DoubleValue, + // "string_value": obj.StringValue, + // "struct_value": obj.StructValue, + // "type": obj.Type, + // "proto_value": obj.ProtoValue, + // "bool_value": obj.BoolValue, + // } + // for name, el := range elements { + // if isZero := IsZeroValue(el); isZero { + // return &RequiredError{Field: name} + // } + // } + return nil } diff --git a/patches/type_asserts.patch b/patches/type_asserts.patch index c7e5d9464..bcb27b81e 100644 --- a/patches/type_asserts.patch +++ b/patches/type_asserts.patch @@ -1,5 +1,5 @@ diff --git a/internal/server/openapi/type_asserts.go b/internal/server/openapi/type_asserts.go -index 6e8ecb1..6d08bbb 100644 +index b001018..9907fbc 100644 --- a/internal/server/openapi/type_asserts.go +++ b/internal/server/openapi/type_asserts.go @@ -18,15 +18,15 @@ import ( @@ -27,3 +27,41 @@ index 6e8ecb1..6d08bbb 100644 return nil } +@@ -449,21 +449,22 @@ func AssertMetadataStructValueConstraints(obj model.MetadataStructValue) error { + + // AssertMetadataValueRequired checks if the required fields are not zero-ed + func AssertMetadataValueRequired(obj model.MetadataValue) error { +- elements := map[string]interface{}{ +- "int_value": obj.IntValue, +- "metadataType": obj.MetadataType, +- "double_value": obj.DoubleValue, +- "string_value": obj.StringValue, +- "struct_value": obj.StructValue, +- "type": obj.Type, +- "proto_value": obj.ProtoValue, +- "bool_value": obj.BoolValue, +- } +- for name, el := range elements { +- if isZero := IsZeroValue(el); isZero { +- return &RequiredError{Field: name} +- } +- } ++ // FIXME(manual): Wrong autogenerated logic, just one elem should be non-zero. ++ // elements := map[string]interface{}{ ++ // "int_value": obj.IntValue, ++ // "metadataType": obj.MetadataType, ++ // "double_value": obj.DoubleValue, ++ // "string_value": obj.StringValue, ++ // "struct_value": obj.StructValue, ++ // "type": obj.Type, ++ // "proto_value": obj.ProtoValue, ++ // "bool_value": obj.BoolValue, ++ // } ++ // for name, el := range elements { ++ // if isZero := IsZeroValue(el); isZero { ++ // return &RequiredError{Field: name} ++ // } ++ // } + + return nil + } diff --git a/pkg/core/core_test.go b/pkg/core/core_test.go index c364101f8..8271fb050 100644 --- a/pkg/core/core_test.go +++ b/pkg/core/core_test.go @@ -120,9 +120,7 @@ func (suite *CoreTestSuite) registerModel(service api.ModelRegistryApi, override Description: &modelDescription, CustomProperties: &map[string]openapi.MetadataValue{ "owner": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &owner, - }, + MetadataStringValue: converter.NewMetadataStringValue(owner), }, }, } @@ -152,9 +150,7 @@ func (suite *CoreTestSuite) registerServingEnvironment(service api.ModelRegistry Description: &entityDescription, CustomProperties: &map[string]openapi.MetadataValue{ "owner": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &owner, - }, + MetadataStringValue: converter.NewMetadataStringValue(owner), }, }, } @@ -218,9 +214,7 @@ func (suite *CoreTestSuite) registerInferenceService(service api.ModelRegistryAp ServingEnvironmentId: servingEnvironmentId, CustomProperties: &map[string]openapi.MetadataValue{ "owner": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &owner, - }, + MetadataStringValue: converter.NewMetadataStringValue(owner), }, }, } @@ -570,9 +564,7 @@ func (suite *CoreTestSuite) TestCreateRegisteredModel() { State: &state, CustomProperties: &map[string]openapi.MetadataValue{ "owner": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &owner, - }, + MetadataStringValue: converter.NewMetadataStringValue(owner), }, }, } @@ -614,9 +606,7 @@ func (suite *CoreTestSuite) TestUpdateRegisteredModel() { ExternalID: &modelExternalId, CustomProperties: &map[string]openapi.MetadataValue{ "owner": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &owner, - }, + MetadataStringValue: converter.NewMetadataStringValue(owner), }, }, } @@ -640,9 +630,7 @@ func (suite *CoreTestSuite) TestUpdateRegisteredModel() { createdModel.ExternalID = &newModelExternalId (*createdModel.CustomProperties)["owner"] = openapi.MetadataValue{ - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &newOwner, - }, + MetadataStringValue: converter.NewMetadataStringValue(newOwner), } // update the model @@ -703,9 +691,7 @@ func (suite *CoreTestSuite) TestGetRegisteredModelById() { State: &state, CustomProperties: &map[string]openapi.MetadataValue{ "owner": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &owner, - }, + MetadataStringValue: converter.NewMetadataStringValue(owner), }, }, } @@ -1042,9 +1028,7 @@ func (suite *CoreTestSuite) TestUpdateModelVersion() { createdVersion.ExternalID = &newExternalId (*createdVersion.CustomProperties)["score"] = openapi.MetadataValue{ - MetadataDoubleValue: &openapi.MetadataDoubleValue{ - DoubleValue: &newScore, - }, + MetadataDoubleValue: converter.NewMetadataDoubleValue(newScore), } updatedVersion, err := service.UpsertModelVersion(createdVersion, ®isteredModelId) @@ -1119,9 +1103,7 @@ func (suite *CoreTestSuite) TestUpdateModelVersionFailure() { createdVersion.ExternalID = &newExternalId (*createdVersion.CustomProperties)["score"] = openapi.MetadataValue{ - MetadataDoubleValue: &openapi.MetadataDoubleValue{ - DoubleValue: &newScore, - }, + MetadataDoubleValue: converter.NewMetadataDoubleValue(newScore), } wrongId := "9999" @@ -1384,9 +1366,7 @@ func (suite *CoreTestSuite) TestCreateArtifact() { Description: &artifactDescription, CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, }, @@ -1401,7 +1381,7 @@ func (suite *CoreTestSuite) TestCreateArtifact() { suite.Equal(*state, *docArtifact.State) suite.Equal(artifactUri, *docArtifact.Uri) suite.Equal(artifactDescription, *docArtifact.Description) - suite.Equal(customString, *(*docArtifact.CustomProperties)["custom_string_prop"].MetadataStringValue.StringValue) + suite.Equal(customString, (*docArtifact.CustomProperties)["custom_string_prop"].MetadataStringValue.StringValue) } func (suite *CoreTestSuite) TestCreateArtifactFailure() { @@ -1417,9 +1397,7 @@ func (suite *CoreTestSuite) TestCreateArtifactFailure() { Uri: &artifactUri, CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, } @@ -1446,9 +1424,7 @@ func (suite *CoreTestSuite) TestUpdateArtifact() { Uri: &artifactUri, CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, }, @@ -1473,7 +1449,7 @@ func (suite *CoreTestSuite) TestUpdateArtifact() { suite.Equal(fmt.Sprintf("%s:%s", modelVersionId, *createdArtifact.DocArtifact.Name), *getById.Artifacts[0].Name) suite.Equal(string(newState), getById.Artifacts[0].State.String()) suite.Equal(*createdArtifact.DocArtifact.Uri, *getById.Artifacts[0].Uri) - suite.Equal(*(*createdArtifact.DocArtifact.CustomProperties)["custom_string_prop"].MetadataStringValue.StringValue, getById.Artifacts[0].CustomProperties["custom_string_prop"].GetStringValue()) + suite.Equal((*createdArtifact.DocArtifact.CustomProperties)["custom_string_prop"].MetadataStringValue.StringValue, getById.Artifacts[0].CustomProperties["custom_string_prop"].GetStringValue()) } func (suite *CoreTestSuite) TestUpdateArtifactFailure() { @@ -1489,9 +1465,7 @@ func (suite *CoreTestSuite) TestUpdateArtifactFailure() { Uri: &artifactUri, CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, }, @@ -1524,9 +1498,7 @@ func (suite *CoreTestSuite) TestGetArtifactById() { Uri: &artifactUri, CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, }, @@ -1543,7 +1515,7 @@ func (suite *CoreTestSuite) TestGetArtifactById() { suite.Equal(artifactName, *getById.DocArtifact.Name) suite.Equal(*state, *getById.DocArtifact.State) suite.Equal(artifactUri, *getById.DocArtifact.Uri) - suite.Equal(customString, *(*getById.DocArtifact.CustomProperties)["custom_string_prop"].MetadataStringValue.StringValue) + suite.Equal(customString, (*getById.DocArtifact.CustomProperties)["custom_string_prop"].MetadataStringValue.StringValue) suite.Equal(*createdArtifact, *getById, "artifacts returned during creation and on get by id should be equal") } @@ -1566,9 +1538,7 @@ func (suite *CoreTestSuite) TestGetArtifacts() { ExternalID: &artifactExtId, CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, }, @@ -1582,9 +1552,7 @@ func (suite *CoreTestSuite) TestGetArtifacts() { ExternalID: &secondArtifactExtId, CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, }, @@ -1632,9 +1600,7 @@ func (suite *CoreTestSuite) TestCreateModelArtifact() { StoragePath: apiutils.Of("bucket"), CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, }, &modelVersionId) @@ -1650,7 +1616,7 @@ func (suite *CoreTestSuite) TestCreateModelArtifact() { suite.Equal("1", *modelArtifact.ModelFormatVersion) suite.Equal("aws-connection-models", *modelArtifact.StorageKey) suite.Equal("bucket", *modelArtifact.StoragePath) - suite.Equal(customString, *(*modelArtifact.CustomProperties)["custom_string_prop"].MetadataStringValue.StringValue) + suite.Equal(customString, (*modelArtifact.CustomProperties)["custom_string_prop"].MetadataStringValue.StringValue) } func (suite *CoreTestSuite) TestCreateModelArtifactFailure() { @@ -1665,9 +1631,7 @@ func (suite *CoreTestSuite) TestCreateModelArtifactFailure() { Uri: &artifactUri, CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, } @@ -1693,9 +1657,7 @@ func (suite *CoreTestSuite) TestUpdateModelArtifact() { Uri: &artifactUri, CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, } @@ -1721,7 +1683,7 @@ func (suite *CoreTestSuite) TestUpdateModelArtifact() { suite.Equal(fmt.Sprintf("%s:%s", modelVersionId, *createdArtifact.Name), *getById.Artifacts[0].Name) suite.Equal(string(newState), getById.Artifacts[0].State.String()) suite.Equal(*createdArtifact.Uri, *getById.Artifacts[0].Uri) - suite.Equal(*(*createdArtifact.CustomProperties)["custom_string_prop"].MetadataStringValue.StringValue, getById.Artifacts[0].CustomProperties["custom_string_prop"].GetStringValue()) + suite.Equal((*createdArtifact.CustomProperties)["custom_string_prop"].MetadataStringValue.StringValue, getById.Artifacts[0].CustomProperties["custom_string_prop"].GetStringValue()) } func (suite *CoreTestSuite) TestUpdateModelArtifactFailure() { @@ -1736,9 +1698,7 @@ func (suite *CoreTestSuite) TestUpdateModelArtifactFailure() { Uri: &artifactUri, CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, } @@ -1760,9 +1720,7 @@ func (suite *CoreTestSuite) TestGetModelArtifactById() { Uri: &artifactUri, CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, } @@ -1780,7 +1738,7 @@ func (suite *CoreTestSuite) TestGetModelArtifactById() { suite.Equal(artifactName, *getById.Name) suite.Equal(*state, *getById.State) suite.Equal(artifactUri, *getById.Uri) - suite.Equal(customString, *(*getById.CustomProperties)["custom_string_prop"].MetadataStringValue.StringValue) + suite.Equal(customString, (*getById.CustomProperties)["custom_string_prop"].MetadataStringValue.StringValue) suite.Equal(*createdArtifact, *getById, "artifacts returned during creation and on get by id should be equal") } @@ -1798,9 +1756,7 @@ func (suite *CoreTestSuite) TestGetModelArtifactByParams() { ExternalID: &artifactExtId, CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, } @@ -1820,7 +1776,7 @@ func (suite *CoreTestSuite) TestGetModelArtifactByParams() { suite.Equal(artifactExtId, *getByName.ExternalID) suite.Equal(*state, *getByName.State) suite.Equal(artifactUri, *getByName.Uri) - suite.Equal(customString, *(*getByName.CustomProperties)["custom_string_prop"].MetadataStringValue.StringValue) + suite.Equal(customString, (*getByName.CustomProperties)["custom_string_prop"].MetadataStringValue.StringValue) suite.Equal(*createdArtifact, *getByName, "artifacts returned during creation and on get by name should be equal") @@ -1832,7 +1788,7 @@ func (suite *CoreTestSuite) TestGetModelArtifactByParams() { suite.Equal(artifactExtId, *getByExtId.ExternalID) suite.Equal(*state, *getByExtId.State) suite.Equal(artifactUri, *getByExtId.Uri) - suite.Equal(customString, *(*getByExtId.CustomProperties)["custom_string_prop"].MetadataStringValue.StringValue) + suite.Equal(customString, (*getByExtId.CustomProperties)["custom_string_prop"].MetadataStringValue.StringValue) suite.Equal(*createdArtifact, *getByExtId, "artifacts returned during creation and on get by ext id should be equal") } @@ -1850,9 +1806,7 @@ func (suite *CoreTestSuite) TestGetModelArtifactByEmptyParams() { ExternalID: &artifactExtId, CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, } @@ -1889,9 +1843,7 @@ func (suite *CoreTestSuite) TestGetModelArtifacts() { ExternalID: &artifactExtId, CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, } @@ -1906,9 +1858,7 @@ func (suite *CoreTestSuite) TestGetModelArtifacts() { ExternalID: &secondArtifactExtId, CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, } @@ -1923,9 +1873,7 @@ func (suite *CoreTestSuite) TestGetModelArtifacts() { ExternalID: &thirdArtifactExtId, CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, } @@ -1975,9 +1923,7 @@ func (suite *CoreTestSuite) TestCreateServingEnvironment() { Description: &entityDescription, CustomProperties: &map[string]openapi.MetadataValue{ "owner": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &owner, - }, + MetadataStringValue: converter.NewMetadataStringValue(owner), }, }, } @@ -2018,9 +1964,7 @@ func (suite *CoreTestSuite) TestUpdateServingEnvironment() { ExternalID: &entityExternalId, CustomProperties: &map[string]openapi.MetadataValue{ "owner": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &owner, - }, + MetadataStringValue: converter.NewMetadataStringValue(owner), }, }, } @@ -2044,9 +1988,7 @@ func (suite *CoreTestSuite) TestUpdateServingEnvironment() { createdEntity.ExternalID = &newExternalId (*createdEntity.CustomProperties)["owner"] = openapi.MetadataValue{ - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &newOwner, - }, + MetadataStringValue: converter.NewMetadataStringValue(newOwner), } // update the entity @@ -2105,9 +2047,7 @@ func (suite *CoreTestSuite) TestGetServingEnvironmentById() { ExternalID: &entityExternalId, CustomProperties: &map[string]openapi.MetadataValue{ "owner": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &owner, - }, + MetadataStringValue: converter.NewMetadataStringValue(owner), }, }, } @@ -2375,9 +2315,7 @@ func (suite *CoreTestSuite) TestCreateInferenceService() { DesiredState: &desiredState, CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, } @@ -2422,9 +2360,7 @@ func (suite *CoreTestSuite) TestCreateInferenceServiceFailure() { RegisteredModelId: "9998", CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, } @@ -2456,9 +2392,7 @@ func (suite *CoreTestSuite) TestUpdateInferenceService() { RegisteredModelId: registeredModelId, CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, } @@ -2475,9 +2409,7 @@ func (suite *CoreTestSuite) TestUpdateInferenceService() { createdEntity.ExternalID = &newExternalId (*createdEntity.CustomProperties)["score"] = openapi.MetadataValue{ - MetadataDoubleValue: &openapi.MetadataDoubleValue{ - DoubleValue: &newScore, - }, + MetadataDoubleValue: converter.NewMetadataDoubleValue(newScore), } updatedEntity, err := service.UpsertInferenceService(createdEntity) @@ -2554,9 +2486,7 @@ func (suite *CoreTestSuite) TestUpdateInferenceServiceFailure() { RegisteredModelId: registeredModelId, CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, } @@ -2571,9 +2501,7 @@ func (suite *CoreTestSuite) TestUpdateInferenceServiceFailure() { createdEntity.ExternalID = &newExternalId (*createdEntity.CustomProperties)["score"] = openapi.MetadataValue{ - MetadataDoubleValue: &openapi.MetadataDoubleValue{ - DoubleValue: &newScore, - }, + MetadataDoubleValue: converter.NewMetadataDoubleValue(newScore), } wrongId := "9999" @@ -2600,9 +2528,7 @@ func (suite *CoreTestSuite) TestGetInferenceServiceById() { DesiredState: &state, CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, } @@ -2628,7 +2554,7 @@ func (suite *CoreTestSuite) TestGetInferenceServiceById() { suite.Equal(*eut.Name, *getById.Name, "saved name should match the provided one") suite.Equal(*eut.ExternalID, *getById.ExternalID, "saved external id should match the provided one") suite.Equal(*eut.DesiredState, *getById.DesiredState, "saved state should match the provided one") - suite.Equal(*(*getById.CustomProperties)["custom_string_prop"].MetadataStringValue.StringValue, customString, "saved custom_string_prop custom property should match the provided one") + suite.Equal((*getById.CustomProperties)["custom_string_prop"].MetadataStringValue.StringValue, customString, "saved custom_string_prop custom property should match the provided one") } func (suite *CoreTestSuite) TestGetRegisteredModelByInferenceServiceId() { @@ -2646,9 +2572,7 @@ func (suite *CoreTestSuite) TestGetRegisteredModelByInferenceServiceId() { RegisteredModelId: registeredModelId, CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, } @@ -2691,9 +2615,7 @@ func (suite *CoreTestSuite) TestGetModelVersionByInferenceServiceId() { ModelVersionId: nil, // first we test by unspecified CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, } @@ -2791,9 +2713,7 @@ func (suite *CoreTestSuite) TestGetInferenceServiceByParamsName() { RegisteredModelId: registeredModelId, CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, } @@ -2818,7 +2738,7 @@ func (suite *CoreTestSuite) TestGetInferenceServiceByParamsName() { suite.Equal(*converter.Int64ToString(ctx.Id), *getByName.Id, "returned id should match the mlmd context one") suite.Equal(fmt.Sprintf("%s:%s", parentResourceId, *getByName.Name), *ctx.Name, "saved name should match the provided one") suite.Equal(*ctx.ExternalId, *getByName.ExternalID, "saved external id should match the provided one") - suite.Equal(ctx.CustomProperties["custom_string_prop"].GetStringValue(), *(*getByName.CustomProperties)["custom_string_prop"].MetadataStringValue.StringValue, "saved custom_string_prop custom property should match the provided one") + suite.Equal(ctx.CustomProperties["custom_string_prop"].GetStringValue(), (*getByName.CustomProperties)["custom_string_prop"].MetadataStringValue.StringValue, "saved custom_string_prop custom property should match the provided one") } func (suite *CoreTestSuite) TestGetInfernenceServiceByParamsExternalId() { @@ -2836,9 +2756,7 @@ func (suite *CoreTestSuite) TestGetInfernenceServiceByParamsExternalId() { RegisteredModelId: registeredModelId, CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, } @@ -2863,7 +2781,7 @@ func (suite *CoreTestSuite) TestGetInfernenceServiceByParamsExternalId() { suite.Equal(*converter.Int64ToString(ctx.Id), *getByExternalId.Id, "returned id should match the mlmd context one") suite.Equal(fmt.Sprintf("%s:%s", parentResourceId, *getByExternalId.Name), *ctx.Name, "saved name should match the provided one") suite.Equal(*ctx.ExternalId, *getByExternalId.ExternalID, "saved external id should match the provided one") - suite.Equal(ctx.CustomProperties["custom_string_prop"].GetStringValue(), *(*getByExternalId.CustomProperties)["custom_string_prop"].MetadataStringValue.StringValue, "saved custom_string_prop custom property should match the provided one") + suite.Equal(ctx.CustomProperties["custom_string_prop"].GetStringValue(), (*getByExternalId.CustomProperties)["custom_string_prop"].MetadataStringValue.StringValue, "saved custom_string_prop custom property should match the provided one") } func (suite *CoreTestSuite) TestGetInferenceServiceByEmptyParams() { @@ -2881,9 +2799,7 @@ func (suite *CoreTestSuite) TestGetInferenceServiceByEmptyParams() { RegisteredModelId: registeredModelId, CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, } @@ -3044,9 +2960,7 @@ func (suite *CoreTestSuite) TestCreateServeModel() { ModelVersionId: createdVersionId, CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, } @@ -3060,7 +2974,7 @@ func (suite *CoreTestSuite) TestCreateServeModel() { suite.Equal(*state, *createdEntity.LastKnownState) suite.Equal(createdVersionId, createdEntity.ModelVersionId) suite.Equal(entityDescription, *createdEntity.Description) - suite.Equal(customString, *(*createdEntity.CustomProperties)["custom_string_prop"].MetadataStringValue.StringValue) + suite.Equal(customString, (*createdEntity.CustomProperties)["custom_string_prop"].MetadataStringValue.StringValue) createdEntityId, _ := converter.StringToInt64(createdEntity.Id) getById, err := suite.mlmdClient.GetExecutionsByID(context.Background(), &proto.GetExecutionsByIDRequest{ @@ -3073,7 +2987,7 @@ func (suite *CoreTestSuite) TestCreateServeModel() { suite.Equal(string(*createdEntity.LastKnownState), getById.Executions[0].LastKnownState.String()) suite.Equal(*createdVersionIdAsInt, getById.Executions[0].Properties["model_version_id"].GetIntValue()) suite.Equal(*createdEntity.Description, getById.Executions[0].Properties["description"].GetStringValue()) - suite.Equal(*(*createdEntity.CustomProperties)["custom_string_prop"].MetadataStringValue.StringValue, getById.Executions[0].CustomProperties["custom_string_prop"].GetStringValue()) + suite.Equal((*createdEntity.CustomProperties)["custom_string_prop"].MetadataStringValue.StringValue, getById.Executions[0].CustomProperties["custom_string_prop"].GetStringValue()) inferenceServiceIdAsInt, _ := converter.StringToInt64(&inferenceServiceId) byCtx, _ := suite.mlmdClient.GetExecutionsByContext(context.Background(), &proto.GetExecutionsByContextRequest{ @@ -3099,9 +3013,7 @@ func (suite *CoreTestSuite) TestCreateServeModelFailure() { ModelVersionId: "9998", CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, } @@ -3142,9 +3054,7 @@ func (suite *CoreTestSuite) TestUpdateServeModel() { ModelVersionId: createdVersionId, CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, } @@ -3170,7 +3080,7 @@ func (suite *CoreTestSuite) TestUpdateServeModel() { suite.Equal(fmt.Sprintf("%s:%s", inferenceServiceId, *createdEntity.Name), *getById.Executions[0].Name) suite.Equal(string(newState), getById.Executions[0].LastKnownState.String()) suite.Equal(*createdVersionIdAsInt, getById.Executions[0].Properties["model_version_id"].GetIntValue()) - suite.Equal(*(*createdEntity.CustomProperties)["custom_string_prop"].MetadataStringValue.StringValue, getById.Executions[0].CustomProperties["custom_string_prop"].GetStringValue()) + suite.Equal((*createdEntity.CustomProperties)["custom_string_prop"].MetadataStringValue.StringValue, getById.Executions[0].CustomProperties["custom_string_prop"].GetStringValue()) prevModelVersionId := updatedEntity.ModelVersionId updatedEntity.ModelVersionId = "" @@ -3205,9 +3115,7 @@ func (suite *CoreTestSuite) TestUpdateServeModelFailure() { ModelVersionId: createdVersionId, CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, } @@ -3254,9 +3162,7 @@ func (suite *CoreTestSuite) TestGetServeModelById() { ModelVersionId: createdVersionId, CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, } @@ -3272,7 +3178,7 @@ func (suite *CoreTestSuite) TestGetServeModelById() { suite.Equal(entityName, *getById.Name) suite.Equal(*state, *getById.LastKnownState) suite.Equal(createdVersionId, getById.ModelVersionId) - suite.Equal(customString, *(*getById.CustomProperties)["custom_string_prop"].MetadataStringValue.StringValue) + suite.Equal(customString, (*getById.CustomProperties)["custom_string_prop"].MetadataStringValue.StringValue) suite.Equal(*createdEntity, *getById, "artifacts returned during creation and on get by id should be equal") } @@ -3311,9 +3217,7 @@ func (suite *CoreTestSuite) TestGetServeModels() { ModelVersionId: createdVersion1Id, CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, } @@ -3326,9 +3230,7 @@ func (suite *CoreTestSuite) TestGetServeModels() { ModelVersionId: createdVersion2Id, CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, } @@ -3341,9 +3243,7 @@ func (suite *CoreTestSuite) TestGetServeModels() { ModelVersionId: createdVersion3Id, CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &customString, - }, + MetadataStringValue: converter.NewMetadataStringValue(customString), }, }, } diff --git a/pkg/openapi/api_model_registry_service.go b/pkg/openapi/api_model_registry_service.go index b94a7d1fb..cb1df38cd 100644 --- a/pkg/openapi/api_model_registry_service.go +++ b/pkg/openapi/api_model_registry_service.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. @@ -72,7 +72,7 @@ func (a *ModelRegistryServiceAPIService) CreateEnvironmentInferenceServiceExecut return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/serving_environments/{servingenvironmentId}/inference_services" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/serving_environments/{servingenvironmentId}/inference_services" localVarPath = strings.Replace(localVarPath, "{"+"servingenvironmentId"+"}", url.PathEscape(parameterValueToString(r.servingenvironmentId, "servingenvironmentId")), -1) localVarHeaderParams := make(map[string]string) @@ -228,7 +228,7 @@ func (a *ModelRegistryServiceAPIService) CreateInferenceServiceExecute(r ApiCrea return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/inference_services" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/inference_services" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -375,7 +375,7 @@ func (a *ModelRegistryServiceAPIService) CreateInferenceServiceServeExecute(r Ap return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/inference_services/{inferenceserviceId}/serves" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/inference_services/{inferenceserviceId}/serves" localVarPath = strings.Replace(localVarPath, "{"+"inferenceserviceId"+"}", url.PathEscape(parameterValueToString(r.inferenceserviceId, "inferenceserviceId")), -1) localVarHeaderParams := make(map[string]string) @@ -531,7 +531,7 @@ func (a *ModelRegistryServiceAPIService) CreateModelArtifactExecute(r ApiCreateM return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/model_artifacts" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/model_artifacts" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -675,7 +675,7 @@ func (a *ModelRegistryServiceAPIService) CreateModelVersionExecute(r ApiCreateMo return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/model_versions" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/model_versions" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -822,7 +822,7 @@ func (a *ModelRegistryServiceAPIService) CreateModelVersionArtifactExecute(r Api return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/model_versions/{modelversionId}/artifacts" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/model_versions/{modelversionId}/artifacts" localVarPath = strings.Replace(localVarPath, "{"+"modelversionId"+"}", url.PathEscape(parameterValueToString(r.modelversionId, "modelversionId")), -1) localVarHeaderParams := make(map[string]string) @@ -978,7 +978,7 @@ func (a *ModelRegistryServiceAPIService) CreateRegisteredModelExecute(r ApiCreat return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/registered_models" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/registered_models" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -1125,7 +1125,7 @@ func (a *ModelRegistryServiceAPIService) CreateRegisteredModelVersionExecute(r A return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/registered_models/{registeredmodelId}/versions" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/registered_models/{registeredmodelId}/versions" localVarPath = strings.Replace(localVarPath, "{"+"registeredmodelId"+"}", url.PathEscape(parameterValueToString(r.registeredmodelId, "registeredmodelId")), -1) localVarHeaderParams := make(map[string]string) @@ -1281,7 +1281,7 @@ func (a *ModelRegistryServiceAPIService) CreateServingEnvironmentExecute(r ApiCr return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/serving_environments" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/serving_environments" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -1439,7 +1439,7 @@ func (a *ModelRegistryServiceAPIService) FindInferenceServiceExecute(r ApiFindIn return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/inference_service" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/inference_service" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -1612,7 +1612,7 @@ func (a *ModelRegistryServiceAPIService) FindModelArtifactExecute(r ApiFindModel return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/model_artifact" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/model_artifact" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -1785,7 +1785,7 @@ func (a *ModelRegistryServiceAPIService) FindModelVersionExecute(r ApiFindModelV return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/model_version" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/model_version" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -1951,7 +1951,7 @@ func (a *ModelRegistryServiceAPIService) FindRegisteredModelExecute(r ApiFindReg return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/registered_model" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/registered_model" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -2103,7 +2103,7 @@ func (a *ModelRegistryServiceAPIService) FindServingEnvironmentExecute(r ApiFind return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/serving_environment" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/serving_environment" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -2286,7 +2286,7 @@ func (a *ModelRegistryServiceAPIService) GetEnvironmentInferenceServicesExecute( return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/serving_environments/{servingenvironmentId}/inference_services" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/serving_environments/{servingenvironmentId}/inference_services" localVarPath = strings.Replace(localVarPath, "{"+"servingenvironmentId"+"}", url.PathEscape(parameterValueToString(r.servingenvironmentId, "servingenvironmentId")), -1) localVarHeaderParams := make(map[string]string) @@ -2440,7 +2440,7 @@ func (a *ModelRegistryServiceAPIService) GetInferenceServiceExecute(r ApiGetInfe return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/inference_services/{inferenceserviceId}" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/inference_services/{inferenceserviceId}" localVarPath = strings.Replace(localVarPath, "{"+"inferenceserviceId"+"}", url.PathEscape(parameterValueToString(r.inferenceserviceId, "inferenceserviceId")), -1) localVarHeaderParams := make(map[string]string) @@ -2576,7 +2576,7 @@ func (a *ModelRegistryServiceAPIService) GetInferenceServiceModelExecute(r ApiGe return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/inference_services/{inferenceserviceId}/model" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/inference_services/{inferenceserviceId}/model" localVarPath = strings.Replace(localVarPath, "{"+"inferenceserviceId"+"}", url.PathEscape(parameterValueToString(r.inferenceserviceId, "inferenceserviceId")), -1) localVarHeaderParams := make(map[string]string) @@ -2754,7 +2754,7 @@ func (a *ModelRegistryServiceAPIService) GetInferenceServiceServesExecute(r ApiG return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/inference_services/{inferenceserviceId}/serves" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/inference_services/{inferenceserviceId}/serves" localVarPath = strings.Replace(localVarPath, "{"+"inferenceserviceId"+"}", url.PathEscape(parameterValueToString(r.inferenceserviceId, "inferenceserviceId")), -1) localVarHeaderParams := make(map[string]string) @@ -2908,7 +2908,7 @@ func (a *ModelRegistryServiceAPIService) GetInferenceServiceVersionExecute(r Api return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/inference_services/{inferenceserviceId}/version" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/inference_services/{inferenceserviceId}/version" localVarPath = strings.Replace(localVarPath, "{"+"inferenceserviceId"+"}", url.PathEscape(parameterValueToString(r.inferenceserviceId, "inferenceserviceId")), -1) localVarHeaderParams := make(map[string]string) @@ -3069,7 +3069,7 @@ func (a *ModelRegistryServiceAPIService) GetInferenceServicesExecute(r ApiGetInf return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/inference_services" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/inference_services" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -3227,7 +3227,7 @@ func (a *ModelRegistryServiceAPIService) GetModelArtifactExecute(r ApiGetModelAr return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/model_artifacts/{modelartifactId}" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/model_artifacts/{modelartifactId}" localVarPath = strings.Replace(localVarPath, "{"+"modelartifactId"+"}", url.PathEscape(parameterValueToString(r.modelartifactId, "modelartifactId")), -1) localVarHeaderParams := make(map[string]string) @@ -3388,7 +3388,7 @@ func (a *ModelRegistryServiceAPIService) GetModelArtifactsExecute(r ApiGetModelA return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/model_artifacts" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/model_artifacts" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -3546,7 +3546,7 @@ func (a *ModelRegistryServiceAPIService) GetModelVersionExecute(r ApiGetModelVer return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/model_versions/{modelversionId}" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/model_versions/{modelversionId}" localVarPath = strings.Replace(localVarPath, "{"+"modelversionId"+"}", url.PathEscape(parameterValueToString(r.modelversionId, "modelversionId")), -1) localVarHeaderParams := make(map[string]string) @@ -3722,7 +3722,7 @@ func (a *ModelRegistryServiceAPIService) GetModelVersionArtifactsExecute(r ApiGe return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/model_versions/{modelversionId}/artifacts" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/model_versions/{modelversionId}/artifacts" localVarPath = strings.Replace(localVarPath, "{"+"modelversionId"+"}", url.PathEscape(parameterValueToString(r.modelversionId, "modelversionId")), -1) localVarHeaderParams := make(map[string]string) @@ -3901,7 +3901,7 @@ func (a *ModelRegistryServiceAPIService) GetModelVersionsExecute(r ApiGetModelVe return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/model_versions" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/model_versions" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -4037,7 +4037,7 @@ func (a *ModelRegistryServiceAPIService) GetRegisteredModelExecute(r ApiGetRegis return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/registered_models/{registeredmodelId}" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/registered_models/{registeredmodelId}" localVarPath = strings.Replace(localVarPath, "{"+"registeredmodelId"+"}", url.PathEscape(parameterValueToString(r.registeredmodelId, "registeredmodelId")), -1) localVarHeaderParams := make(map[string]string) @@ -4215,7 +4215,7 @@ func (a *ModelRegistryServiceAPIService) GetRegisteredModelVersionsExecute(r Api return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/registered_models/{registeredmodelId}/versions" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/registered_models/{registeredmodelId}/versions" localVarPath = strings.Replace(localVarPath, "{"+"registeredmodelId"+"}", url.PathEscape(parameterValueToString(r.registeredmodelId, "registeredmodelId")), -1) localVarHeaderParams := make(map[string]string) @@ -4394,7 +4394,7 @@ func (a *ModelRegistryServiceAPIService) GetRegisteredModelsExecute(r ApiGetRegi return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/registered_models" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/registered_models" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -4530,7 +4530,7 @@ func (a *ModelRegistryServiceAPIService) GetServingEnvironmentExecute(r ApiGetSe return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/serving_environments/{servingenvironmentId}" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/serving_environments/{servingenvironmentId}" localVarPath = strings.Replace(localVarPath, "{"+"servingenvironmentId"+"}", url.PathEscape(parameterValueToString(r.servingenvironmentId, "servingenvironmentId")), -1) localVarHeaderParams := make(map[string]string) @@ -4691,7 +4691,7 @@ func (a *ModelRegistryServiceAPIService) GetServingEnvironmentsExecute(r ApiGetS return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/serving_environments" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/serving_environments" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -4834,7 +4834,7 @@ func (a *ModelRegistryServiceAPIService) UpdateInferenceServiceExecute(r ApiUpda return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/inference_services/{inferenceserviceId}" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/inference_services/{inferenceserviceId}" localVarPath = strings.Replace(localVarPath, "{"+"inferenceserviceId"+"}", url.PathEscape(parameterValueToString(r.inferenceserviceId, "inferenceserviceId")), -1) localVarHeaderParams := make(map[string]string) @@ -4993,7 +4993,7 @@ func (a *ModelRegistryServiceAPIService) UpdateModelArtifactExecute(r ApiUpdateM return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/model_artifacts/{modelartifactId}" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/model_artifacts/{modelartifactId}" localVarPath = strings.Replace(localVarPath, "{"+"modelartifactId"+"}", url.PathEscape(parameterValueToString(r.modelartifactId, "modelartifactId")), -1) localVarHeaderParams := make(map[string]string) @@ -5152,7 +5152,7 @@ func (a *ModelRegistryServiceAPIService) UpdateModelVersionExecute(r ApiUpdateMo return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/model_versions/{modelversionId}" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/model_versions/{modelversionId}" localVarPath = strings.Replace(localVarPath, "{"+"modelversionId"+"}", url.PathEscape(parameterValueToString(r.modelversionId, "modelversionId")), -1) localVarHeaderParams := make(map[string]string) @@ -5311,7 +5311,7 @@ func (a *ModelRegistryServiceAPIService) UpdateRegisteredModelExecute(r ApiUpdat return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/registered_models/{registeredmodelId}" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/registered_models/{registeredmodelId}" localVarPath = strings.Replace(localVarPath, "{"+"registeredmodelId"+"}", url.PathEscape(parameterValueToString(r.registeredmodelId, "registeredmodelId")), -1) localVarHeaderParams := make(map[string]string) @@ -5470,7 +5470,7 @@ func (a *ModelRegistryServiceAPIService) UpdateServingEnvironmentExecute(r ApiUp return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha1/serving_environments/{servingenvironmentId}" + localVarPath := localBasePath + "/api/model_registry/v1alpha2/serving_environments/{servingenvironmentId}" localVarPath = strings.Replace(localVarPath, "{"+"servingenvironmentId"+"}", url.PathEscape(parameterValueToString(r.servingenvironmentId, "servingenvironmentId")), -1) localVarHeaderParams := make(map[string]string) diff --git a/pkg/openapi/client.go b/pkg/openapi/client.go index d54382565..7f6c2dbc9 100644 --- a/pkg/openapi/client.go +++ b/pkg/openapi/client.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. @@ -40,7 +40,7 @@ var ( queryDescape = strings.NewReplacer("%5B", "[", "%5D", "]") ) -// APIClient manages communication with the Model Registry REST API API vv1alpha1 +// APIClient manages communication with the Model Registry REST API API vv1alpha2 // In most cases there should be only one, shared, APIClient. type APIClient struct { cfg *Configuration diff --git a/pkg/openapi/configuration.go b/pkg/openapi/configuration.go index 7575d94d4..113e57770 100644 --- a/pkg/openapi/configuration.go +++ b/pkg/openapi/configuration.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_artifact.go b/pkg/openapi/model_artifact.go index 143a29c89..287f1c67a 100644 --- a/pkg/openapi/model_artifact.go +++ b/pkg/openapi/model_artifact.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_artifact_list.go b/pkg/openapi/model_artifact_list.go index c970693f4..ea62300d3 100644 --- a/pkg/openapi/model_artifact_list.go +++ b/pkg/openapi/model_artifact_list.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_artifact_state.go b/pkg/openapi/model_artifact_state.go index d703a613d..955874474 100644 --- a/pkg/openapi/model_artifact_state.go +++ b/pkg/openapi/model_artifact_state.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_base_artifact.go b/pkg/openapi/model_base_artifact.go index ce0d21e13..da76d8f82 100644 --- a/pkg/openapi/model_base_artifact.go +++ b/pkg/openapi/model_base_artifact.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_base_artifact_create.go b/pkg/openapi/model_base_artifact_create.go index dbd616ebf..1973667d2 100644 --- a/pkg/openapi/model_base_artifact_create.go +++ b/pkg/openapi/model_base_artifact_create.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_base_artifact_update.go b/pkg/openapi/model_base_artifact_update.go index dc89d09d7..9cf629abf 100644 --- a/pkg/openapi/model_base_artifact_update.go +++ b/pkg/openapi/model_base_artifact_update.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_base_execution.go b/pkg/openapi/model_base_execution.go index f650d51fc..db2a8a5ce 100644 --- a/pkg/openapi/model_base_execution.go +++ b/pkg/openapi/model_base_execution.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_base_execution_create.go b/pkg/openapi/model_base_execution_create.go index 4967ffa90..4adbf4ff6 100644 --- a/pkg/openapi/model_base_execution_create.go +++ b/pkg/openapi/model_base_execution_create.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_base_execution_update.go b/pkg/openapi/model_base_execution_update.go index fdeaf485d..aa3716cd6 100644 --- a/pkg/openapi/model_base_execution_update.go +++ b/pkg/openapi/model_base_execution_update.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_base_resource.go b/pkg/openapi/model_base_resource.go index 7890ecc8e..37e2fd02b 100644 --- a/pkg/openapi/model_base_resource.go +++ b/pkg/openapi/model_base_resource.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_base_resource_create.go b/pkg/openapi/model_base_resource_create.go index de4a731a9..a8e158951 100644 --- a/pkg/openapi/model_base_resource_create.go +++ b/pkg/openapi/model_base_resource_create.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_base_resource_list.go b/pkg/openapi/model_base_resource_list.go index a77926b93..d8bc39d73 100644 --- a/pkg/openapi/model_base_resource_list.go +++ b/pkg/openapi/model_base_resource_list.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_base_resource_update.go b/pkg/openapi/model_base_resource_update.go index 1bf46a46d..640443292 100644 --- a/pkg/openapi/model_base_resource_update.go +++ b/pkg/openapi/model_base_resource_update.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_doc_artifact.go b/pkg/openapi/model_doc_artifact.go index 28e36697d..7b3be0795 100644 --- a/pkg/openapi/model_doc_artifact.go +++ b/pkg/openapi/model_doc_artifact.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_error.go b/pkg/openapi/model_error.go index d7767fb96..919bad0b1 100644 --- a/pkg/openapi/model_error.go +++ b/pkg/openapi/model_error.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_execution_state.go b/pkg/openapi/model_execution_state.go index e7852cb98..7542f4686 100644 --- a/pkg/openapi/model_execution_state.go +++ b/pkg/openapi/model_execution_state.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_inference_service.go b/pkg/openapi/model_inference_service.go index 731cb7550..10eb0f16d 100644 --- a/pkg/openapi/model_inference_service.go +++ b/pkg/openapi/model_inference_service.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_inference_service_create.go b/pkg/openapi/model_inference_service_create.go index 01bdd97ed..58368c252 100644 --- a/pkg/openapi/model_inference_service_create.go +++ b/pkg/openapi/model_inference_service_create.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_inference_service_list.go b/pkg/openapi/model_inference_service_list.go index 2eb6b978e..40aacac87 100644 --- a/pkg/openapi/model_inference_service_list.go +++ b/pkg/openapi/model_inference_service_list.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_inference_service_state.go b/pkg/openapi/model_inference_service_state.go index 03ad022d1..b61557c54 100644 --- a/pkg/openapi/model_inference_service_state.go +++ b/pkg/openapi/model_inference_service_state.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_inference_service_update.go b/pkg/openapi/model_inference_service_update.go index 9a2c074bf..c2b2d7583 100644 --- a/pkg/openapi/model_inference_service_update.go +++ b/pkg/openapi/model_inference_service_update.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_metadata_bool_value.go b/pkg/openapi/model_metadata_bool_value.go index bb1c28a36..d868b81e2 100644 --- a/pkg/openapi/model_metadata_bool_value.go +++ b/pkg/openapi/model_metadata_bool_value.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. @@ -19,15 +19,18 @@ var _ MappedNullable = &MetadataBoolValue{} // MetadataBoolValue A bool property value. type MetadataBoolValue struct { - BoolValue *bool `json:"bool_value,omitempty"` + BoolValue bool `json:"bool_value"` + MetadataType string `json:"metadataType"` } // NewMetadataBoolValue instantiates a new MetadataBoolValue object // This constructor will assign default values to properties that have it defined, // and makes sure properties required by API are set, but the set of arguments // will change when the set of required properties is changed -func NewMetadataBoolValue() *MetadataBoolValue { +func NewMetadataBoolValue(boolValue bool, metadataType string) *MetadataBoolValue { this := MetadataBoolValue{} + this.BoolValue = boolValue + this.MetadataType = metadataType return &this } @@ -36,39 +39,57 @@ func NewMetadataBoolValue() *MetadataBoolValue { // but it doesn't guarantee that properties required by API are set func NewMetadataBoolValueWithDefaults() *MetadataBoolValue { this := MetadataBoolValue{} + var metadataType string = "MetadataBoolValue" + this.MetadataType = metadataType return &this } -// GetBoolValue returns the BoolValue field value if set, zero value otherwise. +// GetBoolValue returns the BoolValue field value func (o *MetadataBoolValue) GetBoolValue() bool { - if o == nil || IsNil(o.BoolValue) { + if o == nil { var ret bool return ret } - return *o.BoolValue + + return o.BoolValue } -// GetBoolValueOk returns a tuple with the BoolValue field value if set, nil otherwise +// GetBoolValueOk returns a tuple with the BoolValue field value // and a boolean to check if the value has been set. func (o *MetadataBoolValue) GetBoolValueOk() (*bool, bool) { - if o == nil || IsNil(o.BoolValue) { + if o == nil { return nil, false } - return o.BoolValue, true + return &o.BoolValue, true +} + +// SetBoolValue sets field value +func (o *MetadataBoolValue) SetBoolValue(v bool) { + o.BoolValue = v } -// HasBoolValue returns a boolean if a field has been set. -func (o *MetadataBoolValue) HasBoolValue() bool { - if o != nil && !IsNil(o.BoolValue) { - return true +// GetMetadataType returns the MetadataType field value +func (o *MetadataBoolValue) GetMetadataType() string { + if o == nil { + var ret string + return ret } - return false + return o.MetadataType } -// SetBoolValue gets a reference to the given bool and assigns it to the BoolValue field. -func (o *MetadataBoolValue) SetBoolValue(v bool) { - o.BoolValue = &v +// GetMetadataTypeOk returns a tuple with the MetadataType field value +// and a boolean to check if the value has been set. +func (o *MetadataBoolValue) GetMetadataTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.MetadataType, true +} + +// SetMetadataType sets field value +func (o *MetadataBoolValue) SetMetadataType(v string) { + o.MetadataType = v } func (o MetadataBoolValue) MarshalJSON() ([]byte, error) { @@ -81,9 +102,8 @@ func (o MetadataBoolValue) MarshalJSON() ([]byte, error) { func (o MetadataBoolValue) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - if !IsNil(o.BoolValue) { - toSerialize["bool_value"] = o.BoolValue - } + toSerialize["bool_value"] = o.BoolValue + toSerialize["metadataType"] = o.MetadataType return toSerialize, nil } diff --git a/pkg/openapi/model_metadata_double_value.go b/pkg/openapi/model_metadata_double_value.go index d7fd2ef53..ef2076495 100644 --- a/pkg/openapi/model_metadata_double_value.go +++ b/pkg/openapi/model_metadata_double_value.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. @@ -19,15 +19,18 @@ var _ MappedNullable = &MetadataDoubleValue{} // MetadataDoubleValue A double property value. type MetadataDoubleValue struct { - DoubleValue *float64 `json:"double_value,omitempty"` + DoubleValue float64 `json:"double_value"` + MetadataType string `json:"metadataType"` } // NewMetadataDoubleValue instantiates a new MetadataDoubleValue object // This constructor will assign default values to properties that have it defined, // and makes sure properties required by API are set, but the set of arguments // will change when the set of required properties is changed -func NewMetadataDoubleValue() *MetadataDoubleValue { +func NewMetadataDoubleValue(doubleValue float64, metadataType string) *MetadataDoubleValue { this := MetadataDoubleValue{} + this.DoubleValue = doubleValue + this.MetadataType = metadataType return &this } @@ -36,39 +39,57 @@ func NewMetadataDoubleValue() *MetadataDoubleValue { // but it doesn't guarantee that properties required by API are set func NewMetadataDoubleValueWithDefaults() *MetadataDoubleValue { this := MetadataDoubleValue{} + var metadataType string = "MetadataDoubleValue" + this.MetadataType = metadataType return &this } -// GetDoubleValue returns the DoubleValue field value if set, zero value otherwise. +// GetDoubleValue returns the DoubleValue field value func (o *MetadataDoubleValue) GetDoubleValue() float64 { - if o == nil || IsNil(o.DoubleValue) { + if o == nil { var ret float64 return ret } - return *o.DoubleValue + + return o.DoubleValue } -// GetDoubleValueOk returns a tuple with the DoubleValue field value if set, nil otherwise +// GetDoubleValueOk returns a tuple with the DoubleValue field value // and a boolean to check if the value has been set. func (o *MetadataDoubleValue) GetDoubleValueOk() (*float64, bool) { - if o == nil || IsNil(o.DoubleValue) { + if o == nil { return nil, false } - return o.DoubleValue, true + return &o.DoubleValue, true +} + +// SetDoubleValue sets field value +func (o *MetadataDoubleValue) SetDoubleValue(v float64) { + o.DoubleValue = v } -// HasDoubleValue returns a boolean if a field has been set. -func (o *MetadataDoubleValue) HasDoubleValue() bool { - if o != nil && !IsNil(o.DoubleValue) { - return true +// GetMetadataType returns the MetadataType field value +func (o *MetadataDoubleValue) GetMetadataType() string { + if o == nil { + var ret string + return ret } - return false + return o.MetadataType } -// SetDoubleValue gets a reference to the given float64 and assigns it to the DoubleValue field. -func (o *MetadataDoubleValue) SetDoubleValue(v float64) { - o.DoubleValue = &v +// GetMetadataTypeOk returns a tuple with the MetadataType field value +// and a boolean to check if the value has been set. +func (o *MetadataDoubleValue) GetMetadataTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.MetadataType, true +} + +// SetMetadataType sets field value +func (o *MetadataDoubleValue) SetMetadataType(v string) { + o.MetadataType = v } func (o MetadataDoubleValue) MarshalJSON() ([]byte, error) { @@ -81,9 +102,8 @@ func (o MetadataDoubleValue) MarshalJSON() ([]byte, error) { func (o MetadataDoubleValue) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - if !IsNil(o.DoubleValue) { - toSerialize["double_value"] = o.DoubleValue - } + toSerialize["double_value"] = o.DoubleValue + toSerialize["metadataType"] = o.MetadataType return toSerialize, nil } diff --git a/pkg/openapi/model_metadata_int_value.go b/pkg/openapi/model_metadata_int_value.go index beb403542..f741e1b14 100644 --- a/pkg/openapi/model_metadata_int_value.go +++ b/pkg/openapi/model_metadata_int_value.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. @@ -19,15 +19,18 @@ var _ MappedNullable = &MetadataIntValue{} // MetadataIntValue An integer (int64) property value. type MetadataIntValue struct { - IntValue *string `json:"int_value,omitempty"` + IntValue string `json:"int_value"` + MetadataType string `json:"metadataType"` } // NewMetadataIntValue instantiates a new MetadataIntValue object // This constructor will assign default values to properties that have it defined, // and makes sure properties required by API are set, but the set of arguments // will change when the set of required properties is changed -func NewMetadataIntValue() *MetadataIntValue { +func NewMetadataIntValue(intValue string, metadataType string) *MetadataIntValue { this := MetadataIntValue{} + this.IntValue = intValue + this.MetadataType = metadataType return &this } @@ -36,39 +39,57 @@ func NewMetadataIntValue() *MetadataIntValue { // but it doesn't guarantee that properties required by API are set func NewMetadataIntValueWithDefaults() *MetadataIntValue { this := MetadataIntValue{} + var metadataType string = "MetadataIntValue" + this.MetadataType = metadataType return &this } -// GetIntValue returns the IntValue field value if set, zero value otherwise. +// GetIntValue returns the IntValue field value func (o *MetadataIntValue) GetIntValue() string { - if o == nil || IsNil(o.IntValue) { + if o == nil { var ret string return ret } - return *o.IntValue + + return o.IntValue } -// GetIntValueOk returns a tuple with the IntValue field value if set, nil otherwise +// GetIntValueOk returns a tuple with the IntValue field value // and a boolean to check if the value has been set. func (o *MetadataIntValue) GetIntValueOk() (*string, bool) { - if o == nil || IsNil(o.IntValue) { + if o == nil { return nil, false } - return o.IntValue, true + return &o.IntValue, true +} + +// SetIntValue sets field value +func (o *MetadataIntValue) SetIntValue(v string) { + o.IntValue = v } -// HasIntValue returns a boolean if a field has been set. -func (o *MetadataIntValue) HasIntValue() bool { - if o != nil && !IsNil(o.IntValue) { - return true +// GetMetadataType returns the MetadataType field value +func (o *MetadataIntValue) GetMetadataType() string { + if o == nil { + var ret string + return ret } - return false + return o.MetadataType } -// SetIntValue gets a reference to the given string and assigns it to the IntValue field. -func (o *MetadataIntValue) SetIntValue(v string) { - o.IntValue = &v +// GetMetadataTypeOk returns a tuple with the MetadataType field value +// and a boolean to check if the value has been set. +func (o *MetadataIntValue) GetMetadataTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.MetadataType, true +} + +// SetMetadataType sets field value +func (o *MetadataIntValue) SetMetadataType(v string) { + o.MetadataType = v } func (o MetadataIntValue) MarshalJSON() ([]byte, error) { @@ -81,9 +102,8 @@ func (o MetadataIntValue) MarshalJSON() ([]byte, error) { func (o MetadataIntValue) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - if !IsNil(o.IntValue) { - toSerialize["int_value"] = o.IntValue - } + toSerialize["int_value"] = o.IntValue + toSerialize["metadataType"] = o.MetadataType return toSerialize, nil } diff --git a/pkg/openapi/model_metadata_proto_value.go b/pkg/openapi/model_metadata_proto_value.go index 7b5c254b9..eb30f9f5f 100644 --- a/pkg/openapi/model_metadata_proto_value.go +++ b/pkg/openapi/model_metadata_proto_value.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. @@ -20,17 +20,21 @@ var _ MappedNullable = &MetadataProtoValue{} // MetadataProtoValue A proto property value. type MetadataProtoValue struct { // url describing proto value - Type *string `json:"type,omitempty"` + Type string `json:"type"` // Base64 encoded bytes for proto value - ProtoValue *string `json:"proto_value,omitempty"` + ProtoValue string `json:"proto_value"` + MetadataType string `json:"metadataType"` } // NewMetadataProtoValue instantiates a new MetadataProtoValue object // This constructor will assign default values to properties that have it defined, // and makes sure properties required by API are set, but the set of arguments // will change when the set of required properties is changed -func NewMetadataProtoValue() *MetadataProtoValue { +func NewMetadataProtoValue(type_ string, protoValue string, metadataType string) *MetadataProtoValue { this := MetadataProtoValue{} + this.Type = type_ + this.ProtoValue = protoValue + this.MetadataType = metadataType return &this } @@ -39,71 +43,81 @@ func NewMetadataProtoValue() *MetadataProtoValue { // but it doesn't guarantee that properties required by API are set func NewMetadataProtoValueWithDefaults() *MetadataProtoValue { this := MetadataProtoValue{} + var metadataType string = "MetadataProtoValue" + this.MetadataType = metadataType return &this } -// GetType returns the Type field value if set, zero value otherwise. +// GetType returns the Type field value func (o *MetadataProtoValue) GetType() string { - if o == nil || IsNil(o.Type) { + if o == nil { var ret string return ret } - return *o.Type + + return o.Type } -// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// GetTypeOk returns a tuple with the Type field value // and a boolean to check if the value has been set. func (o *MetadataProtoValue) GetTypeOk() (*string, bool) { - if o == nil || IsNil(o.Type) { + if o == nil { return nil, false } - return o.Type, true -} - -// HasType returns a boolean if a field has been set. -func (o *MetadataProtoValue) HasType() bool { - if o != nil && !IsNil(o.Type) { - return true - } - - return false + return &o.Type, true } -// SetType gets a reference to the given string and assigns it to the Type field. +// SetType sets field value func (o *MetadataProtoValue) SetType(v string) { - o.Type = &v + o.Type = v } -// GetProtoValue returns the ProtoValue field value if set, zero value otherwise. +// GetProtoValue returns the ProtoValue field value func (o *MetadataProtoValue) GetProtoValue() string { - if o == nil || IsNil(o.ProtoValue) { + if o == nil { var ret string return ret } - return *o.ProtoValue + + return o.ProtoValue } -// GetProtoValueOk returns a tuple with the ProtoValue field value if set, nil otherwise +// GetProtoValueOk returns a tuple with the ProtoValue field value // and a boolean to check if the value has been set. func (o *MetadataProtoValue) GetProtoValueOk() (*string, bool) { - if o == nil || IsNil(o.ProtoValue) { + if o == nil { return nil, false } - return o.ProtoValue, true + return &o.ProtoValue, true } -// HasProtoValue returns a boolean if a field has been set. -func (o *MetadataProtoValue) HasProtoValue() bool { - if o != nil && !IsNil(o.ProtoValue) { - return true +// SetProtoValue sets field value +func (o *MetadataProtoValue) SetProtoValue(v string) { + o.ProtoValue = v +} + +// GetMetadataType returns the MetadataType field value +func (o *MetadataProtoValue) GetMetadataType() string { + if o == nil { + var ret string + return ret } - return false + return o.MetadataType } -// SetProtoValue gets a reference to the given string and assigns it to the ProtoValue field. -func (o *MetadataProtoValue) SetProtoValue(v string) { - o.ProtoValue = &v +// GetMetadataTypeOk returns a tuple with the MetadataType field value +// and a boolean to check if the value has been set. +func (o *MetadataProtoValue) GetMetadataTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.MetadataType, true +} + +// SetMetadataType sets field value +func (o *MetadataProtoValue) SetMetadataType(v string) { + o.MetadataType = v } func (o MetadataProtoValue) MarshalJSON() ([]byte, error) { @@ -116,12 +130,9 @@ func (o MetadataProtoValue) MarshalJSON() ([]byte, error) { func (o MetadataProtoValue) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - if !IsNil(o.Type) { - toSerialize["type"] = o.Type - } - if !IsNil(o.ProtoValue) { - toSerialize["proto_value"] = o.ProtoValue - } + toSerialize["type"] = o.Type + toSerialize["proto_value"] = o.ProtoValue + toSerialize["metadataType"] = o.MetadataType return toSerialize, nil } diff --git a/pkg/openapi/model_metadata_string_value.go b/pkg/openapi/model_metadata_string_value.go index b44573065..2c3629e47 100644 --- a/pkg/openapi/model_metadata_string_value.go +++ b/pkg/openapi/model_metadata_string_value.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. @@ -19,15 +19,18 @@ var _ MappedNullable = &MetadataStringValue{} // MetadataStringValue A string property value. type MetadataStringValue struct { - StringValue *string `json:"string_value,omitempty"` + StringValue string `json:"string_value"` + MetadataType string `json:"metadataType"` } // NewMetadataStringValue instantiates a new MetadataStringValue object // This constructor will assign default values to properties that have it defined, // and makes sure properties required by API are set, but the set of arguments // will change when the set of required properties is changed -func NewMetadataStringValue() *MetadataStringValue { +func NewMetadataStringValue(stringValue string, metadataType string) *MetadataStringValue { this := MetadataStringValue{} + this.StringValue = stringValue + this.MetadataType = metadataType return &this } @@ -36,39 +39,57 @@ func NewMetadataStringValue() *MetadataStringValue { // but it doesn't guarantee that properties required by API are set func NewMetadataStringValueWithDefaults() *MetadataStringValue { this := MetadataStringValue{} + var metadataType string = "MetadataStringValue" + this.MetadataType = metadataType return &this } -// GetStringValue returns the StringValue field value if set, zero value otherwise. +// GetStringValue returns the StringValue field value func (o *MetadataStringValue) GetStringValue() string { - if o == nil || IsNil(o.StringValue) { + if o == nil { var ret string return ret } - return *o.StringValue + + return o.StringValue } -// GetStringValueOk returns a tuple with the StringValue field value if set, nil otherwise +// GetStringValueOk returns a tuple with the StringValue field value // and a boolean to check if the value has been set. func (o *MetadataStringValue) GetStringValueOk() (*string, bool) { - if o == nil || IsNil(o.StringValue) { + if o == nil { return nil, false } - return o.StringValue, true + return &o.StringValue, true +} + +// SetStringValue sets field value +func (o *MetadataStringValue) SetStringValue(v string) { + o.StringValue = v } -// HasStringValue returns a boolean if a field has been set. -func (o *MetadataStringValue) HasStringValue() bool { - if o != nil && !IsNil(o.StringValue) { - return true +// GetMetadataType returns the MetadataType field value +func (o *MetadataStringValue) GetMetadataType() string { + if o == nil { + var ret string + return ret } - return false + return o.MetadataType } -// SetStringValue gets a reference to the given string and assigns it to the StringValue field. -func (o *MetadataStringValue) SetStringValue(v string) { - o.StringValue = &v +// GetMetadataTypeOk returns a tuple with the MetadataType field value +// and a boolean to check if the value has been set. +func (o *MetadataStringValue) GetMetadataTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.MetadataType, true +} + +// SetMetadataType sets field value +func (o *MetadataStringValue) SetMetadataType(v string) { + o.MetadataType = v } func (o MetadataStringValue) MarshalJSON() ([]byte, error) { @@ -81,9 +102,8 @@ func (o MetadataStringValue) MarshalJSON() ([]byte, error) { func (o MetadataStringValue) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - if !IsNil(o.StringValue) { - toSerialize["string_value"] = o.StringValue - } + toSerialize["string_value"] = o.StringValue + toSerialize["metadataType"] = o.MetadataType return toSerialize, nil } diff --git a/pkg/openapi/model_metadata_struct_value.go b/pkg/openapi/model_metadata_struct_value.go index 7b97af73b..30e506ed3 100644 --- a/pkg/openapi/model_metadata_struct_value.go +++ b/pkg/openapi/model_metadata_struct_value.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. @@ -20,15 +20,18 @@ var _ MappedNullable = &MetadataStructValue{} // MetadataStructValue A struct property value. type MetadataStructValue struct { // Base64 encoded bytes for struct value - StructValue *string `json:"struct_value,omitempty"` + StructValue string `json:"struct_value"` + MetadataType string `json:"metadataType"` } // NewMetadataStructValue instantiates a new MetadataStructValue object // This constructor will assign default values to properties that have it defined, // and makes sure properties required by API are set, but the set of arguments // will change when the set of required properties is changed -func NewMetadataStructValue() *MetadataStructValue { +func NewMetadataStructValue(structValue string, metadataType string) *MetadataStructValue { this := MetadataStructValue{} + this.StructValue = structValue + this.MetadataType = metadataType return &this } @@ -37,39 +40,57 @@ func NewMetadataStructValue() *MetadataStructValue { // but it doesn't guarantee that properties required by API are set func NewMetadataStructValueWithDefaults() *MetadataStructValue { this := MetadataStructValue{} + var metadataType string = "MetadataStructValue" + this.MetadataType = metadataType return &this } -// GetStructValue returns the StructValue field value if set, zero value otherwise. +// GetStructValue returns the StructValue field value func (o *MetadataStructValue) GetStructValue() string { - if o == nil || IsNil(o.StructValue) { + if o == nil { var ret string return ret } - return *o.StructValue + + return o.StructValue } -// GetStructValueOk returns a tuple with the StructValue field value if set, nil otherwise +// GetStructValueOk returns a tuple with the StructValue field value // and a boolean to check if the value has been set. func (o *MetadataStructValue) GetStructValueOk() (*string, bool) { - if o == nil || IsNil(o.StructValue) { + if o == nil { return nil, false } - return o.StructValue, true + return &o.StructValue, true +} + +// SetStructValue sets field value +func (o *MetadataStructValue) SetStructValue(v string) { + o.StructValue = v } -// HasStructValue returns a boolean if a field has been set. -func (o *MetadataStructValue) HasStructValue() bool { - if o != nil && !IsNil(o.StructValue) { - return true +// GetMetadataType returns the MetadataType field value +func (o *MetadataStructValue) GetMetadataType() string { + if o == nil { + var ret string + return ret } - return false + return o.MetadataType } -// SetStructValue gets a reference to the given string and assigns it to the StructValue field. -func (o *MetadataStructValue) SetStructValue(v string) { - o.StructValue = &v +// GetMetadataTypeOk returns a tuple with the MetadataType field value +// and a boolean to check if the value has been set. +func (o *MetadataStructValue) GetMetadataTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.MetadataType, true +} + +// SetMetadataType sets field value +func (o *MetadataStructValue) SetMetadataType(v string) { + o.MetadataType = v } func (o MetadataStructValue) MarshalJSON() ([]byte, error) { @@ -82,9 +103,8 @@ func (o MetadataStructValue) MarshalJSON() ([]byte, error) { func (o MetadataStructValue) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - if !IsNil(o.StructValue) { - toSerialize["struct_value"] = o.StructValue - } + toSerialize["struct_value"] = o.StructValue + toSerialize["metadataType"] = o.MetadataType return toSerialize, nil } diff --git a/pkg/openapi/model_metadata_value.go b/pkg/openapi/model_metadata_value.go index 0475c0b80..49c037557 100644 --- a/pkg/openapi/model_metadata_value.go +++ b/pkg/openapi/model_metadata_value.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. @@ -70,100 +70,86 @@ func MetadataStructValueAsMetadataValue(v *MetadataStructValue) MetadataValue { // Unmarshal JSON data into one of the pointers in the struct func (dst *MetadataValue) UnmarshalJSON(data []byte) error { var err error - match := 0 - // try to unmarshal data into MetadataBoolValue - err = json.Unmarshal(data, &dst.MetadataBoolValue) - if err == nil { - jsonMetadataBoolValue, _ := json.Marshal(dst.MetadataBoolValue) - if string(jsonMetadataBoolValue) == "{}" { // empty struct - dst.MetadataBoolValue = nil + // use discriminator value to speed up the lookup + var jsonDict map[string]interface{} + err = newStrictDecoder(data).Decode(&jsonDict) + if err != nil { + return fmt.Errorf("failed to unmarshal JSON into map for the discriminator lookup") + } + + // check if the discriminator value is 'MetadataBoolValue' + if jsonDict["metadataType"] == "MetadataBoolValue" { + // try to unmarshal JSON data into MetadataBoolValue + err = json.Unmarshal(data, &dst.MetadataBoolValue) + if err == nil { + return nil // data stored in dst.MetadataBoolValue, return on the first match } else { - match++ + dst.MetadataBoolValue = nil + return fmt.Errorf("failed to unmarshal MetadataValue as MetadataBoolValue: %s", err.Error()) } - } else { - dst.MetadataBoolValue = nil } - // try to unmarshal data into MetadataDoubleValue - err = json.Unmarshal(data, &dst.MetadataDoubleValue) - if err == nil { - jsonMetadataDoubleValue, _ := json.Marshal(dst.MetadataDoubleValue) - if string(jsonMetadataDoubleValue) == "{}" { // empty struct - dst.MetadataDoubleValue = nil + // check if the discriminator value is 'MetadataDoubleValue' + if jsonDict["metadataType"] == "MetadataDoubleValue" { + // try to unmarshal JSON data into MetadataDoubleValue + err = json.Unmarshal(data, &dst.MetadataDoubleValue) + if err == nil { + return nil // data stored in dst.MetadataDoubleValue, return on the first match } else { - match++ + dst.MetadataDoubleValue = nil + return fmt.Errorf("failed to unmarshal MetadataValue as MetadataDoubleValue: %s", err.Error()) } - } else { - dst.MetadataDoubleValue = nil } - // try to unmarshal data into MetadataIntValue - err = json.Unmarshal(data, &dst.MetadataIntValue) - if err == nil { - jsonMetadataIntValue, _ := json.Marshal(dst.MetadataIntValue) - if string(jsonMetadataIntValue) == "{}" { // empty struct - dst.MetadataIntValue = nil + // check if the discriminator value is 'MetadataIntValue' + if jsonDict["metadataType"] == "MetadataIntValue" { + // try to unmarshal JSON data into MetadataIntValue + err = json.Unmarshal(data, &dst.MetadataIntValue) + if err == nil { + return nil // data stored in dst.MetadataIntValue, return on the first match } else { - match++ + dst.MetadataIntValue = nil + return fmt.Errorf("failed to unmarshal MetadataValue as MetadataIntValue: %s", err.Error()) } - } else { - dst.MetadataIntValue = nil } - // try to unmarshal data into MetadataProtoValue - err = json.Unmarshal(data, &dst.MetadataProtoValue) - if err == nil { - jsonMetadataProtoValue, _ := json.Marshal(dst.MetadataProtoValue) - if string(jsonMetadataProtoValue) == "{}" { // empty struct - dst.MetadataProtoValue = nil + // check if the discriminator value is 'MetadataProtoValue' + if jsonDict["metadataType"] == "MetadataProtoValue" { + // try to unmarshal JSON data into MetadataProtoValue + err = json.Unmarshal(data, &dst.MetadataProtoValue) + if err == nil { + return nil // data stored in dst.MetadataProtoValue, return on the first match } else { - match++ + dst.MetadataProtoValue = nil + return fmt.Errorf("failed to unmarshal MetadataValue as MetadataProtoValue: %s", err.Error()) } - } else { - dst.MetadataProtoValue = nil } - // try to unmarshal data into MetadataStringValue - err = json.Unmarshal(data, &dst.MetadataStringValue) - if err == nil { - jsonMetadataStringValue, _ := json.Marshal(dst.MetadataStringValue) - if string(jsonMetadataStringValue) == "{}" { // empty struct - dst.MetadataStringValue = nil + // check if the discriminator value is 'MetadataStringValue' + if jsonDict["metadataType"] == "MetadataStringValue" { + // try to unmarshal JSON data into MetadataStringValue + err = json.Unmarshal(data, &dst.MetadataStringValue) + if err == nil { + return nil // data stored in dst.MetadataStringValue, return on the first match } else { - match++ + dst.MetadataStringValue = nil + return fmt.Errorf("failed to unmarshal MetadataValue as MetadataStringValue: %s", err.Error()) } - } else { - dst.MetadataStringValue = nil } - // try to unmarshal data into MetadataStructValue - err = json.Unmarshal(data, &dst.MetadataStructValue) - if err == nil { - jsonMetadataStructValue, _ := json.Marshal(dst.MetadataStructValue) - if string(jsonMetadataStructValue) == "{}" { // empty struct - dst.MetadataStructValue = nil + // check if the discriminator value is 'MetadataStructValue' + if jsonDict["metadataType"] == "MetadataStructValue" { + // try to unmarshal JSON data into MetadataStructValue + err = json.Unmarshal(data, &dst.MetadataStructValue) + if err == nil { + return nil // data stored in dst.MetadataStructValue, return on the first match } else { - match++ + dst.MetadataStructValue = nil + return fmt.Errorf("failed to unmarshal MetadataValue as MetadataStructValue: %s", err.Error()) } - } else { - dst.MetadataStructValue = nil } - if match > 1 { // more than 1 match - // reset to nil - dst.MetadataBoolValue = nil - dst.MetadataDoubleValue = nil - dst.MetadataIntValue = nil - dst.MetadataProtoValue = nil - dst.MetadataStringValue = nil - dst.MetadataStructValue = nil - - return fmt.Errorf("data matches more than one schema in oneOf(MetadataValue)") - } else if match == 1 { - return nil // exactly one match - } else { // no match - return fmt.Errorf("data failed to match schemas in oneOf(MetadataValue)") - } + return nil } // Marshal data from the first non-nil pointers in the struct to JSON diff --git a/pkg/openapi/model_model_artifact.go b/pkg/openapi/model_model_artifact.go index 1daa99341..ba0d50af6 100644 --- a/pkg/openapi/model_model_artifact.go +++ b/pkg/openapi/model_model_artifact.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_model_artifact_create.go b/pkg/openapi/model_model_artifact_create.go index 353ac655d..16924f753 100644 --- a/pkg/openapi/model_model_artifact_create.go +++ b/pkg/openapi/model_model_artifact_create.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_model_artifact_list.go b/pkg/openapi/model_model_artifact_list.go index f31c95a1f..42d8e9d34 100644 --- a/pkg/openapi/model_model_artifact_list.go +++ b/pkg/openapi/model_model_artifact_list.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_model_artifact_update.go b/pkg/openapi/model_model_artifact_update.go index 3d4e7d597..60d38ea8e 100644 --- a/pkg/openapi/model_model_artifact_update.go +++ b/pkg/openapi/model_model_artifact_update.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_model_version.go b/pkg/openapi/model_model_version.go index fd54c8ad7..b4f5a79f8 100644 --- a/pkg/openapi/model_model_version.go +++ b/pkg/openapi/model_model_version.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_model_version_create.go b/pkg/openapi/model_model_version_create.go index 36c84624a..6786dd960 100644 --- a/pkg/openapi/model_model_version_create.go +++ b/pkg/openapi/model_model_version_create.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_model_version_list.go b/pkg/openapi/model_model_version_list.go index 907df555c..4577658ae 100644 --- a/pkg/openapi/model_model_version_list.go +++ b/pkg/openapi/model_model_version_list.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_model_version_state.go b/pkg/openapi/model_model_version_state.go index 09a408c4c..b9713aaee 100644 --- a/pkg/openapi/model_model_version_state.go +++ b/pkg/openapi/model_model_version_state.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_model_version_update.go b/pkg/openapi/model_model_version_update.go index ed280546e..f9de3d7be 100644 --- a/pkg/openapi/model_model_version_update.go +++ b/pkg/openapi/model_model_version_update.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_order_by_field.go b/pkg/openapi/model_order_by_field.go index 2b4ee75e0..d33ec83a4 100644 --- a/pkg/openapi/model_order_by_field.go +++ b/pkg/openapi/model_order_by_field.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_registered_model.go b/pkg/openapi/model_registered_model.go index f98f7f639..b045ab46e 100644 --- a/pkg/openapi/model_registered_model.go +++ b/pkg/openapi/model_registered_model.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_registered_model_create.go b/pkg/openapi/model_registered_model_create.go index eed1560d8..98311afca 100644 --- a/pkg/openapi/model_registered_model_create.go +++ b/pkg/openapi/model_registered_model_create.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_registered_model_list.go b/pkg/openapi/model_registered_model_list.go index 7c412830d..f1c7daa52 100644 --- a/pkg/openapi/model_registered_model_list.go +++ b/pkg/openapi/model_registered_model_list.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_registered_model_state.go b/pkg/openapi/model_registered_model_state.go index 0e49818db..9af7b4d4b 100644 --- a/pkg/openapi/model_registered_model_state.go +++ b/pkg/openapi/model_registered_model_state.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_registered_model_update.go b/pkg/openapi/model_registered_model_update.go index 8f626d6a9..bf19ca668 100644 --- a/pkg/openapi/model_registered_model_update.go +++ b/pkg/openapi/model_registered_model_update.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_serve_model.go b/pkg/openapi/model_serve_model.go index 27fb1149b..338aa8022 100644 --- a/pkg/openapi/model_serve_model.go +++ b/pkg/openapi/model_serve_model.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_serve_model_create.go b/pkg/openapi/model_serve_model_create.go index fe436a6d5..dcacef1a7 100644 --- a/pkg/openapi/model_serve_model_create.go +++ b/pkg/openapi/model_serve_model_create.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_serve_model_list.go b/pkg/openapi/model_serve_model_list.go index 45a380883..8041deed3 100644 --- a/pkg/openapi/model_serve_model_list.go +++ b/pkg/openapi/model_serve_model_list.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_serve_model_update.go b/pkg/openapi/model_serve_model_update.go index b418c3301..c21e64d85 100644 --- a/pkg/openapi/model_serve_model_update.go +++ b/pkg/openapi/model_serve_model_update.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_serving_environment.go b/pkg/openapi/model_serving_environment.go index 4b45985c1..c68745366 100644 --- a/pkg/openapi/model_serving_environment.go +++ b/pkg/openapi/model_serving_environment.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_serving_environment_create.go b/pkg/openapi/model_serving_environment_create.go index e445e7958..27001c3aa 100644 --- a/pkg/openapi/model_serving_environment_create.go +++ b/pkg/openapi/model_serving_environment_create.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_serving_environment_list.go b/pkg/openapi/model_serving_environment_list.go index f0eadef94..a1ff7d946 100644 --- a/pkg/openapi/model_serving_environment_list.go +++ b/pkg/openapi/model_serving_environment_list.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_serving_environment_update.go b/pkg/openapi/model_serving_environment_update.go index f0818fe73..1da97af9f 100644 --- a/pkg/openapi/model_serving_environment_update.go +++ b/pkg/openapi/model_serving_environment_update.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/model_sort_order.go b/pkg/openapi/model_sort_order.go index 6e1416b47..eeb952b3d 100644 --- a/pkg/openapi/model_sort_order.go +++ b/pkg/openapi/model_sort_order.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/response.go b/pkg/openapi/response.go index 1d5cbaf7d..ac56e649b 100644 --- a/pkg/openapi/response.go +++ b/pkg/openapi/response.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/pkg/openapi/utils.go b/pkg/openapi/utils.go index 2ccc6542c..148c63a25 100644 --- a/pkg/openapi/utils.go +++ b/pkg/openapi/utils.go @@ -3,7 +3,7 @@ Model Registry REST API REST API for Model Registry to create and manage ML model metadata -API version: v1alpha1 +API version: v1alpha2 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/scripts/gen_type_asserts.sh b/scripts/gen_type_asserts.sh index bb2e0fddd..a9a3458c3 100755 --- a/scripts/gen_type_asserts.sh +++ b/scripts/gen_type_asserts.sh @@ -2,6 +2,8 @@ set -e +ROOT_FOLDER="${ROOT_FOLDER:-..}" + ASSERT_FILE_PATH="internal/server/openapi/type_asserts.go" PATCH="./patches/type_asserts.patch" @@ -50,4 +52,6 @@ for file in internal/server/openapi/model_*; do fi done +gofmt -w $ROOT_FOLDER/internal/server/openapi/type_asserts.go + git apply "$PATCH" diff --git a/test/robot/MRkeywords.resource b/test/robot/MRkeywords.resource index 1f66bf642..048fcac65 100644 --- a/test/robot/MRkeywords.resource +++ b/test/robot/MRkeywords.resource @@ -13,7 +13,7 @@ I create a RegisteredModel having [Arguments] ${name} IF $MODE == "REST" ${data} Create Dictionary name=${name} - ${resp} POST url=http://${MR_HOST}:8080/api/model_registry/v1alpha1/registered_models json=${data} expected_status=201 + ${resp} POST url=http://${MR_HOST}:8080/api/model_registry/v1alpha2/registered_models json=${data} expected_status=201 Log to console ${resp.json()} ${result} Set Variable ${resp.json()['id']} ELSE @@ -27,7 +27,7 @@ I create a RegisteredModel having I create a RegisteredModel [Arguments] ${payload} IF $MODE == "REST" - ${resp} POST url=http://${MR_HOST}:8080/api/model_registry/v1alpha1/registered_models json=&{payload} expected_status=201 + ${resp} POST url=http://${MR_HOST}:8080/api/model_registry/v1alpha2/registered_models json=&{payload} expected_status=201 Log to console ${resp.json()} ${result} Set Variable ${resp.json()['id']} ELSE @@ -41,7 +41,7 @@ I create a child ModelVersion having [Arguments] ${registeredModelID} ${name} IF $MODE == "REST" ${data}= Create Dictionary name=${name} registeredModelID=${registeredModelID} - ${resp}= POST url=http://${MR_HOST}:8080/api/model_registry/v1alpha1/model_versions json=${data} expected_status=201 + ${resp}= POST url=http://${MR_HOST}:8080/api/model_registry/v1alpha2/model_versions json=${data} expected_status=201 Log to console ${resp.json()} ${result} Set Variable ${resp.json()['id']} ELSE @@ -56,7 +56,7 @@ I create a child ModelVersion [Arguments] ${registeredModelID} ${payload} IF $MODE == "REST" Set To Dictionary ${payload} registeredModelID=${registeredModelID} - ${resp}= POST url=http://${MR_HOST}:8080/api/model_registry/v1alpha1/model_versions json=&{payload} expected_status=201 + ${resp}= POST url=http://${MR_HOST}:8080/api/model_registry/v1alpha2/model_versions json=&{payload} expected_status=201 Log to console ${resp.json()} ${result} Set Variable ${resp.json()['id']} ELSE @@ -71,7 +71,7 @@ I create a child ModelArtifact having IF $MODE == "REST" ${data}= Create Dictionary uri=${uri} artifactType=model-artifact Log to console ${data} - ${resp}= POST url=http://${MR_HOST}:8080/api/model_registry/v1alpha1/model_versions/${modelversionId}/artifacts json=${data} expected_status=201 + ${resp}= POST url=http://${MR_HOST}:8080/api/model_registry/v1alpha2/model_versions/${modelversionId}/artifacts json=${data} expected_status=201 Log to console ${resp.json()} ${result} Set Variable ${resp.json()['id']} ELSE @@ -85,7 +85,7 @@ I create a child ModelArtifact having I create a child ModelArtifact [Arguments] ${modelversionId} ${payload} IF $MODE == "REST" - ${resp}= POST url=http://${MR_HOST}:8080/api/model_registry/v1alpha1/model_versions/${modelversionId}/artifacts json=&{payload} expected_status=201 + ${resp}= POST url=http://${MR_HOST}:8080/api/model_registry/v1alpha2/model_versions/${modelversionId}/artifacts json=&{payload} expected_status=201 Log to console ${resp.json()} ${result} Set Variable ${resp.json()['id']} ELSE @@ -98,7 +98,7 @@ I create a child ModelArtifact I create a child Artifact [Arguments] ${modelversionId} ${payload} IF $MODE == "REST" - ${resp}= POST url=http://${MR_HOST}:8080/api/model_registry/v1alpha1/model_versions/${modelversionId}/artifacts json=&{payload} expected_status=201 + ${resp}= POST url=http://${MR_HOST}:8080/api/model_registry/v1alpha2/model_versions/${modelversionId}/artifacts json=&{payload} expected_status=201 Log to console ${resp.json()} ${result} Set Variable ${resp.json()['id']} ELSE @@ -111,7 +111,7 @@ I create a child Artifact I get RegisteredModelByID [Arguments] ${id} IF $MODE == "REST" - ${resp}= GET url=http://${MR_HOST}:8080/api/model_registry/v1alpha1/registered_models/${id} expected_status=200 + ${resp}= GET url=http://${MR_HOST}:8080/api/model_registry/v1alpha2/registered_models/${id} expected_status=200 ${result} Set Variable ${resp.json()} Log to console ${resp.json()} ELSE @@ -124,7 +124,7 @@ I get RegisteredModelByID I get ModelVersionByID [Arguments] ${id} IF $MODE == "REST" - ${resp}= GET url=http://${MR_HOST}:8080/api/model_registry/v1alpha1/model_versions/${id} expected_status=200 + ${resp}= GET url=http://${MR_HOST}:8080/api/model_registry/v1alpha2/model_versions/${id} expected_status=200 ${result} Set Variable ${resp.json()} Log to console ${resp.json()} ELSE @@ -137,7 +137,7 @@ I get ModelVersionByID I get ModelArtifactByID [Arguments] ${id} IF $MODE == "REST" - ${resp}= GET url=http://${MR_HOST}:8080/api/model_registry/v1alpha1/model_artifacts/${id} expected_status=200 + ${resp}= GET url=http://${MR_HOST}:8080/api/model_registry/v1alpha2/model_artifacts/${id} expected_status=200 ${result} Set Variable ${resp.json()} Log to console ${resp.json()} ELSE @@ -150,7 +150,7 @@ I get ModelArtifactByID I get ArtifactsByModelVersionID [Arguments] ${id} IF $MODE == "REST" - ${resp}= GET url=http://${MR_HOST}:8080/api/model_registry/v1alpha1/model_versions/${id}/artifacts expected_status=200 + ${resp}= GET url=http://${MR_HOST}:8080/api/model_registry/v1alpha2/model_versions/${id}/artifacts expected_status=200 ${result} Set Variable ${resp.json()} Log to console ${resp.json()} ELSE diff --git a/test/scripts/rest.sh b/test/scripts/rest.sh index d7cfa8b34..4c0d612c5 100755 --- a/test/scripts/rest.sh +++ b/test/scripts/rest.sh @@ -24,7 +24,7 @@ MR_HOSTNAME="http://modelregistry-sample-http-$MR_NAMESPACE.apps.$OCP_CLUSTER_NA timestamp=$(date +"%Y%m%d%H%M%S") rm_name="demo-$timestamp" -rm_id=$(make_post_extract_id "$MR_HOSTNAME/api/model_registry/v1alpha1/registered_models" '{ +rm_id=$(make_post_extract_id "$MR_HOSTNAME/api/model_registry/v1alpha2/registered_models" '{ "description": "lorem ipsum registered model", "name": "'"$rm_name"'" }') @@ -34,7 +34,7 @@ if [ $? -ne 0 ]; then fi echo "Registered Model ID: $rm_id" -mv_id=$(make_post_extract_id "$MR_HOSTNAME/api/model_registry/v1alpha1/model_versions" '{ +mv_id=$(make_post_extract_id "$MR_HOSTNAME/api/model_registry/v1alpha2/model_versions" '{ "description": "lorem ipsum model version", "name": "v1", "author": "John Doe", @@ -47,7 +47,7 @@ fi echo "Model Version ID: $mv_id" RAW_ML_MODEL_URI='https://huggingface.co/tarilabs/mnist/resolve/v1.nb20231206162408/mnist.onnx' -ma_id=$(make_post_extract_id "$MR_HOSTNAME/api/model_registry/v1alpha1/model_versions/$mv_id/artifacts" '{ +ma_id=$(make_post_extract_id "$MR_HOSTNAME/api/model_registry/v1alpha2/model_versions/$mv_id/artifacts" '{ "description": "lorem ipsum model artifact", "uri": "'"$RAW_ML_MODEL_URI"'", "name": "mnist", @@ -90,7 +90,7 @@ spec: EOF # TODO this will continue once we have MC PR merged from: https://github.com/opendatahub-io/odh-model-controller/pull/135 -iss_mr=$(curl -s -X 'GET' "$MR_HOSTNAME/api/model_registry/v1alpha1/inference_services" \ +iss_mr=$(curl -s -X 'GET' "$MR_HOSTNAME/api/model_registry/v1alpha2/inference_services" \ -H 'accept: application/json') echo "InferenceService entities on MR:"