converter

package
v0.2.0-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Int64ToString

func Int64ToString(id *int64) *string

Int64ToString converts numeric id to string-based one

func MapArtifactType

func MapArtifactType(source *proto.Artifact) (string, error)

func MapDescription

func MapDescription(properties map[string]*proto.Value) *string

func MapDocArtifactName

func MapDocArtifactName(source *OpenAPIModelWrapper[openapi.DocArtifact]) *string

maps the user-provided name into MLMD one, i.e., prefixing it with either the parent resource id or a generated uuid. If not provided, autogenerate the name itself

func MapDocArtifactProperties

func MapDocArtifactProperties(source *openapi.DocArtifact) (map[string]*proto.Value, error)

func MapDocArtifactType

func MapDocArtifactType(_ *openapi.DocArtifact) *string

get DocArtifact MLMD type name

func MapInferenceServiceDesiredState

func MapInferenceServiceDesiredState(properties map[string]*proto.Value) *openapi.InferenceServiceState

func MapInferenceServiceName

func MapInferenceServiceName(source *OpenAPIModelWrapper[openapi.InferenceService]) *string

MapInferenceServiceName maps the user-provided name into MLMD one, i.e., prefixing it with either the parent resource id or a generated uuid ref: > InferenceService context is actually a child of ServingEnvironment parent context

func MapInferenceServiceProperties

func MapInferenceServiceProperties(source *openapi.InferenceService) (map[string]*proto.Value, error)

MapInferenceServiceProperties maps InferenceService fields to specific MLMD properties

func MapInferenceServiceType

func MapInferenceServiceType(_ *openapi.InferenceService) *string

MapInferenceServiceType return InferenceService corresponding MLMD context type

func MapIntProperty

func MapIntProperty(properties map[string]*proto.Value, key string) *string

MapIntProperty maps int proto.Value property to specific string field

func MapIntPropertyAsValue

func MapIntPropertyAsValue(properties map[string]*proto.Value, key string) string

MapIntPropertyAsValue maps int proto.Value property to specific string field

func MapLastKnownState

func MapLastKnownState(source *openapi.ExecutionState) (*proto.Execution_State, error)

MapLastKnownState maps LastKnownState field from ServeModel to Execution

func MapMLMDArtifactState

func MapMLMDArtifactState(source *proto.Artifact_State) (st *openapi.ArtifactState)

func MapMLMDCustomProperties

func MapMLMDCustomProperties(source map[string]*proto.Value) (map[string]openapi.MetadataValue, error)

MapMLMDCustomProperties maps MLMD custom properties model to OpenAPI one

func MapMLMDServeModelLastKnownState

func MapMLMDServeModelLastKnownState(source *proto.Execution_State) *openapi.ExecutionState

func MapModelArtifactFormatName

func MapModelArtifactFormatName(properties map[string]*proto.Value) *string

func MapModelArtifactFormatVersion

func MapModelArtifactFormatVersion(properties map[string]*proto.Value) *string

func MapModelArtifactName

func MapModelArtifactName(source *OpenAPIModelWrapper[openapi.ModelArtifact]) *string

MapModelArtifactName maps the user-provided name into MLMD one, i.e., prefixing it with either the parent resource id or a generated uuid. If not provided, autogenerate the name itself

func MapModelArtifactProperties

func MapModelArtifactProperties(source *openapi.ModelArtifact) (map[string]*proto.Value, error)

MapModelArtifactProperties maps ModelArtifact fields to specific MLMD properties

func MapModelArtifactServiceAccountName

func MapModelArtifactServiceAccountName(properties map[string]*proto.Value) *string

func MapModelArtifactStorageKey

func MapModelArtifactStorageKey(properties map[string]*proto.Value) *string

func MapModelArtifactStoragePath

func MapModelArtifactStoragePath(properties map[string]*proto.Value) *string

func MapModelArtifactType

func MapModelArtifactType(_ *openapi.ModelArtifact) *string

MapModelArtifactType return ModelArtifact corresponding MLMD context type

func MapModelVersionName

func MapModelVersionName(source *OpenAPIModelWrapper[openapi.ModelVersion]) *string

MapModelVersionName maps the user-provided name into MLMD one, i.e., prefixing it with either the parent resource id or a generated uuid

func MapModelVersionProperties

func MapModelVersionProperties(source *OpenAPIModelWrapper[openapi.ModelVersion]) (map[string]*proto.Value, error)

MapModelVersionProperties maps ModelVersion fields to specific MLMD properties

func MapModelVersionState

func MapModelVersionState(properties map[string]*proto.Value) *openapi.ModelVersionState

