diff --git a/.gitignore b/.gitignore index ef1719027..0d0c46013 100644 --- a/.gitignore +++ b/.gitignore @@ -27,7 +27,7 @@ metadata.sqlite.db # Ignore go vendor and code coverage files vendor -coverage.txt +coverage.* # Robot Framework files log.html diff --git a/Makefile b/Makefile index 9147383f0..fe6c99339 100644 --- a/Makefile +++ b/Makefile @@ -37,19 +37,19 @@ api/grpc/ml_metadata/proto/metadata_source.proto: mkdir -p api/grpc/ml_metadata/proto/ cd api/grpc/ml_metadata/proto/ && \ curl -LO "https://raw.githubusercontent.com/google/ml-metadata/v${MLMD_VERSION}/ml_metadata/proto/metadata_source.proto" && \ - sed -i 's#syntax = "proto[23]";#&\noption go_package = "github.com/opendatahub-io/model-registry/internal/ml_metadata/proto";#' metadata_source.proto + sed -i 's#syntax = "proto[23]";#&\noption go_package = "github.com/kubeflow/model-registry/internal/ml_metadata/proto";#' metadata_source.proto api/grpc/ml_metadata/proto/metadata_store.proto: mkdir -p api/grpc/ml_metadata/proto/ cd api/grpc/ml_metadata/proto/ && \ curl -LO "https://raw.githubusercontent.com/google/ml-metadata/v${MLMD_VERSION}/ml_metadata/proto/metadata_store.proto" && \ - sed -i 's#syntax = "proto[23]";#&\noption go_package = "github.com/opendatahub-io/model-registry/internal/ml_metadata/proto";#' metadata_store.proto + sed -i 's#syntax = "proto[23]";#&\noption go_package = "github.com/kubeflow/model-registry/internal/ml_metadata/proto";#' metadata_store.proto api/grpc/ml_metadata/proto/metadata_store_service.proto: mkdir -p api/grpc/ml_metadata/proto/ cd api/grpc/ml_metadata/proto/ && \ curl -LO "https://raw.githubusercontent.com/google/ml-metadata/v${MLMD_VERSION}/ml_metadata/proto/metadata_store_service.proto" && \ - sed -i 's#syntax = "proto[23]";#&\noption go_package = "github.com/opendatahub-io/model-registry/internal/ml_metadata/proto";#' metadata_store_service.proto + sed -i 's#syntax = "proto[23]";#&\noption go_package = "github.com/kubeflow/model-registry/internal/ml_metadata/proto";#' metadata_store_service.proto internal/ml_metadata/proto/%.pb.go: api/grpc/ml_metadata/proto/%.proto protoc -I./api/grpc --go_out=./internal --go_opt=paths=source_relative \ @@ -59,7 +59,7 @@ internal/ml_metadata/proto/%.pb.go: api/grpc/ml_metadata/proto/%.proto gen/grpc: internal/ml_metadata/proto/metadata_store.pb.go internal/ml_metadata/proto/metadata_store_service.pb.go internal/converter/generated/converter.go: internal/converter/*.go - ${GOVERTER} gen github.com/opendatahub-io/model-registry/internal/converter/ + ${GOVERTER} gen github.com/kubeflow/model-registry/internal/converter/ .PHONY: gen/converter gen/converter: gen/grpc internal/converter/generated/converter.go diff --git a/README.md b/README.md index a37676c61..1be7dd5f8 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ Model registry provides a central repository for model developers to store and m - Red Hat drives the project's development through Open Source principles, ensuring transparency, sustainability, and community ownership. - Red Hat values the Kubeflow community and commits to providing a minimum of 12 months' notice before ending project maintenance after the initial release. - -[](https://codecov.io/github/opendatahub-io/model-registry) + +[](https://codecov.io/github/kubeflow/model-registry) ## Pre-requisites: - go >= 1.19 @@ -19,14 +19,14 @@ Model registry provides a central repository for model developers to store and m The model registry proxy server implementation follows a contract-first approach, where the contract is identified by [model-registry.yaml](api/openapi/model-registry.yaml) OpenAPI specification. -You can also easily display the latest OpenAPI contract for model-registry in a Swagger-like editor directly from this repository; for example, [here](https://editor.swagger.io/?url=https://raw.githubusercontent.com/opendatahub-io/model-registry/main/api/openapi/model-registry.yaml). +You can also easily display the latest OpenAPI contract for model-registry in a Swagger-like editor directly from this repository; for example, [here](https://editor.swagger.io/?url=https://raw.githubusercontent.com/kubeflow/model-registry/main/api/openapi/model-registry.yaml). ### Starting the OpenAPI Proxy Server Run the following command to start the OpenAPI proxy server from source: ```shell make run/proxy ``` -The proxy service implements the OpenAPI defined in [model-registry.yaml](api/openapi/model-registry.yaml) to create an Open Data Hub specific REST API on top of the existing ml-metadata server. +The proxy service implements the OpenAPI defined in [model-registry.yaml](api/openapi/model-registry.yaml) to create a Model Registry specific REST API on top of the existing ml-metadata server. > **NOTE** The ml-metadata server must be running and accessible from the environment where model-registry starts up. diff --git a/api/grpc/ml_metadata/proto/metadata_store.proto b/api/grpc/ml_metadata/proto/metadata_store.proto index 8e59ff6c2..a3128e589 100644 --- a/api/grpc/ml_metadata/proto/metadata_store.proto +++ b/api/grpc/ml_metadata/proto/metadata_store.proto @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ syntax = "proto2"; -option go_package = "github.com/opendatahub-io/model-registry/internal/ml_metadata/proto"; +option go_package = "github.com/kubeflow/model-registry/internal/ml_metadata/proto"; package ml_metadata; diff --git a/api/grpc/ml_metadata/proto/metadata_store_service.proto b/api/grpc/ml_metadata/proto/metadata_store_service.proto index f4a169199..9c3b4ce3a 100644 --- a/api/grpc/ml_metadata/proto/metadata_store_service.proto +++ b/api/grpc/ml_metadata/proto/metadata_store_service.proto @@ -14,7 +14,7 @@ limitations under the License. ==============================================================================*/ syntax = "proto2"; -option go_package = "github.com/opendatahub-io/model-registry/internal/ml_metadata/proto"; +option go_package = "github.com/kubeflow/model-registry/internal/ml_metadata/proto"; package ml_metadata; diff --git a/api/openapi/model-registry.yaml b/api/openapi/model-registry.yaml index 7fd4d0651..fdf1c604c 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. @@ -971,24 +971,26 @@ components: ModelArtifact: description: An ML model artifact. type: object + required: + - artifactType + properties: + artifactType: + type: string + default: "model-artifact" allOf: - $ref: "#/components/schemas/BaseArtifact" - $ref: "#/components/schemas/ModelArtifactCreate" - - type: object - properties: - artifactType: - type: string - default: "model-artifact" DocArtifact: description: A document. type: object + required: + - artifactType + properties: + artifactType: + type: string + default: "doc-artifact" allOf: - $ref: "#/components/schemas/BaseArtifact" - - type: object - properties: - artifactType: - type: string - default: "doc-artifact" RegisteredModel: description: A registered model in model registry. A registered model has ModelVersion children. allOf: @@ -1102,37 +1104,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 +1183,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" @@ -1293,12 +1347,6 @@ components: allOf: - $ref: "#/components/schemas/BaseArtifactCreate" - $ref: "#/components/schemas/BaseResource" - - required: - - artifactType - type: object - properties: - artifactType: - type: string ServingEnvironmentList: description: List of ServingEnvironments. type: object diff --git a/clients/python/README.md b/clients/python/README.md index febca492e..e542e8e2f 100644 --- a/clients/python/README.md +++ b/clients/python/README.md @@ -1,6 +1,6 @@ # Model Registry Python Client -[](https://github.com/opendatahub-io/model-registry) +[](https://github.com/kubeflow/model-registry) [](../../../LICENSE) This library provides a high level interface for interacting with a model registry server. @@ -85,7 +85,7 @@ Use `nox -l` to list sessions and execute them using `nox -s [session]`. ### Running Locally on Mac M1 or M2 (arm64 architecture) -If you want run tests locally you will need to set up a colima develeopment environment using the instructions [here](https://github.com/opendatahub-io/model-registry/blob/main/CONTRIBUTING.md#colima) +If you want run tests locally you will need to set up a colima develeopment environment using the instructions [here](https://github.com/kubeflow/model-registry/blob/main/CONTRIBUTING.md#colima) You will also have to change the package source to one compatible with ARM64 architecture. This can be actioned by uncommenting lines 14 or 15 in the pyproject.toml file. Run the following command after you have uncommented the line. diff --git a/clients/python/pyproject.toml b/clients/python/pyproject.toml index ebceb5003..11e214f99 100644 --- a/clients/python/pyproject.toml +++ b/clients/python/pyproject.toml @@ -1,14 +1,14 @@ [tool.poetry] name = "model-registry" version = "0.1.1" -description = "Client for Red Hat OpenDataHub Model Registry" +description = "Client for Kubeflow Model Registry" authors = ["Isabella Basso do Amaral <idoamara@redhat.com>"] license = "Apache-2.0" readme = "README.md" -homepage = "https://github.com/opendatahub-io/model-registry" +homepage = "https://github.com/kubeflow/model-registry" [tool.poetry.urls] -"Issues" = "https://github.com/opendatahub-io/model-registry/issues" +"Issues" = "https://github.com/kubeflow/model-registry/issues" [tool.poetry.dependencies] python = ">= 3.9, < 3.11" diff --git a/clients/python/src/model_registry/types/base.py b/clients/python/src/model_registry/types/base.py index 723813dc9..1d67bcce3 100644 --- a/clients/python/src/model_registry/types/base.py +++ b/clients/python/src/model_registry/types/base.py @@ -20,9 +20,9 @@ def get_proto_type_name(cls) -> str: """Name of the proto type. Returns: - Name of the class prefixed with `odh.` + Name of the class prefixed with `kf.` """ - return f"odh.{cls.__name__}" + return f"kf.{cls.__name__}" @property @abstractmethod diff --git a/cmd/proxy.go b/cmd/proxy.go index f3ef67932..f940ce56d 100644 --- a/cmd/proxy.go +++ b/cmd/proxy.go @@ -7,9 +7,9 @@ import ( "time" "github.com/golang/glog" - "github.com/opendatahub-io/model-registry/internal/mlmdtypes" - "github.com/opendatahub-io/model-registry/internal/server/openapi" - "github.com/opendatahub-io/model-registry/pkg/core" + "github.com/kubeflow/model-registry/internal/mlmdtypes" + "github.com/kubeflow/model-registry/internal/server/openapi" + "github.com/kubeflow/model-registry/pkg/core" "github.com/spf13/cobra" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" @@ -49,11 +49,12 @@ func runProxyServer(cmd *cobra.Command, args []string) error { defer conn.Close() glog.Infof("connected to MLMD server") - _, err = mlmdtypes.CreateMLMDTypes(conn) + mlmdTypeNamesConfig := mlmdtypes.NewMLMDTypeNamesConfigFromDefaults() + _, err = mlmdtypes.CreateMLMDTypes(conn, mlmdTypeNamesConfig) if err != nil { return fmt.Errorf("error creating MLMD types: %v", err) } - service, err := core.NewModelRegistryService(conn) + service, err := core.NewModelRegistryService(conn, mlmdTypeNamesConfig) if err != nil { return fmt.Errorf("error creating core service: %v", err) } 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/docs/mr_go_library.md b/docs/mr_go_library.md index 1754eec62..3f57cdee2 100644 --- a/docs/mr_go_library.md +++ b/docs/mr_go_library.md @@ -6,7 +6,7 @@ The Model Registry Service go library provides a convenient interface for managi The recommended way is using `go get`, from your custom project run: ```bash -go get github.com/opendatahub-io/model-registry +go get github.com/kubeflow/model-registry ``` ## Getting Started @@ -50,7 +50,7 @@ Once the gRPC connection is setup, let's create the `ModelRegistryService`: ```go import ( "fmt" - "github.com/opendatahub-io/model-registry/pkg/core" + "github.com/kubeflow/model-registry/pkg/core" ) service, err := core.NewModelRegistryService(conn) diff --git a/docs/remote_only_packaging_of_MLMD_Python_lib.md b/docs/remote_only_packaging_of_MLMD_Python_lib.md index 57bd0c655..2d6a73086 100644 --- a/docs/remote_only_packaging_of_MLMD_Python_lib.md +++ b/docs/remote_only_packaging_of_MLMD_Python_lib.md @@ -9,7 +9,7 @@ whilst also making it [architecture specific](https://pypi.org/project/ml-metada The [Model Registry project](https://docs.google.com/document/d/1G-pjdGaS2kLELsB5kYk_D4AmH-fTfnCnJOhJ8xENjx0/edit?usp=sharing) (MR) is built on top of MLMD. The Go implementation interfaces with the MLMD server via gRPC, typically available as a Docker container. -The [MR Python client](https://github.com/opendatahub-io/model-registry/tree/main/clients/python#readme) wraps the MLMD client. +The [MR Python client](https://github.com/kubeflow/model-registry/tree/main/clients/python#readme) wraps the MLMD client. As the MLMD client is architecture specific, so is the MR Python client, which **severely limits the targets it can run on**, as it only supports x86-64. This **poses many challenges to contributors** using other CPU architectures, specially ARM, as that's become more prevalent in recent years. @@ -97,7 +97,7 @@ Cons: ### Packaging Option2: mix resulting artifact inside Model Registry repo -This delivery option considers placing the resulting artifact by executing the exercise from the alternative selected above and placing it directly inside the Model Registry repo, with the python client source [location](https://github.com/opendatahub-io/model-registry/tree/main/clients/python). (for analogy, this is similar to “shading”/”uberjar” in Java world for those familiar with the concept) +This delivery option considers placing the resulting artifact by executing the exercise from the alternative selected above and placing it directly inside the Model Registry repo, with the python client source [location](https://github.com/kubeflow/model-registry/tree/main/clients/python). (for analogy, this is similar to “shading”/”uberjar” in Java world for those familiar with the concept) Pros: @@ -117,10 +117,10 @@ Based on analysis of the alternatives provided, we decided to further pursue: - the repackaging by **Alternative B** because makes it actually easier to demonstrate the steps and modifications required using as baseline the upstream repo. - the distribution by **Packaging Option1** because it will make it easier to "revert" to the upstream `ml-metadata` dependency if upstream will publish for all architectures, OSes, etc. and as the pros outweight considered cons. -MR python client [tests](https://github.com/opendatahub-io/model-registry/blob/259b39320953bf05942dcec1fb5ec74f7eb5d4a7/clients/python/tests/conftest.py#L19) should be rewritten using Testcontainers, and not leveraging the embedded server (already done with [this PR](https://github.com/opendatahub-io/model-registry/pull/225)). +MR python client [tests](https://github.com/kubeflow/model-registry/blob/259b39320953bf05942dcec1fb5ec74f7eb5d4a7/clients/python/tests/conftest.py#L19) should be rewritten using Testcontainers, and not leveraging the embedded server (already done with [this PR](https://github.com/kubeflow/model-registry/pull/225)). -The group concur this is a sensible approach ([recorded here](https://redhat-internal.slack.com/archives/C05LGBNUK9C/p1700763823505259?thread_ts=1700427888.670999&cid=C05LGBNUK9C)). +The group concur this is a sensible approach. -This change would also better align the test approach used for the MR python client, by aligning with the same strategy of the MR core Go layer test framework, which already makes use of Testcontainers for Go ([reference](https://github.com/opendatahub-io/model-registry/blob/259b39320953bf05942dcec1fb5ec74f7eb5d4a7/internal/testutils/test_container_utils.go#L59)). +This change would also better align the test approach used for the MR python client, by aligning with the same strategy of the MR core Go layer test framework, which already makes use of Testcontainers for Go ([reference](https://github.com/kubeflow/model-registry/blob/259b39320953bf05942dcec1fb5ec74f7eb5d4a7/internal/testutils/test_container_utils.go#L59)). This would allow to update the constraint on the version for the `attrs` dependency as part of this activity. diff --git a/go.mod b/go.mod index 18e274946..e54854aed 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/opendatahub-io/model-registry +module github.com/kubeflow/model-registry go 1.19 @@ -11,7 +11,7 @@ require ( github.com/spf13/viper v1.18.2 github.com/stretchr/testify v1.8.4 github.com/testcontainers/testcontainers-go v0.26.0 - google.golang.org/grpc v1.61.1 + google.golang.org/grpc v1.62.0 google.golang.org/protobuf v1.32.0 ) @@ -71,10 +71,10 @@ require ( github.com/yusufpapurcu/wmi v1.2.3 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 golang.org/x/mod v0.12.0 // indirect - golang.org/x/net v0.19.0 // indirect - golang.org/x/sys v0.15.0 // indirect + golang.org/x/net v0.20.0 // indirect + golang.org/x/sys v0.16.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.13.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect gopkg.in/ini.v1 v1.67.0 // indirect ) diff --git a/go.sum b/go.sum index 06da93d57..9b7412deb 100644 --- a/go.sum +++ b/go.sum @@ -154,12 +154,12 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= -golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= +golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -170,8 +170,8 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= @@ -187,10 +187,10 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f h1:ultW7fxlIvee4HYrtnaRPon9HpEgFk5zYpmfMgtKB5I= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f/go.mod h1:L9KNLi232K1/xB6f7AlSX692koaRnKaWSR0stBki0Yc= -google.golang.org/grpc v1.61.1 h1:kLAiWrZs7YeDM6MumDe7m3y4aM6wacLzM1Y/wiLP9XY= -google.golang.org/grpc v1.61.1/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 h1:AjyfHzEPEFp/NpvfN5g+KDla3EMojjhRVZc1i7cj+oM= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80/go.mod h1:PAREbraiVEVGVdTZsVWjSbbTtSyGbAgIIvni8a8CD5s= +google.golang.org/grpc v1.62.0 h1:HQKZ/fa1bXkX1oFOvSjmZEUL8wLSaZTjCcLAlmZRtdk= +google.golang.org/grpc v1.62.0/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= diff --git a/internal/apiutils/api_utils.go b/internal/apiutils/api_utils.go index ac28515c0..6c5a10dac 100644 --- a/internal/apiutils/api_utils.go +++ b/internal/apiutils/api_utils.go @@ -1,10 +1,10 @@ package apiutils import ( - "github.com/opendatahub-io/model-registry/internal/converter" - "github.com/opendatahub-io/model-registry/internal/ml_metadata/proto" - "github.com/opendatahub-io/model-registry/pkg/api" - model "github.com/opendatahub-io/model-registry/pkg/openapi" + "github.com/kubeflow/model-registry/internal/converter" + "github.com/kubeflow/model-registry/internal/ml_metadata/proto" + "github.com/kubeflow/model-registry/pkg/api" + model "github.com/kubeflow/model-registry/pkg/openapi" ) func BuildListOperationOptions(listOptions api.ListOptions) (*proto.ListOperationOptions, error) { diff --git a/internal/constants/constants.go b/internal/constants/constants.go deleted file mode 100644 index eabfa9681..000000000 --- a/internal/constants/constants.go +++ /dev/null @@ -1,12 +0,0 @@ -package constants - -// MLMD type names -const ( - RegisteredModelTypeName = "odh.RegisteredModel" - ModelVersionTypeName = "odh.ModelVersion" - ModelArtifactTypeName = "odh.ModelArtifact" - DocArtifactTypeName = "odh.DocArtifact" - ServingEnvironmentTypeName = "odh.ServingEnvironment" - InferenceServiceTypeName = "odh.InferenceService" - ServeModelTypeName = "odh.ServeModel" -) diff --git a/internal/converter/generated/mlmd_openapi_converter.gen.go b/internal/converter/generated/mlmd_openapi_converter.gen.go index 92ab100f9..192341d57 100755 --- a/internal/converter/generated/mlmd_openapi_converter.gen.go +++ b/internal/converter/generated/mlmd_openapi_converter.gen.go @@ -4,9 +4,9 @@ package generated import ( "fmt" - converter "github.com/opendatahub-io/model-registry/internal/converter" - proto "github.com/opendatahub-io/model-registry/internal/ml_metadata/proto" - openapi "github.com/opendatahub-io/model-registry/pkg/openapi" + converter "github.com/kubeflow/model-registry/internal/converter" + proto "github.com/kubeflow/model-registry/internal/ml_metadata/proto" + openapi "github.com/kubeflow/model-registry/pkg/openapi" ) type MLMDToOpenAPIConverterImpl struct{} @@ -15,6 +15,11 @@ func (c *MLMDToOpenAPIConverterImpl) ConvertDocArtifact(source *proto.Artifact) var pOpenapiDocArtifact *openapi.DocArtifact if source != nil { var openapiDocArtifact openapi.DocArtifact + xstring, err := converter.MapArtifactType(source) + if err != nil { + return nil, fmt.Errorf("error setting field ArtifactType: %w", err) + } + openapiDocArtifact.ArtifactType = xstring mapStringOpenapiMetadataValue, err := converter.MapMLMDCustomProperties((*source).CustomProperties) if err != nil { return nil, err @@ -23,14 +28,14 @@ func (c *MLMDToOpenAPIConverterImpl) ConvertDocArtifact(source *proto.Artifact) openapiDocArtifact.Description = converter.MapDescription((*source).Properties) var pString *string if (*source).ExternalId != nil { - xstring := *(*source).ExternalId - pString = &xstring + xstring2 := *(*source).ExternalId + pString = &xstring2 } openapiDocArtifact.ExternalID = pString var pString2 *string if (*source).Uri != nil { - xstring2 := *(*source).Uri - pString2 = &xstring2 + xstring3 := *(*source).Uri + pString2 = &xstring3 } openapiDocArtifact.Uri = pString2 openapiDocArtifact.State = converter.MapMLMDArtifactState((*source).State) @@ -38,11 +43,6 @@ func (c *MLMDToOpenAPIConverterImpl) ConvertDocArtifact(source *proto.Artifact) openapiDocArtifact.Id = converter.Int64ToString((*source).Id) openapiDocArtifact.CreateTimeSinceEpoch = converter.Int64ToString((*source).CreateTimeSinceEpoch) openapiDocArtifact.LastUpdateTimeSinceEpoch = converter.Int64ToString((*source).LastUpdateTimeSinceEpoch) - xstring3, err := converter.MapArtifactType(source) - if err != nil { - return nil, fmt.Errorf("error setting field ArtifactType: %w", err) - } - openapiDocArtifact.ArtifactType = xstring3 pOpenapiDocArtifact = &openapiDocArtifact } return pOpenapiDocArtifact, nil @@ -80,6 +80,11 @@ func (c *MLMDToOpenAPIConverterImpl) ConvertModelArtifact(source *proto.Artifact var pOpenapiModelArtifact *openapi.ModelArtifact if source != nil { var openapiModelArtifact openapi.ModelArtifact + xstring, err := converter.MapArtifactType(source) + if err != nil { + return nil, fmt.Errorf("error setting field ArtifactType: %w", err) + } + openapiModelArtifact.ArtifactType = xstring mapStringOpenapiMetadataValue, err := converter.MapMLMDCustomProperties((*source).CustomProperties) if err != nil { return nil, err @@ -88,14 +93,14 @@ func (c *MLMDToOpenAPIConverterImpl) ConvertModelArtifact(source *proto.Artifact openapiModelArtifact.Description = converter.MapDescription((*source).Properties) var pString *string if (*source).ExternalId != nil { - xstring := *(*source).ExternalId - pString = &xstring + xstring2 := *(*source).ExternalId + pString = &xstring2 } openapiModelArtifact.ExternalID = pString var pString2 *string if (*source).Uri != nil { - xstring2 := *(*source).Uri - pString2 = &xstring2 + xstring3 := *(*source).Uri + pString2 = &xstring3 } openapiModelArtifact.Uri = pString2 openapiModelArtifact.State = converter.MapMLMDArtifactState((*source).State) @@ -103,11 +108,6 @@ func (c *MLMDToOpenAPIConverterImpl) ConvertModelArtifact(source *proto.Artifact openapiModelArtifact.Id = converter.Int64ToString((*source).Id) openapiModelArtifact.CreateTimeSinceEpoch = converter.Int64ToString((*source).CreateTimeSinceEpoch) openapiModelArtifact.LastUpdateTimeSinceEpoch = converter.Int64ToString((*source).LastUpdateTimeSinceEpoch) - xstring3, err := converter.MapArtifactType(source) - if err != nil { - return nil, fmt.Errorf("error setting field ArtifactType: %w", err) - } - openapiModelArtifact.ArtifactType = xstring3 openapiModelArtifact.ModelFormatName = converter.MapModelArtifactFormatName((*source).Properties) openapiModelArtifact.StorageKey = converter.MapModelArtifactStorageKey((*source).Properties) openapiModelArtifact.StoragePath = converter.MapModelArtifactStoragePath((*source).Properties) diff --git a/internal/converter/generated/openapi_converter.gen.go b/internal/converter/generated/openapi_converter.gen.go index 96cccad65..75d441b1a 100755 --- a/internal/converter/generated/openapi_converter.gen.go +++ b/internal/converter/generated/openapi_converter.gen.go @@ -3,8 +3,8 @@ package generated import ( - converter "github.com/opendatahub-io/model-registry/internal/converter" - openapi "github.com/opendatahub-io/model-registry/pkg/openapi" + converter "github.com/kubeflow/model-registry/internal/converter" + openapi "github.com/kubeflow/model-registry/pkg/openapi" ) type OpenAPIConverterImpl struct{} @@ -605,23 +605,23 @@ func (c *OpenAPIConverterImpl) OverrideNotEditableForModelArtifact(source conver openapiModelArtifact := converter.InitModelArtifactWithUpdate(source) var pString *string if source.Existing != nil { - pString = source.Existing.Name + pString = &source.Existing.ArtifactType } - var pString2 *string + var xstring string if pString != nil { - xstring := *pString - pString2 = &xstring + xstring = *pString } - openapiModelArtifact.Name = pString2 - var pString3 *string + openapiModelArtifact.ArtifactType = xstring + var pString2 *string if source.Existing != nil { - pString3 = &source.Existing.ArtifactType + pString2 = source.Existing.Name } - var xstring2 string - if pString3 != nil { - xstring2 = *pString3 + var pString3 *string + if pString2 != nil { + xstring2 := *pString2 + pString3 = &xstring2 } - openapiModelArtifact.ArtifactType = xstring2 + openapiModelArtifact.Name = pString3 return openapiModelArtifact, nil } func (c *OpenAPIConverterImpl) OverrideNotEditableForModelVersion(source converter.OpenapiUpdateWrapper[openapi.ModelVersion]) (openapi.ModelVersion, error) { @@ -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/generated/openapi_mlmd_converter.gen.go b/internal/converter/generated/openapi_mlmd_converter.gen.go index 5badda5fb..ac3ae2f6d 100755 --- a/internal/converter/generated/openapi_mlmd_converter.gen.go +++ b/internal/converter/generated/openapi_mlmd_converter.gen.go @@ -4,9 +4,9 @@ package generated import ( "fmt" - converter "github.com/opendatahub-io/model-registry/internal/converter" - proto "github.com/opendatahub-io/model-registry/internal/ml_metadata/proto" - openapi "github.com/opendatahub-io/model-registry/pkg/openapi" + converter "github.com/kubeflow/model-registry/internal/converter" + proto "github.com/kubeflow/model-registry/internal/ml_metadata/proto" + openapi "github.com/kubeflow/model-registry/pkg/openapi" ) type OpenAPIToMLMDConverterImpl struct{} diff --git a/internal/converter/mlmd_converter_util_test.go b/internal/converter/mlmd_converter_util_test.go index 27ac3d81b..7fad4c33b 100644 --- a/internal/converter/mlmd_converter_util_test.go +++ b/internal/converter/mlmd_converter_util_test.go @@ -6,9 +6,9 @@ import ( "strings" "testing" - "github.com/opendatahub-io/model-registry/internal/constants" - "github.com/opendatahub-io/model-registry/internal/ml_metadata/proto" - "github.com/opendatahub-io/model-registry/pkg/openapi" + "github.com/kubeflow/model-registry/internal/defaults" + "github.com/kubeflow/model-registry/internal/ml_metadata/proto" + "github.com/kubeflow/model-registry/pkg/openapi" "github.com/stretchr/testify/assert" "golang.org/x/exp/maps" ) @@ -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) @@ -208,7 +205,7 @@ func TestMapRegisteredModelType(t *testing.T) { typeName := MapRegisteredModelType(&openapi.RegisteredModel{}) assertion.NotNil(typeName) - assertion.Equal(constants.RegisteredModelTypeName, *typeName) + assertion.Equal(defaults.RegisteredModelTypeName, *typeName) } func TestMapModelVersionProperties(t *testing.T) { @@ -236,7 +233,7 @@ func TestMapModelVersionType(t *testing.T) { typeName := MapModelVersionType(&openapi.ModelVersion{}) assertion.NotNil(typeName) - assertion.Equal(constants.ModelVersionTypeName, *typeName) + assertion.Equal(defaults.ModelVersionTypeName, *typeName) } func TestMapModelVersionName(t *testing.T) { @@ -287,7 +284,7 @@ func TestMapModelArtifactType(t *testing.T) { typeName := MapModelArtifactType(&openapi.ModelArtifact{}) assertion.NotNil(typeName) - assertion.Equal(constants.ModelArtifactTypeName, *typeName) + assertion.Equal(defaults.ModelArtifactTypeName, *typeName) } func TestMapModelArtifactName(t *testing.T) { @@ -346,7 +343,7 @@ func TestMapDocArtifactType(t *testing.T) { typeName := MapModelArtifactType(&openapi.ModelArtifact{}) assertion.NotNil(typeName) - assertion.Equal(constants.ModelArtifactTypeName, *typeName) + assertion.Equal(defaults.ModelArtifactTypeName, *typeName) } func TestMapDocArtifactName(t *testing.T) { @@ -577,13 +574,13 @@ func TestMapArtifactType(t *testing.T) { assertion := setup(t) artifactType, err := MapArtifactType(&proto.Artifact{ - Type: of(constants.ModelArtifactTypeName), + Type: of(defaults.ModelArtifactTypeName), }) assertion.Nil(err) assertion.Equal("model-artifact", artifactType) artifactType, err = MapArtifactType(&proto.Artifact{ - Type: of(constants.DocArtifactTypeName), + Type: of(defaults.DocArtifactTypeName), }) assertion.Nil(err) assertion.Equal("doc-artifact", artifactType) @@ -659,7 +656,7 @@ func TestMapServingEnvironmentType(t *testing.T) { typeName := MapServingEnvironmentType(&openapi.ServingEnvironment{}) assertion.NotNil(typeName) - assertion.Equal(constants.ServingEnvironmentTypeName, *typeName) + assertion.Equal(defaults.ServingEnvironmentTypeName, *typeName) } func TestMapInferenceServiceType(t *testing.T) { @@ -667,7 +664,7 @@ func TestMapInferenceServiceType(t *testing.T) { typeName := MapInferenceServiceType(&openapi.InferenceService{}) assertion.NotNil(typeName) - assertion.Equal(constants.InferenceServiceTypeName, *typeName) + assertion.Equal(defaults.InferenceServiceTypeName, *typeName) } func TestMapInferenceServiceProperties(t *testing.T) { @@ -710,7 +707,7 @@ func TestMapServeModelType(t *testing.T) { typeName := MapServeModelType(&openapi.ServeModel{}) assertion.NotNil(typeName) - assertion.Equal(constants.ServeModelTypeName, *typeName) + assertion.Equal(defaults.ServeModelTypeName, *typeName) } func TestMapServeModelProperties(t *testing.T) { diff --git a/internal/converter/mlmd_openapi_converter.go b/internal/converter/mlmd_openapi_converter.go index 993ba5856..92bb45163 100644 --- a/internal/converter/mlmd_openapi_converter.go +++ b/internal/converter/mlmd_openapi_converter.go @@ -1,8 +1,8 @@ package converter import ( - "github.com/opendatahub-io/model-registry/internal/ml_metadata/proto" - "github.com/opendatahub-io/model-registry/pkg/openapi" + "github.com/kubeflow/model-registry/internal/ml_metadata/proto" + "github.com/kubeflow/model-registry/pkg/openapi" ) // goverter:converter diff --git a/internal/converter/mlmd_openapi_converter_util.go b/internal/converter/mlmd_openapi_converter_util.go index b6bb863a6..aa326da7e 100644 --- a/internal/converter/mlmd_openapi_converter_util.go +++ b/internal/converter/mlmd_openapi_converter_util.go @@ -4,13 +4,51 @@ import ( "encoding/base64" "encoding/json" "fmt" + "strconv" "strings" - "github.com/opendatahub-io/model-registry/internal/constants" - "github.com/opendatahub-io/model-registry/internal/ml_metadata/proto" - "github.com/opendatahub-io/model-registry/pkg/openapi" + "github.com/kubeflow/model-registry/internal/defaults" + "github.com/kubeflow/model-registry/internal/ml_metadata/proto" + "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) } @@ -87,9 +115,9 @@ func MapArtifactType(source *proto.Artifact) (string, error) { return "", fmt.Errorf("artifact type is nil") } switch *source.Type { - case constants.ModelArtifactTypeName: + case defaults.ModelArtifactTypeName: return "model-artifact", nil - case constants.DocArtifactTypeName: + case defaults.DocArtifactTypeName: return "doc-artifact", nil default: return "", fmt.Errorf("invalid artifact type found: %v", source.Type) diff --git a/internal/converter/openapi_converter.go b/internal/converter/openapi_converter.go index eb7486be0..638b3a168 100644 --- a/internal/converter/openapi_converter.go +++ b/internal/converter/openapi_converter.go @@ -1,6 +1,6 @@ package converter -import "github.com/opendatahub-io/model-registry/pkg/openapi" +import "github.com/kubeflow/model-registry/pkg/openapi" // NOTE: methods must follow these patterns, otherwise tests could not find possible issues: // Converters createEntity to entity: Convert<ENTITY>Create diff --git a/internal/converter/openapi_converter_test.go b/internal/converter/openapi_converter_test.go index 8b571f410..4c33c27ed 100644 --- a/internal/converter/openapi_converter_test.go +++ b/internal/converter/openapi_converter_test.go @@ -11,7 +11,7 @@ import ( "strings" "testing" - "github.com/opendatahub-io/model-registry/pkg/openapi" + "github.com/kubeflow/model-registry/pkg/openapi" ) // visitor diff --git a/internal/converter/openapi_converter_util.go b/internal/converter/openapi_converter_util.go index 3a492fd70..a0efb5cb0 100644 --- a/internal/converter/openapi_converter_util.go +++ b/internal/converter/openapi_converter_util.go @@ -1,6 +1,6 @@ package converter -import "github.com/opendatahub-io/model-registry/pkg/openapi" +import "github.com/kubeflow/model-registry/pkg/openapi" type OpenAPIModel interface { openapi.RegisteredModel | diff --git a/internal/converter/openapi_mlmd_converter.go b/internal/converter/openapi_mlmd_converter.go index 521e2c6c4..ccf56fbe3 100644 --- a/internal/converter/openapi_mlmd_converter.go +++ b/internal/converter/openapi_mlmd_converter.go @@ -1,8 +1,8 @@ package converter import ( - "github.com/opendatahub-io/model-registry/internal/ml_metadata/proto" - "github.com/opendatahub-io/model-registry/pkg/openapi" + "github.com/kubeflow/model-registry/internal/ml_metadata/proto" + "github.com/kubeflow/model-registry/pkg/openapi" ) type OpenAPIModelWrapper[ diff --git a/internal/converter/openapi_mlmd_converter_util.go b/internal/converter/openapi_mlmd_converter_util.go index de5214246..26a7a626f 100644 --- a/internal/converter/openapi_mlmd_converter_util.go +++ b/internal/converter/openapi_mlmd_converter_util.go @@ -7,9 +7,9 @@ import ( "strconv" "github.com/google/uuid" - "github.com/opendatahub-io/model-registry/internal/constants" - "github.com/opendatahub-io/model-registry/internal/ml_metadata/proto" - "github.com/opendatahub-io/model-registry/pkg/openapi" + "github.com/kubeflow/model-registry/internal/defaults" + "github.com/kubeflow/model-registry/internal/ml_metadata/proto" + "github.com/kubeflow/model-registry/pkg/openapi" "google.golang.org/protobuf/types/known/structpb" ) @@ -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) } @@ -144,7 +144,7 @@ func MapRegisteredModelProperties(source *openapi.RegisteredModel) (map[string]* // MapRegisteredModelType return RegisteredModel corresponding MLMD context type func MapRegisteredModelType(_ *openapi.RegisteredModel) *string { - return of(constants.RegisteredModelTypeName) + return of(defaults.RegisteredModelTypeName) } // MODEL VERSION @@ -194,7 +194,7 @@ func MapModelVersionProperties(source *OpenAPIModelWrapper[openapi.ModelVersion] // MapModelVersionType return ModelVersion corresponding MLMD context type func MapModelVersionType(_ *openapi.ModelVersion) *string { - return of(constants.ModelVersionTypeName) + return of(defaults.ModelVersionTypeName) } // MapModelVersionName maps the user-provided name into MLMD one, i.e., prefixing it with @@ -222,7 +222,7 @@ func MapOpenAPIArtifactState(source *openapi.ArtifactState) (*proto.Artifact_Sta // get DocArtifact MLMD type name func MapDocArtifactType(_ *openapi.DocArtifact) *string { - return of(constants.DocArtifactTypeName) + return of(defaults.DocArtifactTypeName) } func MapDocArtifactProperties(source *openapi.DocArtifact) (map[string]*proto.Value, error) { @@ -307,7 +307,7 @@ func MapModelArtifactProperties(source *openapi.ModelArtifact) (map[string]*prot // MapModelArtifactType return ModelArtifact corresponding MLMD context type func MapModelArtifactType(_ *openapi.ModelArtifact) *string { - return of(constants.ModelArtifactTypeName) + return of(defaults.ModelArtifactTypeName) } // MapModelArtifactName maps the user-provided name into MLMD one, i.e., prefixing it with @@ -328,7 +328,7 @@ func MapModelArtifactName(source *OpenAPIModelWrapper[openapi.ModelArtifact]) *s // MapServingEnvironmentType return ServingEnvironment corresponding MLMD context type func MapServingEnvironmentType(_ *openapi.ServingEnvironment) *string { - return of(constants.ServingEnvironmentTypeName) + return of(defaults.ServingEnvironmentTypeName) } // MapServingEnvironmentProperties maps ServingEnvironment fields to specific MLMD properties @@ -350,7 +350,7 @@ func MapServingEnvironmentProperties(source *openapi.ServingEnvironment) (map[st // MapInferenceServiceType return InferenceService corresponding MLMD context type func MapInferenceServiceType(_ *openapi.InferenceService) *string { - return of(constants.InferenceServiceTypeName) + return of(defaults.InferenceServiceTypeName) } // MapInferenceServiceProperties maps InferenceService fields to specific MLMD properties @@ -436,7 +436,7 @@ func MapInferenceServiceName(source *OpenAPIModelWrapper[openapi.InferenceServic // MapServeModelType return ServeModel corresponding MLMD context type func MapServeModelType(_ *openapi.ServeModel) *string { - return of(constants.ServeModelTypeName) + return of(defaults.ServeModelTypeName) } // MapServeModelProperties maps ServeModel fields to specific MLMD properties diff --git a/internal/defaults/defaults.go b/internal/defaults/defaults.go new file mode 100644 index 000000000..a14cce33b --- /dev/null +++ b/internal/defaults/defaults.go @@ -0,0 +1,12 @@ +package defaults + +// MLMD type names +const ( + RegisteredModelTypeName = "kf.RegisteredModel" + ModelVersionTypeName = "kf.ModelVersion" + ModelArtifactTypeName = "kf.ModelArtifact" + DocArtifactTypeName = "kf.DocArtifact" + ServingEnvironmentTypeName = "kf.ServingEnvironment" + InferenceServiceTypeName = "kf.InferenceService" + ServeModelTypeName = "kf.ServeModel" +) diff --git a/internal/mapper/mapper.go b/internal/mapper/mapper.go index 271ea7438..9f28601a8 100644 --- a/internal/mapper/mapper.go +++ b/internal/mapper/mapper.go @@ -3,11 +3,11 @@ package mapper import ( "fmt" - "github.com/opendatahub-io/model-registry/internal/constants" - "github.com/opendatahub-io/model-registry/internal/converter" - "github.com/opendatahub-io/model-registry/internal/converter/generated" - "github.com/opendatahub-io/model-registry/internal/ml_metadata/proto" - "github.com/opendatahub-io/model-registry/pkg/openapi" + "github.com/kubeflow/model-registry/internal/converter" + "github.com/kubeflow/model-registry/internal/converter/generated" + "github.com/kubeflow/model-registry/internal/defaults" + "github.com/kubeflow/model-registry/internal/ml_metadata/proto" + "github.com/kubeflow/model-registry/pkg/openapi" ) type Mapper struct { @@ -28,14 +28,14 @@ func NewMapper(mlmdTypes map[string]int64) *Mapper { func (m *Mapper) MapFromRegisteredModel(registeredModel *openapi.RegisteredModel) (*proto.Context, error) { return m.OpenAPIConverter.ConvertRegisteredModel(&converter.OpenAPIModelWrapper[openapi.RegisteredModel]{ - TypeId: m.MLMDTypes[constants.RegisteredModelTypeName], + TypeId: m.MLMDTypes[defaults.RegisteredModelTypeName], Model: registeredModel, }) } func (m *Mapper) MapFromModelVersion(modelVersion *openapi.ModelVersion, registeredModelId string, registeredModelName *string) (*proto.Context, error) { return m.OpenAPIConverter.ConvertModelVersion(&converter.OpenAPIModelWrapper[openapi.ModelVersion]{ - TypeId: m.MLMDTypes[constants.ModelVersionTypeName], + TypeId: m.MLMDTypes[defaults.ModelVersionTypeName], Model: modelVersion, ParentResourceId: ®isteredModelId, ModelName: registeredModelName, @@ -44,7 +44,7 @@ func (m *Mapper) MapFromModelVersion(modelVersion *openapi.ModelVersion, registe func (m *Mapper) MapFromModelArtifact(modelArtifact *openapi.ModelArtifact, modelVersionId *string) (*proto.Artifact, error) { return m.OpenAPIConverter.ConvertModelArtifact(&converter.OpenAPIModelWrapper[openapi.ModelArtifact]{ - TypeId: m.MLMDTypes[constants.ModelArtifactTypeName], + TypeId: m.MLMDTypes[defaults.ModelArtifactTypeName], Model: modelArtifact, ParentResourceId: modelVersionId, }) @@ -52,7 +52,7 @@ func (m *Mapper) MapFromModelArtifact(modelArtifact *openapi.ModelArtifact, mode func (m *Mapper) MapFromDocArtifact(docArtifact *openapi.DocArtifact, modelVersionId *string) (*proto.Artifact, error) { return m.OpenAPIConverter.ConvertDocArtifact(&converter.OpenAPIModelWrapper[openapi.DocArtifact]{ - TypeId: m.MLMDTypes[constants.DocArtifactTypeName], + TypeId: m.MLMDTypes[defaults.DocArtifactTypeName], Model: docArtifact, ParentResourceId: modelVersionId, }) @@ -89,14 +89,14 @@ func (m *Mapper) MapFromModelArtifacts(modelArtifacts []openapi.ModelArtifact, m func (m *Mapper) MapFromServingEnvironment(servingEnvironment *openapi.ServingEnvironment) (*proto.Context, error) { return m.OpenAPIConverter.ConvertServingEnvironment(&converter.OpenAPIModelWrapper[openapi.ServingEnvironment]{ - TypeId: m.MLMDTypes[constants.ServingEnvironmentTypeName], + TypeId: m.MLMDTypes[defaults.ServingEnvironmentTypeName], Model: servingEnvironment, }) } func (m *Mapper) MapFromInferenceService(inferenceService *openapi.InferenceService, servingEnvironmentId string) (*proto.Context, error) { return m.OpenAPIConverter.ConvertInferenceService(&converter.OpenAPIModelWrapper[openapi.InferenceService]{ - TypeId: m.MLMDTypes[constants.InferenceServiceTypeName], + TypeId: m.MLMDTypes[defaults.InferenceServiceTypeName], Model: inferenceService, ParentResourceId: &servingEnvironmentId, }) @@ -104,7 +104,7 @@ func (m *Mapper) MapFromInferenceService(inferenceService *openapi.InferenceServ func (m *Mapper) MapFromServeModel(serveModel *openapi.ServeModel, inferenceServiceId string) (*proto.Execution, error) { return m.OpenAPIConverter.ConvertServeModel(&converter.OpenAPIModelWrapper[openapi.ServeModel]{ - TypeId: m.MLMDTypes[constants.ServeModelTypeName], + TypeId: m.MLMDTypes[defaults.ServeModelTypeName], Model: serveModel, ParentResourceId: &inferenceServiceId, }) @@ -113,19 +113,19 @@ func (m *Mapper) MapFromServeModel(serveModel *openapi.ServeModel, inferenceServ // Utilities for MLMD --> OpenAPI mapping, make use of generated Converters func (m *Mapper) MapToRegisteredModel(ctx *proto.Context) (*openapi.RegisteredModel, error) { - return mapTo(ctx, m.MLMDTypes, constants.RegisteredModelTypeName, m.MLMDConverter.ConvertRegisteredModel) + return mapTo(ctx, m.MLMDTypes, defaults.RegisteredModelTypeName, m.MLMDConverter.ConvertRegisteredModel) } func (m *Mapper) MapToModelVersion(ctx *proto.Context) (*openapi.ModelVersion, error) { - return mapTo(ctx, m.MLMDTypes, constants.ModelVersionTypeName, m.MLMDConverter.ConvertModelVersion) + return mapTo(ctx, m.MLMDTypes, defaults.ModelVersionTypeName, m.MLMDConverter.ConvertModelVersion) } func (m *Mapper) MapToModelArtifact(art *proto.Artifact) (*openapi.ModelArtifact, error) { - return mapTo(art, m.MLMDTypes, constants.ModelArtifactTypeName, m.MLMDConverter.ConvertModelArtifact) + return mapTo(art, m.MLMDTypes, defaults.ModelArtifactTypeName, m.MLMDConverter.ConvertModelArtifact) } func (m *Mapper) MapToDocArtifact(art *proto.Artifact) (*openapi.DocArtifact, error) { - return mapTo(art, m.MLMDTypes, constants.DocArtifactTypeName, m.MLMDConverter.ConvertDocArtifact) + return mapTo(art, m.MLMDTypes, defaults.DocArtifactTypeName, m.MLMDConverter.ConvertDocArtifact) } func (m *Mapper) MapToArtifact(art *proto.Artifact) (*openapi.Artifact, error) { @@ -136,12 +136,12 @@ func (m *Mapper) MapToArtifact(art *proto.Artifact) (*openapi.Artifact, error) { return nil, fmt.Errorf("invalid artifact type, can't map from nil") } switch art.GetType() { - case constants.ModelArtifactTypeName: + case defaults.ModelArtifactTypeName: ma, err := m.MapToModelArtifact(art) return &openapi.Artifact{ ModelArtifact: ma, }, err - case constants.DocArtifactTypeName: + case defaults.DocArtifactTypeName: da, err := m.MapToDocArtifact(art) return &openapi.Artifact{ DocArtifact: da, @@ -152,15 +152,15 @@ func (m *Mapper) MapToArtifact(art *proto.Artifact) (*openapi.Artifact, error) { } func (m *Mapper) MapToServingEnvironment(ctx *proto.Context) (*openapi.ServingEnvironment, error) { - return mapTo(ctx, m.MLMDTypes, constants.ServingEnvironmentTypeName, m.MLMDConverter.ConvertServingEnvironment) + return mapTo(ctx, m.MLMDTypes, defaults.ServingEnvironmentTypeName, m.MLMDConverter.ConvertServingEnvironment) } func (m *Mapper) MapToInferenceService(ctx *proto.Context) (*openapi.InferenceService, error) { - return mapTo(ctx, m.MLMDTypes, constants.InferenceServiceTypeName, m.MLMDConverter.ConvertInferenceService) + return mapTo(ctx, m.MLMDTypes, defaults.InferenceServiceTypeName, m.MLMDConverter.ConvertInferenceService) } func (m *Mapper) MapToServeModel(ex *proto.Execution) (*openapi.ServeModel, error) { - return mapTo(ex, m.MLMDTypes, constants.ServeModelTypeName, m.MLMDConverter.ConvertServeModel) + return mapTo(ex, m.MLMDTypes, defaults.ServeModelTypeName, m.MLMDConverter.ConvertServeModel) } type getTypeIder interface { diff --git a/internal/mapper/mapper_test.go b/internal/mapper/mapper_test.go index 7ad7b98a3..04d55bbc6 100644 --- a/internal/mapper/mapper_test.go +++ b/internal/mapper/mapper_test.go @@ -4,9 +4,9 @@ import ( "fmt" "testing" - "github.com/opendatahub-io/model-registry/internal/constants" - "github.com/opendatahub-io/model-registry/internal/ml_metadata/proto" - "github.com/opendatahub-io/model-registry/pkg/openapi" + "github.com/kubeflow/model-registry/internal/defaults" + "github.com/kubeflow/model-registry/internal/ml_metadata/proto" + "github.com/kubeflow/model-registry/pkg/openapi" "github.com/stretchr/testify/assert" ) @@ -22,13 +22,13 @@ const ( ) var typesMap = map[string]int64{ - constants.RegisteredModelTypeName: registeredModelTypeId, - constants.ModelVersionTypeName: modelVersionTypeId, - constants.DocArtifactTypeName: docArtifactTypeId, - constants.ModelArtifactTypeName: modelArtifactTypeId, - constants.ServingEnvironmentTypeName: servingEnvironmentTypeId, - constants.InferenceServiceTypeName: inferenceServiceTypeId, - constants.ServeModelTypeName: serveModelTypeId, + defaults.RegisteredModelTypeName: registeredModelTypeId, + defaults.ModelVersionTypeName: modelVersionTypeId, + defaults.DocArtifactTypeName: docArtifactTypeId, + defaults.ModelArtifactTypeName: modelArtifactTypeId, + defaults.ServingEnvironmentTypeName: servingEnvironmentTypeId, + defaults.InferenceServiceTypeName: inferenceServiceTypeId, + defaults.ServeModelTypeName: serveModelTypeId, } func setup(t *testing.T) (*assert.Assertions, *Mapper) { @@ -148,7 +148,7 @@ func TestMapToRegisteredModel(t *testing.T) { assertion, m := setup(t) _, err := m.MapToRegisteredModel(&proto.Context{ TypeId: of(registeredModelTypeId), - Type: of(constants.RegisteredModelTypeName), + Type: of(defaults.RegisteredModelTypeName), }) assertion.Nil(err) } @@ -157,17 +157,17 @@ func TestMapToRegisteredModelInvalid(t *testing.T) { assertion, m := setup(t) _, err := m.MapToRegisteredModel(&proto.Context{ TypeId: of(invalidTypeId), - Type: of("odh.OtherEntity"), + Type: of("kf.OtherEntity"), }) assertion.NotNil(err) - assertion.Equal(fmt.Sprintf("invalid entity: expected %s but received odh.OtherEntity, please check the provided id", constants.RegisteredModelTypeName), err.Error()) + assertion.Equal(fmt.Sprintf("invalid entity: expected %s but received kf.OtherEntity, please check the provided id", defaults.RegisteredModelTypeName), err.Error()) } func TestMapToModelVersion(t *testing.T) { assertion, m := setup(t) _, err := m.MapToModelVersion(&proto.Context{ TypeId: of(modelVersionTypeId), - Type: of(constants.ModelVersionTypeName), + Type: of(defaults.ModelVersionTypeName), }) assertion.Nil(err) } @@ -176,17 +176,17 @@ func TestMapToModelVersionInvalid(t *testing.T) { assertion, m := setup(t) _, err := m.MapToModelVersion(&proto.Context{ TypeId: of(invalidTypeId), - Type: of("odh.OtherEntity"), + Type: of("kf.OtherEntity"), }) assertion.NotNil(err) - assertion.Equal(fmt.Sprintf("invalid entity: expected %s but received odh.OtherEntity, please check the provided id", constants.ModelVersionTypeName), err.Error()) + assertion.Equal(fmt.Sprintf("invalid entity: expected %s but received kf.OtherEntity, please check the provided id", defaults.ModelVersionTypeName), err.Error()) } func TestMapToDocArtifact(t *testing.T) { assertion, m := setup(t) _, err := m.MapToArtifact(&proto.Artifact{ TypeId: of(docArtifactTypeId), - Type: of(constants.DocArtifactTypeName), + Type: of(defaults.DocArtifactTypeName), }) assertion.Nil(err) } @@ -195,7 +195,7 @@ func TestMapToModelArtifact(t *testing.T) { assertion, m := setup(t) _, err := m.MapToArtifact(&proto.Artifact{ TypeId: of(modelArtifactTypeId), - Type: of(constants.ModelArtifactTypeName), + Type: of(defaults.ModelArtifactTypeName), }) assertion.Nil(err) } @@ -213,17 +213,17 @@ func TestMapToArtifactInvalid(t *testing.T) { assertion, m := setup(t) _, err := m.MapToArtifact(&proto.Artifact{ TypeId: of(invalidTypeId), - Type: of("odh.OtherEntity"), + Type: of("kf.OtherEntity"), }) assertion.NotNil(err) - assertion.Equal("unknown artifact type: odh.OtherEntity", err.Error()) + assertion.Equal("unknown artifact type: kf.OtherEntity", err.Error()) } func TestMapToServingEnvironment(t *testing.T) { assertion, m := setup(t) _, err := m.MapToServingEnvironment(&proto.Context{ TypeId: of(servingEnvironmentTypeId), - Type: of(constants.ServingEnvironmentTypeName), + Type: of(defaults.ServingEnvironmentTypeName), }) assertion.Nil(err) } @@ -232,17 +232,17 @@ func TestMapToServingEnvironmentInvalid(t *testing.T) { assertion, m := setup(t) _, err := m.MapToServingEnvironment(&proto.Context{ TypeId: of(invalidTypeId), - Type: of("odh.OtherEntity"), + Type: of("kf.OtherEntity"), }) assertion.NotNil(err) - assertion.Equal(fmt.Sprintf("invalid entity: expected %s but received odh.OtherEntity, please check the provided id", constants.ServingEnvironmentTypeName), err.Error()) + assertion.Equal(fmt.Sprintf("invalid entity: expected %s but received kf.OtherEntity, please check the provided id", defaults.ServingEnvironmentTypeName), err.Error()) } func TestMapToInferenceService(t *testing.T) { assertion, m := setup(t) _, err := m.MapToInferenceService(&proto.Context{ TypeId: of(inferenceServiceTypeId), - Type: of(constants.InferenceServiceTypeName), + Type: of(defaults.InferenceServiceTypeName), }) assertion.Nil(err) } @@ -251,17 +251,17 @@ func TestMapToInferenceServiceInvalid(t *testing.T) { assertion, m := setup(t) _, err := m.MapToInferenceService(&proto.Context{ TypeId: of(invalidTypeId), - Type: of("odh.OtherEntity"), + Type: of("kf.OtherEntity"), }) assertion.NotNil(err) - assertion.Equal(fmt.Sprintf("invalid entity: expected %s but received odh.OtherEntity, please check the provided id", constants.InferenceServiceTypeName), err.Error()) + assertion.Equal(fmt.Sprintf("invalid entity: expected %s but received kf.OtherEntity, please check the provided id", defaults.InferenceServiceTypeName), err.Error()) } func TestMapToServeModel(t *testing.T) { assertion, m := setup(t) _, err := m.MapToServeModel(&proto.Execution{ TypeId: of(serveModelTypeId), - Type: of(constants.ServeModelTypeName), + Type: of(defaults.ServeModelTypeName), }) assertion.Nil(err) } @@ -270,10 +270,10 @@ func TestMapToServeModelInvalid(t *testing.T) { assertion, m := setup(t) _, err := m.MapToServeModel(&proto.Execution{ TypeId: of(invalidTypeId), - Type: of("odh.OtherEntity"), + Type: of("kf.OtherEntity"), }) assertion.NotNil(err) - assertion.Equal(fmt.Sprintf("invalid entity: expected %s but received odh.OtherEntity, please check the provided id", constants.ServeModelTypeName), err.Error()) + assertion.Equal(fmt.Sprintf("invalid entity: expected %s but received kf.OtherEntity, please check the provided id", defaults.ServeModelTypeName), err.Error()) } func TestMapTo(t *testing.T) { diff --git a/internal/ml_metadata/proto/metadata_store.pb.go b/internal/ml_metadata/proto/metadata_store.pb.go index b616143bb..e24a427de 100644 --- a/internal/ml_metadata/proto/metadata_store.pb.go +++ b/internal/ml_metadata/proto/metadata_store.pb.go @@ -5662,12 +5662,11 @@ var file_ml_metadata_proto_metadata_store_proto_rawDesc = []byte{ 0xb7, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x6d, 0x6c, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x54, 0x79, 0x70, 0x65, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x13, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0x54, 0x79, 0x70, 0x65, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0x45, 0x5a, - 0x43, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x70, 0x65, 0x6e, - 0x64, 0x61, 0x74, 0x61, 0x68, 0x75, 0x62, 0x2d, 0x69, 0x6f, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, - 0x2d, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, - 0x61, 0x6c, 0x2f, 0x6d, 0x6c, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x70, - 0x72, 0x6f, 0x74, 0x6f, + 0x54, 0x79, 0x70, 0x65, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0x3f, 0x5a, + 0x3d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x75, 0x62, 0x65, + 0x66, 0x6c, 0x6f, 0x77, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2d, 0x72, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x6d, 0x6c, 0x5f, + 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, } var ( diff --git a/internal/ml_metadata/proto/metadata_store_service.pb.go b/internal/ml_metadata/proto/metadata_store_service.pb.go index 7a88900c2..aeada4ada 100644 --- a/internal/ml_metadata/proto/metadata_store_service.pb.go +++ b/internal/ml_metadata/proto/metadata_store_service.pb.go @@ -8399,11 +8399,11 @@ var file_ml_metadata_proto_metadata_store_service_proto_rawDesc = []byte{ 0x70, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x6d, 0x6c, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x6e, 0x65, 0x61, 0x67, 0x65, 0x53, 0x75, 0x62, 0x67, 0x72, 0x61, 0x70, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x00, 0x42, 0x45, 0x5a, 0x43, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x64, 0x61, 0x74, 0x61, 0x68, 0x75, 0x62, 0x2d, 0x69, - 0x6f, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2d, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x6d, 0x6c, 0x5f, 0x6d, 0x65, 0x74, - 0x61, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x73, 0x65, 0x22, 0x00, 0x42, 0x3f, 0x5a, 0x3d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x6b, 0x75, 0x62, 0x65, 0x66, 0x6c, 0x6f, 0x77, 0x2f, 0x6d, 0x6f, 0x64, 0x65, + 0x6c, 0x2d, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, + 0x6e, 0x61, 0x6c, 0x2f, 0x6d, 0x6c, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, } var ( diff --git a/internal/mlmdtypes/mlmdtypes.go b/internal/mlmdtypes/mlmdtypes.go index 7d6b4220f..73b403996 100644 --- a/internal/mlmdtypes/mlmdtypes.go +++ b/internal/mlmdtypes/mlmdtypes.go @@ -4,32 +4,44 @@ import ( "context" "fmt" - "github.com/opendatahub-io/model-registry/internal/apiutils" - "github.com/opendatahub-io/model-registry/internal/constants" - "github.com/opendatahub-io/model-registry/internal/ml_metadata/proto" + "github.com/kubeflow/model-registry/internal/defaults" + "github.com/kubeflow/model-registry/internal/ml_metadata/proto" "google.golang.org/grpc" ) -var ( - registeredModelTypeName = apiutils.Of(constants.RegisteredModelTypeName) - modelVersionTypeName = apiutils.Of(constants.ModelVersionTypeName) - modelArtifactTypeName = apiutils.Of(constants.ModelArtifactTypeName) - docArtifactTypeName = apiutils.Of(constants.DocArtifactTypeName) - servingEnvironmentTypeName = apiutils.Of(constants.ServingEnvironmentTypeName) - inferenceServiceTypeName = apiutils.Of(constants.InferenceServiceTypeName) - serveModelTypeName = apiutils.Of(constants.ServeModelTypeName) - canAddFields = apiutils.Of(true) -) +type MLMDTypeNamesConfig struct { + RegisteredModelTypeName string + ModelVersionTypeName string + ModelArtifactTypeName string + DocArtifactTypeName string + ServingEnvironmentTypeName string + InferenceServiceTypeName string + ServeModelTypeName string + CanAddFields bool +} + +func NewMLMDTypeNamesConfigFromDefaults() MLMDTypeNamesConfig { + return MLMDTypeNamesConfig{ + RegisteredModelTypeName: defaults.RegisteredModelTypeName, + ModelVersionTypeName: defaults.ModelVersionTypeName, + ModelArtifactTypeName: defaults.ModelArtifactTypeName, + DocArtifactTypeName: defaults.DocArtifactTypeName, + ServingEnvironmentTypeName: defaults.ServingEnvironmentTypeName, + InferenceServiceTypeName: defaults.InferenceServiceTypeName, + ServeModelTypeName: defaults.ServeModelTypeName, + CanAddFields: true, + } +} // Utility method that created the necessary Model Registry's logical-model types // as the necessary MLMD's Context, Artifact, Execution types etc. in the underlying MLMD service -func CreateMLMDTypes(cc grpc.ClientConnInterface) (map[string]int64, error) { +func CreateMLMDTypes(cc grpc.ClientConnInterface, nameConfig MLMDTypeNamesConfig) (map[string]int64, error) { client := proto.NewMetadataStoreServiceClient(cc) registeredModelReq := proto.PutContextTypeRequest{ - CanAddFields: canAddFields, + CanAddFields: &nameConfig.CanAddFields, ContextType: &proto.ContextType{ - Name: registeredModelTypeName, + Name: &nameConfig.RegisteredModelTypeName, Properties: map[string]proto.PropertyType{ "description": proto.PropertyType_STRING, "state": proto.PropertyType_STRING, @@ -38,9 +50,9 @@ func CreateMLMDTypes(cc grpc.ClientConnInterface) (map[string]int64, error) { } modelVersionReq := proto.PutContextTypeRequest{ - CanAddFields: canAddFields, + CanAddFields: &nameConfig.CanAddFields, ContextType: &proto.ContextType{ - Name: modelVersionTypeName, + Name: &nameConfig.ModelVersionTypeName, Properties: map[string]proto.PropertyType{ "description": proto.PropertyType_STRING, "model_name": proto.PropertyType_STRING, @@ -52,9 +64,9 @@ func CreateMLMDTypes(cc grpc.ClientConnInterface) (map[string]int64, error) { } docArtifactReq := proto.PutArtifactTypeRequest{ - CanAddFields: canAddFields, + CanAddFields: &nameConfig.CanAddFields, ArtifactType: &proto.ArtifactType{ - Name: docArtifactTypeName, + Name: &nameConfig.DocArtifactTypeName, Properties: map[string]proto.PropertyType{ "description": proto.PropertyType_STRING, }, @@ -62,9 +74,9 @@ func CreateMLMDTypes(cc grpc.ClientConnInterface) (map[string]int64, error) { } modelArtifactReq := proto.PutArtifactTypeRequest{ - CanAddFields: canAddFields, + CanAddFields: &nameConfig.CanAddFields, ArtifactType: &proto.ArtifactType{ - Name: modelArtifactTypeName, + Name: &nameConfig.ModelArtifactTypeName, Properties: map[string]proto.PropertyType{ "description": proto.PropertyType_STRING, "model_format_name": proto.PropertyType_STRING, @@ -77,9 +89,9 @@ func CreateMLMDTypes(cc grpc.ClientConnInterface) (map[string]int64, error) { } servingEnvironmentReq := proto.PutContextTypeRequest{ - CanAddFields: canAddFields, + CanAddFields: &nameConfig.CanAddFields, ContextType: &proto.ContextType{ - Name: servingEnvironmentTypeName, + Name: &nameConfig.ServingEnvironmentTypeName, Properties: map[string]proto.PropertyType{ "description": proto.PropertyType_STRING, }, @@ -87,9 +99,9 @@ func CreateMLMDTypes(cc grpc.ClientConnInterface) (map[string]int64, error) { } inferenceServiceReq := proto.PutContextTypeRequest{ - CanAddFields: canAddFields, + CanAddFields: &nameConfig.CanAddFields, ContextType: &proto.ContextType{ - Name: inferenceServiceTypeName, + Name: &nameConfig.InferenceServiceTypeName, Properties: map[string]proto.PropertyType{ "description": proto.PropertyType_STRING, "model_version_id": proto.PropertyType_INT, @@ -103,9 +115,9 @@ func CreateMLMDTypes(cc grpc.ClientConnInterface) (map[string]int64, error) { } serveModelReq := proto.PutExecutionTypeRequest{ - CanAddFields: canAddFields, + CanAddFields: &nameConfig.CanAddFields, ExecutionType: &proto.ExecutionType{ - Name: serveModelTypeName, + Name: &nameConfig.ServeModelTypeName, Properties: map[string]proto.PropertyType{ "description": proto.PropertyType_STRING, "model_version_id": proto.PropertyType_INT, @@ -115,47 +127,47 @@ func CreateMLMDTypes(cc grpc.ClientConnInterface) (map[string]int64, error) { registeredModelResp, err := client.PutContextType(context.Background(), ®isteredModelReq) if err != nil { - return nil, fmt.Errorf("error setting up context type %s: %v", *registeredModelTypeName, err) + return nil, fmt.Errorf("error setting up context type %s: %v", nameConfig.RegisteredModelTypeName, err) } modelVersionResp, err := client.PutContextType(context.Background(), &modelVersionReq) if err != nil { - return nil, fmt.Errorf("error setting up context type %s: %v", *modelVersionTypeName, err) + return nil, fmt.Errorf("error setting up context type %s: %v", nameConfig.ModelVersionTypeName, err) } docArtifactResp, err := client.PutArtifactType(context.Background(), &docArtifactReq) if err != nil { - return nil, fmt.Errorf("error setting up artifact type %s: %v", *docArtifactTypeName, err) + return nil, fmt.Errorf("error setting up artifact type %s: %v", nameConfig.DocArtifactTypeName, err) } modelArtifactResp, err := client.PutArtifactType(context.Background(), &modelArtifactReq) if err != nil { - return nil, fmt.Errorf("error setting up artifact type %s: %v", *modelArtifactTypeName, err) + return nil, fmt.Errorf("error setting up artifact type %s: %v", nameConfig.ModelArtifactTypeName, err) } servingEnvironmentResp, err := client.PutContextType(context.Background(), &servingEnvironmentReq) if err != nil { - return nil, fmt.Errorf("error setting up context type %s: %v", *servingEnvironmentTypeName, err) + return nil, fmt.Errorf("error setting up context type %s: %v", nameConfig.ServingEnvironmentTypeName, err) } inferenceServiceResp, err := client.PutContextType(context.Background(), &inferenceServiceReq) if err != nil { - return nil, fmt.Errorf("error setting up context type %s: %v", *inferenceServiceTypeName, err) + return nil, fmt.Errorf("error setting up context type %s: %v", nameConfig.InferenceServiceTypeName, err) } serveModelResp, err := client.PutExecutionType(context.Background(), &serveModelReq) if err != nil { - return nil, fmt.Errorf("error setting up execution type %s: %v", *serveModelTypeName, err) + return nil, fmt.Errorf("error setting up execution type %s: %v", nameConfig.ServeModelTypeName, err) } typesMap := map[string]int64{ - constants.RegisteredModelTypeName: registeredModelResp.GetTypeId(), - constants.ModelVersionTypeName: modelVersionResp.GetTypeId(), - constants.DocArtifactTypeName: docArtifactResp.GetTypeId(), - constants.ModelArtifactTypeName: modelArtifactResp.GetTypeId(), - constants.ServingEnvironmentTypeName: servingEnvironmentResp.GetTypeId(), - constants.InferenceServiceTypeName: inferenceServiceResp.GetTypeId(), - constants.ServeModelTypeName: serveModelResp.GetTypeId(), + defaults.RegisteredModelTypeName: registeredModelResp.GetTypeId(), + defaults.ModelVersionTypeName: modelVersionResp.GetTypeId(), + defaults.DocArtifactTypeName: docArtifactResp.GetTypeId(), + defaults.ModelArtifactTypeName: modelArtifactResp.GetTypeId(), + defaults.ServingEnvironmentTypeName: servingEnvironmentResp.GetTypeId(), + defaults.InferenceServiceTypeName: inferenceServiceResp.GetTypeId(), + defaults.ServeModelTypeName: serveModelResp.GetTypeId(), } return typesMap, nil } diff --git a/internal/server/openapi/api.go b/internal/server/openapi/api.go index e8212f8f7..079d32df7 100644 --- a/internal/server/openapi/api.go +++ b/internal/server/openapi/api.go @@ -13,7 +13,7 @@ import ( "context" "net/http" - model "github.com/opendatahub-io/model-registry/pkg/openapi" + model "github.com/kubeflow/model-registry/pkg/openapi" ) // ModelRegistryServiceAPIRouter defines the required methods for binding the api requests to a responses for the ModelRegistryServiceAPI diff --git a/internal/server/openapi/api_model_registry_service.go b/internal/server/openapi/api_model_registry_service.go index 6fb7ebee0..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) */ @@ -16,7 +16,7 @@ import ( "github.com/go-chi/chi/v5" - model "github.com/opendatahub-io/model-registry/pkg/openapi" + model "github.com/kubeflow/model-registry/pkg/openapi" ) // ModelRegistryServiceAPIController binds http requests to an api service and writes the service results to the http response @@ -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/api_model_registry_service_service.go b/internal/server/openapi/api_model_registry_service_service.go index 51713d5d6..03bf20084 100644 --- a/internal/server/openapi/api_model_registry_service_service.go +++ b/internal/server/openapi/api_model_registry_service_service.go @@ -12,11 +12,11 @@ package openapi import ( "context" - "github.com/opendatahub-io/model-registry/internal/apiutils" - "github.com/opendatahub-io/model-registry/internal/converter" - "github.com/opendatahub-io/model-registry/internal/converter/generated" - "github.com/opendatahub-io/model-registry/pkg/api" - model "github.com/opendatahub-io/model-registry/pkg/openapi" + "github.com/kubeflow/model-registry/internal/apiutils" + "github.com/kubeflow/model-registry/internal/converter" + "github.com/kubeflow/model-registry/internal/converter/generated" + "github.com/kubeflow/model-registry/pkg/api" + model "github.com/kubeflow/model-registry/pkg/openapi" ) // ModelRegistryServiceAPIService is a service that implements the logic for the ModelRegistryServiceAPIServicer diff --git a/internal/server/openapi/type_asserts.go b/internal/server/openapi/type_asserts.go index 6d08bbb2c..9964c0be9 100644 --- a/internal/server/openapi/type_asserts.go +++ b/internal/server/openapi/type_asserts.go @@ -13,20 +13,11 @@ package openapi import ( - model "github.com/opendatahub-io/model-registry/pkg/openapi" + model "github.com/kubeflow/model-registry/pkg/openapi" ) // AssertArtifactRequired checks if the required fields are not zero-ed func AssertArtifactRequired(obj model.Artifact) error { - // FIXME(manual): Artifact.ArtifactType is not present on client models - // elements := map[string]interface{}{ - // "artifactType": obj.ArtifactType, - // } - // for name, el := range elements { - // if isZero := IsZeroValue(el); isZero { - // return &RequiredError{Field: name} - // } - // } return nil } @@ -83,15 +74,6 @@ func AssertBaseArtifactCreateConstraints(obj model.BaseArtifactCreate) error { // AssertBaseArtifactRequired checks if the required fields are not zero-ed func AssertBaseArtifactRequired(obj model.BaseArtifact) error { - elements := map[string]interface{}{ - "artifactType": obj.ArtifactType, - } - for name, el := range elements { - if isZero := IsZeroValue(el); isZero { - return &RequiredError{Field: name} - } - } - return nil } @@ -328,6 +310,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 +330,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 +350,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 +370,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 +391,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 +411,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 +431,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/internal/testutils/test_container_utils.go b/internal/testutils/test_container_utils.go index 426715502..128435a33 100644 --- a/internal/testutils/test_container_utils.go +++ b/internal/testutils/test_container_utils.go @@ -7,7 +7,7 @@ import ( "os" "testing" - "github.com/opendatahub-io/model-registry/internal/ml_metadata/proto" + "github.com/kubeflow/model-registry/internal/ml_metadata/proto" "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/wait" "google.golang.org/grpc" diff --git a/main.go b/main.go index bccdb30f2..b83960ca1 100644 --- a/main.go +++ b/main.go @@ -2,7 +2,7 @@ package main import ( "github.com/golang/glog" - "github.com/opendatahub-io/model-registry/cmd" + "github.com/kubeflow/model-registry/cmd" "log" "net/http" _ "net/http/pprof" diff --git a/patches/type_asserts.patch b/patches/type_asserts.patch index c7e5d9464..485878a1b 100644 --- a/patches/type_asserts.patch +++ b/patches/type_asserts.patch @@ -1,29 +1,42 @@ 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 ( +@@ -449,21 +449,22 @@ func AssertMetadataStructValueConstraints(obj model.MetadataStructValue) error { - // AssertArtifactRequired checks if the required fields are not zero-ed - func AssertArtifactRequired(obj model.Artifact) error { + // AssertMetadataValueRequired checks if the required fields are not zero-ed + func AssertMetadataValueRequired(obj model.MetadataValue) error { - elements := map[string]interface{}{ -- "artifactType": obj.ArtifactType, +- "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): Artifact.ArtifactType is not present on client models ++ // FIXME(manual): Wrong autogenerated logic, just one elem should be non-zero. + // elements := map[string]interface{}{ -+ // "artifactType": obj.ArtifactType, ++ // "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/api/api.go b/pkg/api/api.go index 33f16540b..14e14cb94 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -1,6 +1,6 @@ package api -import "github.com/opendatahub-io/model-registry/pkg/openapi" +import "github.com/kubeflow/model-registry/pkg/openapi" // ListOptions provides options for listing entities with pagination and sorting. // It includes parameters such as PageSize, OrderBy, SortOrder, and NextPageToken. diff --git a/pkg/core/core.go b/pkg/core/core.go index d812130e7..dc0ec9fea 100644 --- a/pkg/core/core.go +++ b/pkg/core/core.go @@ -6,30 +6,21 @@ import ( "strings" "github.com/golang/glog" - "github.com/opendatahub-io/model-registry/internal/apiutils" - "github.com/opendatahub-io/model-registry/internal/constants" - "github.com/opendatahub-io/model-registry/internal/converter" - "github.com/opendatahub-io/model-registry/internal/converter/generated" - "github.com/opendatahub-io/model-registry/internal/mapper" - "github.com/opendatahub-io/model-registry/internal/ml_metadata/proto" - "github.com/opendatahub-io/model-registry/pkg/api" - "github.com/opendatahub-io/model-registry/pkg/openapi" + "github.com/kubeflow/model-registry/internal/apiutils" + "github.com/kubeflow/model-registry/internal/converter" + "github.com/kubeflow/model-registry/internal/converter/generated" + "github.com/kubeflow/model-registry/internal/mapper" + "github.com/kubeflow/model-registry/internal/ml_metadata/proto" + "github.com/kubeflow/model-registry/internal/mlmdtypes" + "github.com/kubeflow/model-registry/pkg/api" + "github.com/kubeflow/model-registry/pkg/openapi" "google.golang.org/grpc" ) -var ( - registeredModelTypeName = apiutils.Of(constants.RegisteredModelTypeName) - modelVersionTypeName = apiutils.Of(constants.ModelVersionTypeName) - modelArtifactTypeName = apiutils.Of(constants.ModelArtifactTypeName) - docArtifactTypeName = apiutils.Of(constants.DocArtifactTypeName) - servingEnvironmentTypeName = apiutils.Of(constants.ServingEnvironmentTypeName) - inferenceServiceTypeName = apiutils.Of(constants.InferenceServiceTypeName) - serveModelTypeName = apiutils.Of(constants.ServeModelTypeName) -) - // ModelRegistryService is the core library of the model registry type ModelRegistryService struct { mlmdClient proto.MetadataStoreServiceClient + nameConfig mlmdtypes.MLMDTypeNamesConfig typesMap map[string]int64 mapper *mapper.Mapper openapiConv *generated.OpenAPIConverterImpl @@ -40,8 +31,8 @@ type ModelRegistryService struct { // // Parameters: // - cc: A gRPC client connection to the underlying MLMD service -func NewModelRegistryService(cc grpc.ClientConnInterface) (api.ModelRegistryApi, error) { - typesMap, err := BuildTypesMap(cc) +func NewModelRegistryService(cc grpc.ClientConnInterface, nameConfig mlmdtypes.MLMDTypeNamesConfig) (api.ModelRegistryApi, error) { + typesMap, err := BuildTypesMap(cc, nameConfig) if err != nil { // early return in case type Ids cannot be retrieved return nil, err } @@ -50,72 +41,73 @@ func NewModelRegistryService(cc grpc.ClientConnInterface) (api.ModelRegistryApi, return &ModelRegistryService{ mlmdClient: client, + nameConfig: nameConfig, typesMap: typesMap, openapiConv: &generated.OpenAPIConverterImpl{}, mapper: mapper.NewMapper(typesMap), }, nil } -func BuildTypesMap(cc grpc.ClientConnInterface) (map[string]int64, error) { +func BuildTypesMap(cc grpc.ClientConnInterface, nameConfig mlmdtypes.MLMDTypeNamesConfig) (map[string]int64, error) { client := proto.NewMetadataStoreServiceClient(cc) registeredModelContextTypeReq := proto.GetContextTypeRequest{ - TypeName: registeredModelTypeName, + TypeName: &nameConfig.RegisteredModelTypeName, } registeredModelResp, err := client.GetContextType(context.Background(), ®isteredModelContextTypeReq) if err != nil { - return nil, fmt.Errorf("error getting context type %s: %v", *registeredModelTypeName, err) + return nil, fmt.Errorf("error getting context type %s: %v", nameConfig.RegisteredModelTypeName, err) } modelVersionContextTypeReq := proto.GetContextTypeRequest{ - TypeName: modelVersionTypeName, + TypeName: &nameConfig.ModelVersionTypeName, } modelVersionResp, err := client.GetContextType(context.Background(), &modelVersionContextTypeReq) if err != nil { - return nil, fmt.Errorf("error getting context type %s: %v", *modelVersionTypeName, err) + return nil, fmt.Errorf("error getting context type %s: %v", nameConfig.ModelVersionTypeName, err) } docArtifactResp, err := client.GetArtifactType(context.Background(), &proto.GetArtifactTypeRequest{ - TypeName: docArtifactTypeName, + TypeName: &nameConfig.DocArtifactTypeName, }) if err != nil { - return nil, fmt.Errorf("error getting artifact type %s: %v", *docArtifactTypeName, err) + return nil, fmt.Errorf("error getting artifact type %s: %v", nameConfig.DocArtifactTypeName, err) } modelArtifactArtifactTypeReq := proto.GetArtifactTypeRequest{ - TypeName: modelArtifactTypeName, + TypeName: &nameConfig.ModelArtifactTypeName, } modelArtifactResp, err := client.GetArtifactType(context.Background(), &modelArtifactArtifactTypeReq) if err != nil { - return nil, fmt.Errorf("error getting artifact type %s: %v", *modelArtifactTypeName, err) + return nil, fmt.Errorf("error getting artifact type %s: %v", nameConfig.ModelArtifactTypeName, err) } servingEnvironmentContextTypeReq := proto.GetContextTypeRequest{ - TypeName: servingEnvironmentTypeName, + TypeName: &nameConfig.ServingEnvironmentTypeName, } servingEnvironmentResp, err := client.GetContextType(context.Background(), &servingEnvironmentContextTypeReq) if err != nil { - return nil, fmt.Errorf("error getting context type %s: %v", *servingEnvironmentTypeName, err) + return nil, fmt.Errorf("error getting context type %s: %v", nameConfig.ServingEnvironmentTypeName, err) } inferenceServiceContextTypeReq := proto.GetContextTypeRequest{ - TypeName: inferenceServiceTypeName, + TypeName: &nameConfig.InferenceServiceTypeName, } inferenceServiceResp, err := client.GetContextType(context.Background(), &inferenceServiceContextTypeReq) if err != nil { - return nil, fmt.Errorf("error getting context type %s: %v", *inferenceServiceTypeName, err) + return nil, fmt.Errorf("error getting context type %s: %v", nameConfig.InferenceServiceTypeName, err) } serveModelExecutionReq := proto.GetExecutionTypeRequest{ - TypeName: serveModelTypeName, + TypeName: &nameConfig.ServeModelTypeName, } serveModelResp, err := client.GetExecutionType(context.Background(), &serveModelExecutionReq) if err != nil { - return nil, fmt.Errorf("error getting execution type %s: %v", *serveModelTypeName, err) + return nil, fmt.Errorf("error getting execution type %s: %v", nameConfig.ServeModelTypeName, err) } typesMap := map[string]int64{ - constants.RegisteredModelTypeName: registeredModelResp.ContextType.GetId(), - constants.ModelVersionTypeName: modelVersionResp.ContextType.GetId(), - constants.DocArtifactTypeName: docArtifactResp.ArtifactType.GetId(), - constants.ModelArtifactTypeName: modelArtifactResp.ArtifactType.GetId(), - constants.ServingEnvironmentTypeName: servingEnvironmentResp.ContextType.GetId(), - constants.InferenceServiceTypeName: inferenceServiceResp.ContextType.GetId(), - constants.ServeModelTypeName: serveModelResp.ExecutionType.GetId(), + nameConfig.RegisteredModelTypeName: registeredModelResp.ContextType.GetId(), + nameConfig.ModelVersionTypeName: modelVersionResp.ContextType.GetId(), + nameConfig.DocArtifactTypeName: docArtifactResp.ArtifactType.GetId(), + nameConfig.ModelArtifactTypeName: modelArtifactResp.ArtifactType.GetId(), + nameConfig.ServingEnvironmentTypeName: servingEnvironmentResp.ContextType.GetId(), + nameConfig.InferenceServiceTypeName: inferenceServiceResp.ContextType.GetId(), + nameConfig.ServeModelTypeName: serveModelResp.ExecutionType.GetId(), } return typesMap, nil } @@ -255,7 +247,7 @@ func (serv *ModelRegistryService) GetRegisteredModelByParams(name *string, exter } getByParamsResp, err := serv.mlmdClient.GetContextsByType(context.Background(), &proto.GetContextsByTypeRequest{ - TypeName: registeredModelTypeName, + TypeName: &serv.nameConfig.RegisteredModelTypeName, Options: &proto.ListOperationOptions{ FilterQuery: &filterQuery, }, @@ -286,7 +278,7 @@ func (serv *ModelRegistryService) GetRegisteredModels(listOptions api.ListOption return nil, err } contextsResp, err := serv.mlmdClient.GetContextsByType(context.Background(), &proto.GetContextsByTypeRequest{ - TypeName: registeredModelTypeName, + TypeName: &serv.nameConfig.RegisteredModelTypeName, Options: listOperationOptions, }) if err != nil { @@ -489,7 +481,7 @@ func (serv *ModelRegistryService) GetModelVersionByParams(versionName *string, r } getByParamsResp, err := serv.mlmdClient.GetContextsByType(context.Background(), &proto.GetContextsByTypeRequest{ - TypeName: modelVersionTypeName, + TypeName: &serv.nameConfig.ModelVersionTypeName, Options: &proto.ListOperationOptions{ FilterQuery: &filterQuery, }, @@ -526,7 +518,7 @@ func (serv *ModelRegistryService) GetModelVersions(listOptions api.ListOptions, } contextsResp, err := serv.mlmdClient.GetContextsByType(context.Background(), &proto.GetContextsByTypeRequest{ - TypeName: modelVersionTypeName, + TypeName: &serv.nameConfig.ModelVersionTypeName, Options: listOperationOptions, }) if err != nil { @@ -789,7 +781,7 @@ func (serv *ModelRegistryService) GetModelArtifactByParams(artifactName *string, } artifactsResponse, err := serv.mlmdClient.GetArtifactsByType(context.Background(), &proto.GetArtifactsByTypeRequest{ - TypeName: modelArtifactTypeName, + TypeName: &serv.nameConfig.ModelArtifactTypeName, Options: &proto.ListOperationOptions{ FilterQuery: &filterQuery, }, @@ -841,7 +833,7 @@ func (serv *ModelRegistryService) GetModelArtifacts(listOptions api.ListOptions, nextPageToken = artifactsResp.NextPageToken } else { artifactsResp, err := serv.mlmdClient.GetArtifactsByType(context.Background(), &proto.GetArtifactsByTypeRequest{ - TypeName: modelArtifactTypeName, + TypeName: &serv.nameConfig.ModelArtifactTypeName, Options: listOperationOptions, }) if err != nil { @@ -963,7 +955,7 @@ func (serv *ModelRegistryService) GetServingEnvironmentByParams(name *string, ex } getByParamsResp, err := serv.mlmdClient.GetContextsByType(context.Background(), &proto.GetContextsByTypeRequest{ - TypeName: servingEnvironmentTypeName, + TypeName: &serv.nameConfig.ServingEnvironmentTypeName, Options: &proto.ListOperationOptions{ FilterQuery: &filterQuery, }, @@ -994,7 +986,7 @@ func (serv *ModelRegistryService) GetServingEnvironments(listOptions api.ListOpt return nil, err } contextsResp, err := serv.mlmdClient.GetContextsByType(context.Background(), &proto.GetContextsByTypeRequest{ - TypeName: servingEnvironmentTypeName, + TypeName: &serv.nameConfig.ServingEnvironmentTypeName, Options: listOperationOptions, }) if err != nil { @@ -1187,7 +1179,7 @@ func (serv *ModelRegistryService) GetInferenceServiceByParams(name *string, serv } getByParamsResp, err := serv.mlmdClient.GetContextsByType(context.Background(), &proto.GetContextsByTypeRequest{ - TypeName: inferenceServiceTypeName, + TypeName: &serv.nameConfig.InferenceServiceTypeName, Options: &proto.ListOperationOptions{ FilterQuery: &filterQuery, }, @@ -1233,7 +1225,7 @@ func (serv *ModelRegistryService) GetInferenceServices(listOptions api.ListOptio listOperationOptions.FilterQuery = &query contextsResp, err := serv.mlmdClient.GetContextsByType(context.Background(), &proto.GetContextsByTypeRequest{ - TypeName: inferenceServiceTypeName, + TypeName: &serv.nameConfig.InferenceServiceTypeName, Options: listOperationOptions, }) if err != nil { @@ -1437,7 +1429,7 @@ func (serv *ModelRegistryService) GetServeModels(listOptions api.ListOptions, in nextPageToken = executionsResp.NextPageToken } else { executionsResp, err := serv.mlmdClient.GetExecutionsByType(context.Background(), &proto.GetExecutionsByTypeRequest{ - TypeName: serveModelTypeName, + TypeName: &serv.nameConfig.ServeModelTypeName, Options: listOperationOptions, }) if err != nil { diff --git a/pkg/core/core_test.go b/pkg/core/core_test.go index a031c541c..26cee6d2c 100644 --- a/pkg/core/core_test.go +++ b/pkg/core/core_test.go @@ -5,13 +5,14 @@ import ( "fmt" "testing" - "github.com/opendatahub-io/model-registry/internal/apiutils" - "github.com/opendatahub-io/model-registry/internal/converter" - "github.com/opendatahub-io/model-registry/internal/ml_metadata/proto" - "github.com/opendatahub-io/model-registry/internal/mlmdtypes" - "github.com/opendatahub-io/model-registry/internal/testutils" - "github.com/opendatahub-io/model-registry/pkg/api" - "github.com/opendatahub-io/model-registry/pkg/openapi" + "github.com/kubeflow/model-registry/internal/apiutils" + "github.com/kubeflow/model-registry/internal/converter" + "github.com/kubeflow/model-registry/internal/defaults" + "github.com/kubeflow/model-registry/internal/ml_metadata/proto" + "github.com/kubeflow/model-registry/internal/mlmdtypes" + "github.com/kubeflow/model-registry/internal/testutils" + "github.com/kubeflow/model-registry/pkg/api" + "github.com/kubeflow/model-registry/pkg/openapi" "github.com/stretchr/testify/suite" "google.golang.org/grpc" ) @@ -53,7 +54,17 @@ type CoreTestSuite struct { mlmdClient proto.MetadataStoreServiceClient } -var canAddFields = apiutils.Of(true) +// test defaults +var ( + registeredModelTypeName = apiutils.Of(defaults.RegisteredModelTypeName) + modelVersionTypeName = apiutils.Of(defaults.ModelVersionTypeName) + modelArtifactTypeName = apiutils.Of(defaults.ModelArtifactTypeName) + docArtifactTypeName = apiutils.Of(defaults.DocArtifactTypeName) + servingEnvironmentTypeName = apiutils.Of(defaults.ServingEnvironmentTypeName) + inferenceServiceTypeName = apiutils.Of(defaults.InferenceServiceTypeName) + serveModelTypeName = apiutils.Of(defaults.ServeModelTypeName) + canAddFields = apiutils.Of(true) +) func TestRunCoreTestSuite(t *testing.T) { // before all @@ -102,10 +113,11 @@ func (suite *CoreTestSuite) AfterTest(suiteName, testName string) { } func (suite *CoreTestSuite) setupModelRegistryService() *ModelRegistryService { - _, err := mlmdtypes.CreateMLMDTypes(suite.grpcConn) + mlmdtypeNames := mlmdtypes.NewMLMDTypeNamesConfigFromDefaults() + _, err := mlmdtypes.CreateMLMDTypes(suite.grpcConn, mlmdtypeNames) suite.Nilf(err, "error creating MLMD types: %v", err) // setup model registry service - service, err := NewModelRegistryService(suite.grpcConn) + service, err := NewModelRegistryService(suite.grpcConn, mlmdtypeNames) suite.Nilf(err, "error creating core service: %v", err) mrService, ok := service.(*ModelRegistryService) suite.True(ok) @@ -120,9 +132,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 +162,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 +226,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), }, }, } @@ -451,9 +457,9 @@ func (suite *CoreTestSuite) TestModelRegistryFailureForOmittedFieldInRegisteredM suite.Nil(err) // steps to create model registry service - _, err = mlmdtypes.CreateMLMDTypes(suite.grpcConn) + _, err = mlmdtypes.CreateMLMDTypes(suite.grpcConn, mlmdtypes.NewMLMDTypeNamesConfigFromDefaults()) suite.NotNil(err) - suite.Regexp("error setting up context type odh.RegisteredModel: rpc error: code = AlreadyExists.*", err.Error()) + suite.Regexp("error setting up context type "+*registeredModelTypeName+": rpc error: code = AlreadyExists.*", err.Error()) } func (suite *CoreTestSuite) TestModelRegistryFailureForOmittedFieldInModelVersion() { @@ -471,9 +477,9 @@ func (suite *CoreTestSuite) TestModelRegistryFailureForOmittedFieldInModelVersio suite.Nil(err) // steps to create model registry service - _, err = mlmdtypes.CreateMLMDTypes(suite.grpcConn) + _, err = mlmdtypes.CreateMLMDTypes(suite.grpcConn, mlmdtypes.NewMLMDTypeNamesConfigFromDefaults()) suite.NotNil(err) - suite.Regexp("error setting up context type odh.ModelVersion: rpc error: code = AlreadyExists.*", err.Error()) + suite.Regexp("error setting up context type "+*modelVersionTypeName+": rpc error: code = AlreadyExists.*", err.Error()) } func (suite *CoreTestSuite) TestModelRegistryFailureForOmittedFieldInModelArtifact() { @@ -491,9 +497,9 @@ func (suite *CoreTestSuite) TestModelRegistryFailureForOmittedFieldInModelArtifa suite.Nil(err) // steps to create model registry service - _, err = mlmdtypes.CreateMLMDTypes(suite.grpcConn) + _, err = mlmdtypes.CreateMLMDTypes(suite.grpcConn, mlmdtypes.NewMLMDTypeNamesConfigFromDefaults()) suite.NotNil(err) - suite.Regexp("error setting up artifact type odh.ModelArtifact: rpc error: code = AlreadyExists.*", err.Error()) + suite.Regexp("error setting up artifact type "+*modelArtifactTypeName+": rpc error: code = AlreadyExists.*", err.Error()) } func (suite *CoreTestSuite) TestModelRegistryFailureForOmittedFieldInServingEnvironment() { @@ -510,9 +516,9 @@ func (suite *CoreTestSuite) TestModelRegistryFailureForOmittedFieldInServingEnvi suite.Nil(err) // steps to create model registry service - _, err = mlmdtypes.CreateMLMDTypes(suite.grpcConn) + _, err = mlmdtypes.CreateMLMDTypes(suite.grpcConn, mlmdtypes.NewMLMDTypeNamesConfigFromDefaults()) suite.NotNil(err) - suite.Regexp("error setting up context type odh.ServingEnvironment: rpc error: code = AlreadyExists.*", err.Error()) + suite.Regexp("error setting up context type "+*servingEnvironmentTypeName+": rpc error: code = AlreadyExists.*", err.Error()) } func (suite *CoreTestSuite) TestModelRegistryFailureForOmittedFieldInInferenceService() { @@ -530,9 +536,9 @@ func (suite *CoreTestSuite) TestModelRegistryFailureForOmittedFieldInInferenceSe suite.Nil(err) // steps to create model registry service - _, err = mlmdtypes.CreateMLMDTypes(suite.grpcConn) + _, err = mlmdtypes.CreateMLMDTypes(suite.grpcConn, mlmdtypes.NewMLMDTypeNamesConfigFromDefaults()) suite.NotNil(err) - suite.Regexp("error setting up context type odh.InferenceService: rpc error: code = AlreadyExists.*", err.Error()) + suite.Regexp("error setting up context type "+*inferenceServiceTypeName+": rpc error: code = AlreadyExists.*", err.Error()) } func (suite *CoreTestSuite) TestModelRegistryFailureForOmittedFieldInServeModel() { @@ -550,9 +556,9 @@ func (suite *CoreTestSuite) TestModelRegistryFailureForOmittedFieldInServeModel( suite.Nil(err) // steps to create model registry service - _, err = mlmdtypes.CreateMLMDTypes(suite.grpcConn) + _, err = mlmdtypes.CreateMLMDTypes(suite.grpcConn, mlmdtypes.NewMLMDTypeNamesConfigFromDefaults()) suite.NotNil(err) - suite.Regexp("error setting up execution type odh.ServeModel: rpc error: code = AlreadyExists.*", err.Error()) + suite.Regexp("error setting up execution type "+*serveModelTypeName+": rpc error: code = AlreadyExists.*", err.Error()) } // REGISTERED MODELS @@ -570,9 +576,7 @@ func (suite *CoreTestSuite) TestCreateRegisteredModel() { State: &state, CustomProperties: &map[string]openapi.MetadataValue{ "owner": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &owner, - }, + MetadataStringValue: converter.NewMetadataStringValue(owner), }, }, } @@ -614,9 +618,7 @@ func (suite *CoreTestSuite) TestUpdateRegisteredModel() { ExternalID: &modelExternalId, CustomProperties: &map[string]openapi.MetadataValue{ "owner": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &owner, - }, + MetadataStringValue: converter.NewMetadataStringValue(owner), }, }, } @@ -640,9 +642,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 +703,7 @@ func (suite *CoreTestSuite) TestGetRegisteredModelById() { State: &state, CustomProperties: &map[string]openapi.MetadataValue{ "owner": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &owner, - }, + MetadataStringValue: converter.NewMetadataStringValue(owner), }, }, } @@ -1042,9 +1040,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 +1115,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 +1378,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 +1393,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 +1409,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 +1436,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 +1461,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 +1477,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 +1510,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 +1527,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 +1550,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 +1564,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 +1612,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 +1628,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 +1643,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 +1669,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 +1695,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 +1710,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 +1732,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 +1750,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 +1768,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 +1788,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 +1800,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 +1818,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 +1855,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 +1870,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 +1885,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 +1935,7 @@ func (suite *CoreTestSuite) TestCreateServingEnvironment() { Description: &entityDescription, CustomProperties: &map[string]openapi.MetadataValue{ "owner": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &owner, - }, + MetadataStringValue: converter.NewMetadataStringValue(owner), }, }, } @@ -2018,9 +1976,7 @@ func (suite *CoreTestSuite) TestUpdateServingEnvironment() { ExternalID: &entityExternalId, CustomProperties: &map[string]openapi.MetadataValue{ "owner": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &owner, - }, + MetadataStringValue: converter.NewMetadataStringValue(owner), }, }, } @@ -2044,9 +2000,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 +2059,7 @@ func (suite *CoreTestSuite) TestGetServingEnvironmentById() { ExternalID: &entityExternalId, CustomProperties: &map[string]openapi.MetadataValue{ "owner": { - MetadataStringValue: &openapi.MetadataStringValue{ - StringValue: &owner, - }, + MetadataStringValue: converter.NewMetadataStringValue(owner), }, }, } @@ -2375,9 +2327,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 +2372,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 +2404,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 +2421,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 +2498,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 +2513,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 +2540,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 +2566,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 +2584,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 +2627,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 +2725,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 +2750,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 +2768,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 +2793,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 +2811,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 +2972,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 +2986,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 +2999,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 +3025,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 +3066,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 +3092,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 +3127,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 +3174,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 +3190,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 +3229,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 +3242,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 +3255,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..8e29c4daf 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. @@ -36,18 +36,16 @@ type BaseArtifact struct { CreateTimeSinceEpoch *string `json:"createTimeSinceEpoch,omitempty"` // Output only. Last update time of the resource since epoch in millisecond since epoch. LastUpdateTimeSinceEpoch *string `json:"lastUpdateTimeSinceEpoch,omitempty"` - ArtifactType string `json:"artifactType"` } // NewBaseArtifact instantiates a new BaseArtifact 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 NewBaseArtifact(artifactType string) *BaseArtifact { +func NewBaseArtifact() *BaseArtifact { this := BaseArtifact{} var state ArtifactState = ARTIFACTSTATE_UNKNOWN this.State = &state - this.ArtifactType = artifactType return &this } @@ -349,30 +347,6 @@ func (o *BaseArtifact) SetLastUpdateTimeSinceEpoch(v string) { o.LastUpdateTimeSinceEpoch = &v } -// GetArtifactType returns the ArtifactType field value -func (o *BaseArtifact) GetArtifactType() string { - if o == nil { - var ret string - return ret - } - - return o.ArtifactType -} - -// GetArtifactTypeOk returns a tuple with the ArtifactType field value -// and a boolean to check if the value has been set. -func (o *BaseArtifact) GetArtifactTypeOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.ArtifactType, true -} - -// SetArtifactType sets field value -func (o *BaseArtifact) SetArtifactType(v string) { - o.ArtifactType = v -} - func (o BaseArtifact) MarshalJSON() ([]byte, error) { toSerialize, err := o.ToMap() if err != nil { @@ -410,7 +384,6 @@ func (o BaseArtifact) ToMap() (map[string]interface{}, error) { if !IsNil(o.LastUpdateTimeSinceEpoch) { toSerialize["lastUpdateTimeSinceEpoch"] = o.LastUpdateTimeSinceEpoch } - toSerialize["artifactType"] = o.ArtifactType return toSerialize, nil } 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..f34fddd05 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. @@ -19,6 +19,7 @@ var _ MappedNullable = &DocArtifact{} // DocArtifact A document. type DocArtifact struct { + ArtifactType string `json:"artifactType"` // User provided custom properties which are not defined by its type. CustomProperties *map[string]MetadataValue `json:"customProperties,omitempty"` // An optional description about the resource. @@ -36,7 +37,6 @@ type DocArtifact struct { CreateTimeSinceEpoch *string `json:"createTimeSinceEpoch,omitempty"` // Output only. Last update time of the resource since epoch in millisecond since epoch. LastUpdateTimeSinceEpoch *string `json:"lastUpdateTimeSinceEpoch,omitempty"` - ArtifactType string `json:"artifactType"` } // NewDocArtifact instantiates a new DocArtifact object @@ -47,7 +47,6 @@ func NewDocArtifact(artifactType string) *DocArtifact { this := DocArtifact{} var state ArtifactState = ARTIFACTSTATE_UNKNOWN this.State = &state - this.ArtifactType = artifactType return &this } @@ -56,13 +55,37 @@ func NewDocArtifact(artifactType string) *DocArtifact { // but it doesn't guarantee that properties required by API are set func NewDocArtifactWithDefaults() *DocArtifact { this := DocArtifact{} - var state ArtifactState = ARTIFACTSTATE_UNKNOWN - this.State = &state var artifactType string = "doc-artifact" this.ArtifactType = artifactType + var state ArtifactState = ARTIFACTSTATE_UNKNOWN + this.State = &state return &this } +// GetArtifactType returns the ArtifactType field value +func (o *DocArtifact) GetArtifactType() string { + if o == nil { + var ret string + return ret + } + + return o.ArtifactType +} + +// GetArtifactTypeOk returns a tuple with the ArtifactType field value +// and a boolean to check if the value has been set. +func (o *DocArtifact) GetArtifactTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ArtifactType, true +} + +// SetArtifactType sets field value +func (o *DocArtifact) SetArtifactType(v string) { + o.ArtifactType = v +} + // GetCustomProperties returns the CustomProperties field value if set, zero value otherwise. func (o *DocArtifact) GetCustomProperties() map[string]MetadataValue { if o == nil || IsNil(o.CustomProperties) { @@ -351,30 +374,6 @@ func (o *DocArtifact) SetLastUpdateTimeSinceEpoch(v string) { o.LastUpdateTimeSinceEpoch = &v } -// GetArtifactType returns the ArtifactType field value -func (o *DocArtifact) GetArtifactType() string { - if o == nil { - var ret string - return ret - } - - return o.ArtifactType -} - -// GetArtifactTypeOk returns a tuple with the ArtifactType field value -// and a boolean to check if the value has been set. -func (o *DocArtifact) GetArtifactTypeOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.ArtifactType, true -} - -// SetArtifactType sets field value -func (o *DocArtifact) SetArtifactType(v string) { - o.ArtifactType = v -} - func (o DocArtifact) MarshalJSON() ([]byte, error) { toSerialize, err := o.ToMap() if err != nil { @@ -385,6 +384,7 @@ func (o DocArtifact) MarshalJSON() ([]byte, error) { func (o DocArtifact) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} + toSerialize["artifactType"] = o.ArtifactType if !IsNil(o.CustomProperties) { toSerialize["customProperties"] = o.CustomProperties } @@ -412,7 +412,6 @@ func (o DocArtifact) ToMap() (map[string]interface{}, error) { if !IsNil(o.LastUpdateTimeSinceEpoch) { toSerialize["lastUpdateTimeSinceEpoch"] = o.LastUpdateTimeSinceEpoch } - toSerialize["artifactType"] = o.ArtifactType return toSerialize, nil } 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..c0992e75c 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. @@ -19,6 +19,7 @@ var _ MappedNullable = &ModelArtifact{} // ModelArtifact An ML model artifact. type ModelArtifact struct { + ArtifactType string `json:"artifactType"` // User provided custom properties which are not defined by its type. CustomProperties *map[string]MetadataValue `json:"customProperties,omitempty"` // An optional description about the resource. @@ -36,7 +37,6 @@ type ModelArtifact struct { CreateTimeSinceEpoch *string `json:"createTimeSinceEpoch,omitempty"` // Output only. Last update time of the resource since epoch in millisecond since epoch. LastUpdateTimeSinceEpoch *string `json:"lastUpdateTimeSinceEpoch,omitempty"` - ArtifactType string `json:"artifactType"` // Name of the model format. ModelFormatName *string `json:"modelFormatName,omitempty"` // Storage secret name. @@ -57,7 +57,6 @@ func NewModelArtifact(artifactType string) *ModelArtifact { this := ModelArtifact{} var state ArtifactState = ARTIFACTSTATE_UNKNOWN this.State = &state - this.ArtifactType = artifactType return &this } @@ -66,13 +65,37 @@ func NewModelArtifact(artifactType string) *ModelArtifact { // but it doesn't guarantee that properties required by API are set func NewModelArtifactWithDefaults() *ModelArtifact { this := ModelArtifact{} - var state ArtifactState = ARTIFACTSTATE_UNKNOWN - this.State = &state var artifactType string = "model-artifact" this.ArtifactType = artifactType + var state ArtifactState = ARTIFACTSTATE_UNKNOWN + this.State = &state return &this } +// GetArtifactType returns the ArtifactType field value +func (o *ModelArtifact) GetArtifactType() string { + if o == nil { + var ret string + return ret + } + + return o.ArtifactType +} + +// GetArtifactTypeOk returns a tuple with the ArtifactType field value +// and a boolean to check if the value has been set. +func (o *ModelArtifact) GetArtifactTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ArtifactType, true +} + +// SetArtifactType sets field value +func (o *ModelArtifact) SetArtifactType(v string) { + o.ArtifactType = v +} + // GetCustomProperties returns the CustomProperties field value if set, zero value otherwise. func (o *ModelArtifact) GetCustomProperties() map[string]MetadataValue { if o == nil || IsNil(o.CustomProperties) { @@ -361,30 +384,6 @@ func (o *ModelArtifact) SetLastUpdateTimeSinceEpoch(v string) { o.LastUpdateTimeSinceEpoch = &v } -// GetArtifactType returns the ArtifactType field value -func (o *ModelArtifact) GetArtifactType() string { - if o == nil { - var ret string - return ret - } - - return o.ArtifactType -} - -// GetArtifactTypeOk returns a tuple with the ArtifactType field value -// and a boolean to check if the value has been set. -func (o *ModelArtifact) GetArtifactTypeOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.ArtifactType, true -} - -// SetArtifactType sets field value -func (o *ModelArtifact) SetArtifactType(v string) { - o.ArtifactType = v -} - // GetModelFormatName returns the ModelFormatName field value if set, zero value otherwise. func (o *ModelArtifact) GetModelFormatName() string { if o == nil || IsNil(o.ModelFormatName) { @@ -555,6 +554,7 @@ func (o ModelArtifact) MarshalJSON() ([]byte, error) { func (o ModelArtifact) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} + toSerialize["artifactType"] = o.ArtifactType if !IsNil(o.CustomProperties) { toSerialize["customProperties"] = o.CustomProperties } @@ -582,7 +582,6 @@ func (o ModelArtifact) ToMap() (map[string]interface{}, error) { if !IsNil(o.LastUpdateTimeSinceEpoch) { toSerialize["lastUpdateTimeSinceEpoch"] = o.LastUpdateTimeSinceEpoch } - toSerialize["artifactType"] = o.ArtifactType if !IsNil(o.ModelFormatName) { toSerialize["modelFormatName"] = o.ModelFormatName } 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 27808c3a2..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" @@ -29,7 +31,7 @@ INITIAL_CONTENT=$(cat <<EOF package openapi import ( - model "github.com/opendatahub-io/model-registry/pkg/openapi" + model "github.com/kubeflow/model-registry/pkg/openapi" ) @@ -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/templates/go-server/controller-api.mustache b/templates/go-server/controller-api.mustache index 4735921ac..38996ed82 100644 --- a/templates/go-server/controller-api.mustache +++ b/templates/go-server/controller-api.mustache @@ -20,7 +20,7 @@ import ( "github.com/go-chi/chi/v5" {{/chi}} - model "github.com/opendatahub-io/model-registry/pkg/openapi" + model "github.com/kubeflow/model-registry/pkg/openapi" {{/routers}} ) diff --git a/test/robot/MRandLogicalModel.robot b/test/robot/MRandLogicalModel.robot index fd3ff706e..fbfd82f34 100644 --- a/test/robot/MRandLogicalModel.robot +++ b/test/robot/MRandLogicalModel.robot @@ -29,13 +29,13 @@ Verify basic logical mapping between MR and MLMD # RegisteredModel shall result in a MLMD Context ${mlmdProto} Get Context By Single Id ${rId} Log To Console ${mlmdProto} - Should be equal ${mlmdProto.type} odh.RegisteredModel + Should be equal ${mlmdProto.type} kf.RegisteredModel Should be equal ${mlmdProto.name} ${name} # ModelVersion shall result in a MLMD Context and parent Context(of RegisteredModel) ${mlmdProto} Get Context By Single Id ${vId} Log To Console ${mlmdProto} - Should be equal ${mlmdProto.type} odh.ModelVersion + Should be equal ${mlmdProto.type} kf.ModelVersion Should be equal ${mlmdProto.name} ${rId}:v1 ${mlmdProto} Get Parent Contexts By Context ${vId} Should be equal ${mlmdProto[0].id} ${rId} @@ -44,7 +44,7 @@ Verify basic logical mapping between MR and MLMD ${aNamePrefix} Set Variable ${vId}: ${mlmdProto} Get Artifact By Single Id ${aId} Log To Console ${mlmdProto} - Should be equal ${mlmdProto.type} odh.ModelArtifact + Should be equal ${mlmdProto.type} kf.ModelArtifact Should Start With ${mlmdProto.name} ${aNamePrefix} Should be equal ${mlmdProto.uri} s3://12345 ${mlmdProto} Get Artifacts By Context ${vId} 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:"