func MapModelVersionType

func MapModelVersionType(_ *openapi.ModelVersion) *string

MapModelVersionType return ModelVersion corresponding MLMD context type

func MapNameFromOwned

func MapNameFromOwned(source *string) *string

MapNameFromOwned derive the entity name from the mlmd fullname for owned entity such as ModelVersion for potentially owned entity such as ModelArtifact

func MapOpenAPIArtifactState

func MapOpenAPIArtifactState(source *openapi.ArtifactState) (*proto.Artifact_State, error)

func MapOpenAPICustomProperties

func MapOpenAPICustomProperties(source *map[string]openapi.MetadataValue) (map[string]*proto.Value, error)

MapOpenAPICustomProperties maps OpenAPI custom properties model to MLMD one

func MapPropertyAuthor

func MapPropertyAuthor(properties map[string]*proto.Value) *string

func MapPropertyModelVersionId

func MapPropertyModelVersionId(properties map[string]*proto.Value) *string

func MapPropertyModelVersionIdAsValue

func MapPropertyModelVersionIdAsValue(properties map[string]*proto.Value) string

func MapPropertyRegisteredModelId

func MapPropertyRegisteredModelId(properties map[string]*proto.Value) string

func MapPropertyRuntime

func MapPropertyRuntime(properties map[string]*proto.Value) *string

func MapPropertyServingEnvironmentId

func MapPropertyServingEnvironmentId(properties map[string]*proto.Value) string

func MapRegisteredModelIdFromOwned

func MapRegisteredModelIdFromOwned(source *string) (string, error)

func MapRegisteredModelProperties

func MapRegisteredModelProperties(source *openapi.RegisteredModel) (map[string]*proto.Value, error)

MapRegisteredModelProperties maps RegisteredModel fields to specific MLMD properties

func MapRegisteredModelState

func MapRegisteredModelState(properties map[string]*proto.Value) *openapi.RegisteredModelState

func MapRegisteredModelType

func MapRegisteredModelType(_ *openapi.RegisteredModel) *string

MapRegisteredModelType return RegisteredModel corresponding MLMD context type

func MapServeModelName

func MapServeModelName(source *OpenAPIModelWrapper[openapi.ServeModel]) *string

MapServeModelName maps the user-provided name into MLMD one, i.e., prefixing it with either the parent resource id or a generated uuid. If not provided, autogenerate the name itself

func MapServeModelProperties

func MapServeModelProperties(source *openapi.ServeModel) (map[string]*proto.Value, error)

MapServeModelProperties maps ServeModel fields to specific MLMD properties

func MapServeModelType

func MapServeModelType(_ *openapi.ServeModel) *string

MapServeModelType return ServeModel corresponding MLMD context type

func MapServingEnvironmentProperties

func MapServingEnvironmentProperties(source *openapi.ServingEnvironment) (map[string]*proto.Value, error)

MapServingEnvironmentProperties maps ServingEnvironment fields to specific MLMD properties

func MapServingEnvironmentType

func MapServingEnvironmentType(_ *openapi.ServingEnvironment) *string

MapServingEnvironmentType return ServingEnvironment corresponding MLMD context type

func MapStringProperty

func MapStringProperty(properties map[string]*proto.Value, key string) *string

MapStringProperty maps string proto.Value property to specific string field

func NewMetadataBoolValue

func NewMetadataBoolValue(value bool) *openapi.MetadataBoolValue

func NewMetadataDoubleValue

func NewMetadataDoubleValue(value float64) *openapi.MetadataDoubleValue

func NewMetadataIntValue

func NewMetadataIntValue(value string) *openapi.MetadataIntValue

func NewMetadataProtoValue

func NewMetadataProtoValue(typeDef string, value string) *openapi.MetadataProtoValue

func NewMetadataStringValue

func NewMetadataStringValue(value string) *openapi.MetadataStringValue

func NewMetadataStructValue

func NewMetadataStructValue(value string) *openapi.MetadataStructValue

func PrefixWhenOwned

func PrefixWhenOwned(ownerId *string, entityName string) string

PrefixWhenOwned compose the mlmd fullname by using ownerId as prefix For owned entity such as ModelVersion for potentially owned entity such as ModelArtifact

func StringToInt32

func StringToInt32(idString string) (int32, error)

StringToInt32 converts string-based numeric value (a OpenAPI string literal consisting only of digits) to int32 if numeric, otherwise return error

func StringToInt64

func StringToInt64(id *string) (*int64, error)

StringToInt64 converts string-based id to int64 if numeric, otherwise return error

Types

type MLMDToOpenAPIConverter

type MLMDToOpenAPIConverter interface {
	// goverter:map Properties Description | MapDescription
	// goverter:map Properties State | MapRegisteredModelState
	ConvertRegisteredModel(source *proto.Context) (*openapi.RegisteredModel, error)

	// goverter:map Name | MapNameFromOwned
	// goverter:map Name RegisteredModelId | MapRegisteredModelIdFromOwned
	// goverter:map Properties Description | MapDescription
	// goverter:map Properties State | MapModelVersionState
	// goverter:map Properties Author | MapPropertyAuthor
	ConvertModelVersion(source *proto.Context) (*openapi.ModelVersion, error)

	// goverter:map Name | MapNameFromOwned
	// goverter:map . ArtifactType | MapArtifactType
	// goverter:map State | MapMLMDArtifactState
	// goverter:map Properties Description | MapDescription
	// goverter:map Properties ModelFormatName | MapModelArtifactFormatName
	// goverter:map Properties ModelFormatVersion | MapModelArtifactFormatVersion
	// goverter:map Properties StorageKey | MapModelArtifactStorageKey
	// goverter:map Properties StoragePath | MapModelArtifactStoragePath
	// goverter:map Properties ServiceAccountName | MapModelArtifactServiceAccountName
	ConvertModelArtifact(source *proto.Artifact) (*openapi.ModelArtifact, error)

	// goverter:map Name | MapNameFromOwned
	// goverter:map . ArtifactType | MapArtifactType
	// goverter:map State | MapMLMDArtifactState
	// goverter:map Properties Description | MapDescription
	ConvertDocArtifact(source *proto.Artifact) (*openapi.DocArtifact, error)

	// goverter:map Name | MapNameFromOwned
	// goverter:map Properties Description | MapDescription
	ConvertServingEnvironment(source *proto.Context) (*openapi.ServingEnvironment, error)

	// goverter:map Name | MapNameFromOwned
	// goverter:map Properties Description | MapDescription
	// goverter:map Properties Runtime | MapPropertyRuntime
	// goverter:map Properties ModelVersionId | MapPropertyModelVersionId
	// goverter:map Properties RegisteredModelId | MapPropertyRegisteredModelId
	// goverter:map Properties ServingEnvironmentId | MapPropertyServingEnvironmentId
	// goverter:map Properties DesiredState | MapInferenceServiceDesiredState
	ConvertInferenceService(source *proto.Context) (*openapi.InferenceService, error)

	// goverter:map Name | MapNameFromOwned
	// goverter:map Properties Description | MapDescription
	// goverter:map Properties ModelVersionId | MapPropertyModelVersionIdAsValue
	// goverter:map LastKnownState | MapMLMDServeModelLastKnownState
	ConvertServeModel(source *proto.Execution) (*openapi.ServeModel, error)
}

goverter:converter goverter:output:file ./generated/mlmd_openapi_converter.gen.go goverter:wrapErrors goverter:matchIgnoreCase goverter:useZeroValueOnPointerInconsistency goverter:extend Int64ToString goverter:extend StringToInt64 goverter:extend MapMLMDCustomProperties

type OpenAPIConverter

type OpenAPIConverter interface {
	// goverter:ignore Id CreateTimeSinceEpoch LastUpdateTimeSinceEpoch
	ConvertRegisteredModelCreate(source *openapi.RegisteredModelCreate) (*openapi.RegisteredModel, error)

	// goverter:ignore Id CreateTimeSinceEpoch LastUpdateTimeSinceEpoch Name
	ConvertRegisteredModelUpdate(source *openapi.RegisteredModelUpdate) (*openapi.RegisteredModel, error)

	// goverter:ignore Id CreateTimeSinceEpoch LastUpdateTimeSinceEpoch
	ConvertModelVersionCreate(source *openapi.ModelVersionCreate) (*openapi.ModelVersion, error)

	// goverter:ignore Id CreateTimeSinceEpoch LastUpdateTimeSinceEpoch Name RegisteredModelId
	ConvertModelVersionUpdate(source *openapi.ModelVersionUpdate) (*openapi.ModelVersion, error)

	// goverter:ignore Id CreateTimeSinceEpoch LastUpdateTimeSinceEpoch ArtifactType
	ConvertModelArtifactCreate(source *openapi.ModelArtifactCreate) (*openapi.ModelArtifact, error)

	// goverter:ignore Id CreateTimeSinceEpoch LastUpdateTimeSinceEpoch ArtifactType Name
	ConvertModelArtifactUpdate(source *openapi.ModelArtifactUpdate) (*openapi.ModelArtifact, error)

	// goverter:ignore Id CreateTimeSinceEpoch LastUpdateTimeSinceEpoch
	ConvertServingEnvironmentCreate(source *openapi.ServingEnvironmentCreate) (*openapi.ServingEnvironment, error)

	// goverter:ignore Id CreateTimeSinceEpoch LastUpdateTimeSinceEpoch Name
	ConvertServingEnvironmentUpdate(source *openapi.ServingEnvironmentUpdate) (*openapi.ServingEnvironment, error)

	// goverter:ignore Id CreateTimeSinceEpoch LastUpdateTimeSinceEpoch
	ConvertInferenceServiceCreate(source *openapi.InferenceServiceCreate) (*openapi.InferenceService, error)

	// goverter:ignore Id CreateTimeSinceEpoch LastUpdateTimeSinceEpoch Name RegisteredModelId ServingEnvironmentId
	ConvertInferenceServiceUpdate(source *openapi.InferenceServiceUpdate) (*openapi.InferenceService, error)

	// goverter:ignore Id CreateTimeSinceEpoch LastUpdateTimeSinceEpoch
	ConvertServeModelCreate(source *openapi.ServeModelCreate) (*openapi.ServeModel, error)

	// goverter:ignore Id CreateTimeSinceEpoch LastUpdateTimeSinceEpoch Name ModelVersionId
	ConvertServeModelUpdate(source *openapi.ServeModelUpdate) (*openapi.ServeModel, error)

	// Ignore all fields that ARE editable
	// goverter:default InitRegisteredModelWithUpdate
	// goverter:autoMap Existing
	// goverter:ignore Id CreateTimeSinceEpoch LastUpdateTimeSinceEpoch Description ExternalId CustomProperties State
	OverrideNotEditableForRegisteredModel(source OpenapiUpdateWrapper[openapi.RegisteredModel]) (openapi.RegisteredModel, error)

	// Ignore all fields that ARE editable
	// goverter:default InitModelVersionWithUpdate
	// goverter:autoMap Existing
	// goverter:ignore Id CreateTimeSinceEpoch LastUpdateTimeSinceEpoch Description ExternalId CustomProperties State Author
	OverrideNotEditableForModelVersion(source OpenapiUpdateWrapper[openapi.ModelVersion]) (openapi.ModelVersion, error)

	// Ignore all fields that ARE editable
	// goverter:default InitDocArtifactWithUpdate
	// goverter:autoMap Existing
	// goverter:ignore Id Name ArtifactType CreateTimeSinceEpoch LastUpdateTimeSinceEpoch Description ExternalId CustomProperties Uri State
	OverrideNotEditableForDocArtifact(source OpenapiUpdateWrapper[openapi.DocArtifact]) (openapi.DocArtifact, error)

	// Ignore all fields that ARE editable
	// goverter:default InitModelArtifactWithUpdate
	// goverter:autoMap Existing
	// goverter:ignore Id CreateTimeSinceEpoch LastUpdateTimeSinceEpoch Description ExternalId CustomProperties Uri State ServiceAccountName ModelFormatName ModelFormatVersion StorageKey StoragePath
	OverrideNotEditableForModelArtifact(source OpenapiUpdateWrapper[openapi.ModelArtifact]) (openapi.ModelArtifact, error)

	// Ignore all fields that ARE editable
	// goverter:default InitServingEnvironmentWithUpdate
	// goverter:autoMap Existing
	// goverter:ignore Id CreateTimeSinceEpoch LastUpdateTimeSinceEpoch Description ExternalId CustomProperties
	OverrideNotEditableForServingEnvironment(source OpenapiUpdateWrapper[openapi.ServingEnvironment]) (openapi.ServingEnvironment, error)

	// Ignore all fields that ARE editable
	// goverter:default InitInferenceServiceWithUpdate
	// goverter:autoMap Existing
	// goverter:ignore Id CreateTimeSinceEpoch LastUpdateTimeSinceEpoch Description ExternalId CustomProperties ModelVersionId Runtime DesiredState
	OverrideNotEditableForInferenceService(source OpenapiUpdateWrapper[openapi.InferenceService]) (openapi.InferenceService, error)

	// Ignore all fields that ARE editable
	// goverter:default InitServeModelWithUpdate
	// goverter:autoMap Existing
	// goverter:ignore Id CreateTimeSinceEpoch LastUpdateTimeSinceEpoch Description ExternalId CustomProperties LastKnownState
	OverrideNotEditableForServeModel(source OpenapiUpdateWrapper[openapi.ServeModel]) (openapi.ServeModel, error)
}

goverter:converter goverter:output:file ./generated/openapi_converter.gen.go goverter:wrapErrors goverter:matchIgnoreCase goverter:useZeroValueOnPointerInconsistency

type OpenAPIModelWrapper

type OpenAPIModelWrapper[
	M OpenAPIModel,
] struct {
	TypeId           int64
	Model            *M
	ParentResourceId *string // optional parent id
	ModelName        *string // optional registered model name
}

type OpenAPIToMLMDConverter

type OpenAPIToMLMDConverter interface {
	// goverter:autoMap Model
	// goverter:map Model Type | MapRegisteredModelType
	// goverter:map Model Properties | MapRegisteredModelProperties
	// goverter:ignore state sizeCache unknownFields SystemMetadata CreateTimeSinceEpoch LastUpdateTimeSinceEpoch
	ConvertRegisteredModel(source *OpenAPIModelWrapper[openapi.RegisteredModel]) (*proto.Context, error)

	// goverter:autoMap Model
	// goverter:map . Name | MapModelVersionName
	// goverter:map Model Type | MapModelVersionType
	// goverter:map . Properties | MapModelVersionProperties
	// goverter:ignore state sizeCache unknownFields SystemMetadata CreateTimeSinceEpoch LastUpdateTimeSinceEpoch
	ConvertModelVersion(source *OpenAPIModelWrapper[openapi.ModelVersion]) (*proto.Context, error)

	// goverter:autoMap Model
	// goverter:map . Name | MapModelArtifactName
	// goverter:map Model Type | MapModelArtifactType
	// goverter:map Model Properties | MapModelArtifactProperties
	// goverter:map Model.State State | MapOpenAPIArtifactState
	// goverter:ignore state sizeCache unknownFields SystemMetadata CreateTimeSinceEpoch LastUpdateTimeSinceEpoch
	ConvertModelArtifact(source *OpenAPIModelWrapper[openapi.ModelArtifact]) (*proto.Artifact, error)

	// goverter:autoMap Model
	// goverter:map . Name | MapDocArtifactName
	// goverter:map Model Type | MapDocArtifactType
	// goverter:map Model Properties | MapDocArtifactProperties
	// goverter:map Model.State State | MapOpenAPIArtifactState
	// goverter:ignore state sizeCache unknownFields SystemMetadata CreateTimeSinceEpoch LastUpdateTimeSinceEpoch
	ConvertDocArtifact(source *OpenAPIModelWrapper[openapi.DocArtifact]) (*proto.Artifact, error)

	// goverter:autoMap Model
	// goverter:map Model Type | MapServingEnvironmentType
	// goverter:map Model Properties | MapServingEnvironmentProperties
	// goverter:ignore state sizeCache unknownFields SystemMetadata CreateTimeSinceEpoch LastUpdateTimeSinceEpoch
	ConvertServingEnvironment(source *OpenAPIModelWrapper[openapi.ServingEnvironment]) (*proto.Context, error)

	// goverter:autoMap Model
	// goverter:map . Name | MapInferenceServiceName
	// goverter:map Model Type | MapInferenceServiceType
	// goverter:map Model Properties | MapInferenceServiceProperties
	// goverter:ignore state sizeCache unknownFields SystemMetadata CreateTimeSinceEpoch LastUpdateTimeSinceEpoch
	ConvertInferenceService(source *OpenAPIModelWrapper[openapi.InferenceService]) (*proto.Context, error)

	// goverter:autoMap Model
	// goverter:map . Name | MapServeModelName
	// goverter:map Model Type | MapServeModelType
	// goverter:map Model Properties | MapServeModelProperties
	// goverter:map Model.LastKnownState LastKnownState | MapLastKnownState
	// goverter:ignore state sizeCache unknownFields SystemMetadata CreateTimeSinceEpoch LastUpdateTimeSinceEpoch
	ConvertServeModel(source *OpenAPIModelWrapper[openapi.ServeModel]) (*proto.Execution, error)
}

goverter:converter goverter:output:file ./generated/openapi_mlmd_converter.gen.go goverter:wrapErrors goverter:matchIgnoreCase goverter:useZeroValueOnPointerInconsistency goverter:extend Int64ToString goverter:extend StringToInt64 goverter:extend MapOpenAPICustomProperties

type OpenapiUpdateWrapper

type OpenapiUpdateWrapper[
	M OpenAPIModel,
] struct {
	Existing *M
	Update   *M
}

func NewOpenapiUpdateWrapper

func NewOpenapiUpdateWrapper[
	M OpenAPIModel,
](existing *M, update *M) OpenapiUpdateWrapper[M]

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL