diff --git a/.github/workflows/merlin.yml b/.github/workflows/merlin.yml index f1668f2d1..cf67e6c7d 100644 --- a/.github/workflows/merlin.yml +++ b/.github/workflows/merlin.yml @@ -156,6 +156,23 @@ jobs: version: v1.58.1 working-directory: api + check-generated-clients: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + cache-dependency-path: api/go.sum + - name: Install codegen tools + # generate-client-go calls goimports, installed by `make setup` into + # $(go env GOPATH)/bin, which must be on PATH for the bare goimports call. + run: | + make setup + echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH" + - name: Verify generated clients are in sync with swagger.yaml + run: make verify-client + test-api: runs-on: ubuntu-latest services: @@ -493,6 +510,7 @@ jobs: uses: ./.github/workflows/release.yml needs: - create-version + - check-generated-clients - build-api - build-batch-predictor-base-image - build-pyfunc-server-base-image diff --git a/Makefile b/Makefile index ed05231a5..28d5b64d1 100644 --- a/Makefile +++ b/Makefile @@ -197,7 +197,7 @@ generate-client-go: @echo "Generating Go client from swagger.yaml" @mv ${CLIENT_GO_EXAMPLES_DIR} ${TEMP_CLIENT_GO_EXAMPLES_DIR} @rm -rf ${CLIENT_GO_OUTPUT_DIR} - @docker run --rm -v ${PWD}/:/local openapitools/openapi-generator-cli:v7.1.0 generate \ + @docker run --rm -u "$$(id -u):$$(id -g)" -v ${PWD}/:/local openapitools/openapi-generator-cli:v7.1.0 generate \ --input-spec /local/swagger.yaml \ --generator-name go \ --output /local/api/client_tmp/. \ @@ -215,13 +215,35 @@ TEMP_CLIENT_PYTHON_OUTPUT_DIR = ./python/sdk/client_tmp .PHONY: generate-client-python generate-client-python: rm -rf ${CLIENT_PYTHON_OUTPUT_DIR} - @docker run --rm -v ${PWD}/:/local openapitools/openapi-generator-cli:v7.1.0 generate \ + @docker run --rm -u "$$(id -u):$$(id -g)" -v ${PWD}/:/local openapitools/openapi-generator-cli:v7.1.0 generate \ --input-spec /local/swagger.yaml \ --generator-name python \ --output /local/python/sdk/. \ --config /local/openapi-sdk-codegen.yaml +# Generated OpenAPI client paths checked for drift against swagger.yaml. +# Scoped to the client directories so the untracked python/sdk/.openapi-generator/ +# manifest (a sibling of client/, dropped by the generator) cannot false-positive. +GENERATED_CLIENT_PATHS = api/client python/sdk/client python/sdk/client_README.md +.PHONY: verify-client +verify-client: generate-client + @echo "Verifying generated OpenAPI clients are in sync with swagger.yaml ..." + @drift="$$(git status --porcelain -- ${GENERATED_CLIENT_PATHS})"; \ + if [ -n "$$drift" ]; then \ + echo ""; \ + echo "ERROR: generated OpenAPI clients are out of sync with swagger.yaml."; \ + echo "The following generated files differ from what is committed:"; \ + echo "$$drift"; \ + echo ""; \ + git --no-pager diff -- ${GENERATED_CLIENT_PATHS}; \ + echo ""; \ + echo "Run 'make generate-client' and commit the regenerated clients."; \ + exit 1; \ + fi; \ + echo "Generated OpenAPI clients are in sync with swagger.yaml." + + .PHONY: generate-proto generate-proto: @echo "> Generating specification configuration from Proto file..." diff --git a/api/client/model_prediction_job_config.go b/api/client/model_prediction_job_config.go index 6f715e31e..6518b0928 100644 --- a/api/client/model_prediction_job_config.go +++ b/api/client/model_prediction_job_config.go @@ -19,14 +19,16 @@ var _ MappedNullable = &PredictionJobConfig{} // PredictionJobConfig struct for PredictionJobConfig type PredictionJobConfig struct { - Version *string `json:"version,omitempty"` - Kind *string `json:"kind,omitempty"` - Name *string `json:"name,omitempty"` - BigquerySource *PredictionJobConfigBigquerySource `json:"bigquery_source,omitempty"` - GcsSource *PredictionJobConfigGcsSource `json:"gcs_source,omitempty"` - Model *PredictionJobConfigModel `json:"model,omitempty"` - BigquerySink *PredictionJobConfigBigquerySink `json:"bigquery_sink,omitempty"` - GcsSink *PredictionJobConfigGcsSink `json:"gcs_sink,omitempty"` + Version *string `json:"version,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + BigquerySource *PredictionJobConfigBigquerySource `json:"bigquery_source,omitempty"` + GcsSource *PredictionJobConfigGcsSource `json:"gcs_source,omitempty"` + MaxcomputeSource *PredictionJobConfigMaxcomputeSource `json:"maxcompute_source,omitempty"` + Model *PredictionJobConfigModel `json:"model,omitempty"` + BigquerySink *PredictionJobConfigBigquerySink `json:"bigquery_sink,omitempty"` + GcsSink *PredictionJobConfigGcsSink `json:"gcs_sink,omitempty"` + MaxcomputeSink *PredictionJobConfigMaxcomputeSink `json:"maxcompute_sink,omitempty"` } // NewPredictionJobConfig instantiates a new PredictionJobConfig object @@ -206,6 +208,38 @@ func (o *PredictionJobConfig) SetGcsSource(v PredictionJobConfigGcsSource) { o.GcsSource = &v } +// GetMaxcomputeSource returns the MaxcomputeSource field value if set, zero value otherwise. +func (o *PredictionJobConfig) GetMaxcomputeSource() PredictionJobConfigMaxcomputeSource { + if o == nil || IsNil(o.MaxcomputeSource) { + var ret PredictionJobConfigMaxcomputeSource + return ret + } + return *o.MaxcomputeSource +} + +// GetMaxcomputeSourceOk returns a tuple with the MaxcomputeSource field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PredictionJobConfig) GetMaxcomputeSourceOk() (*PredictionJobConfigMaxcomputeSource, bool) { + if o == nil || IsNil(o.MaxcomputeSource) { + return nil, false + } + return o.MaxcomputeSource, true +} + +// HasMaxcomputeSource returns a boolean if a field has been set. +func (o *PredictionJobConfig) HasMaxcomputeSource() bool { + if o != nil && !IsNil(o.MaxcomputeSource) { + return true + } + + return false +} + +// SetMaxcomputeSource gets a reference to the given PredictionJobConfigMaxcomputeSource and assigns it to the MaxcomputeSource field. +func (o *PredictionJobConfig) SetMaxcomputeSource(v PredictionJobConfigMaxcomputeSource) { + o.MaxcomputeSource = &v +} + // GetModel returns the Model field value if set, zero value otherwise. func (o *PredictionJobConfig) GetModel() PredictionJobConfigModel { if o == nil || IsNil(o.Model) { @@ -302,6 +336,38 @@ func (o *PredictionJobConfig) SetGcsSink(v PredictionJobConfigGcsSink) { o.GcsSink = &v } +// GetMaxcomputeSink returns the MaxcomputeSink field value if set, zero value otherwise. +func (o *PredictionJobConfig) GetMaxcomputeSink() PredictionJobConfigMaxcomputeSink { + if o == nil || IsNil(o.MaxcomputeSink) { + var ret PredictionJobConfigMaxcomputeSink + return ret + } + return *o.MaxcomputeSink +} + +// GetMaxcomputeSinkOk returns a tuple with the MaxcomputeSink field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PredictionJobConfig) GetMaxcomputeSinkOk() (*PredictionJobConfigMaxcomputeSink, bool) { + if o == nil || IsNil(o.MaxcomputeSink) { + return nil, false + } + return o.MaxcomputeSink, true +} + +// HasMaxcomputeSink returns a boolean if a field has been set. +func (o *PredictionJobConfig) HasMaxcomputeSink() bool { + if o != nil && !IsNil(o.MaxcomputeSink) { + return true + } + + return false +} + +// SetMaxcomputeSink gets a reference to the given PredictionJobConfigMaxcomputeSink and assigns it to the MaxcomputeSink field. +func (o *PredictionJobConfig) SetMaxcomputeSink(v PredictionJobConfigMaxcomputeSink) { + o.MaxcomputeSink = &v +} + func (o PredictionJobConfig) MarshalJSON() ([]byte, error) { toSerialize, err := o.ToMap() if err != nil { @@ -327,6 +393,9 @@ func (o PredictionJobConfig) ToMap() (map[string]interface{}, error) { if !IsNil(o.GcsSource) { toSerialize["gcs_source"] = o.GcsSource } + if !IsNil(o.MaxcomputeSource) { + toSerialize["maxcompute_source"] = o.MaxcomputeSource + } if !IsNil(o.Model) { toSerialize["model"] = o.Model } @@ -336,6 +405,9 @@ func (o PredictionJobConfig) ToMap() (map[string]interface{}, error) { if !IsNil(o.GcsSink) { toSerialize["gcs_sink"] = o.GcsSink } + if !IsNil(o.MaxcomputeSink) { + toSerialize["maxcompute_sink"] = o.MaxcomputeSink + } return toSerialize, nil } diff --git a/api/client/model_probe_config.go b/api/client/model_probe_config.go new file mode 100644 index 000000000..76046df13 --- /dev/null +++ b/api/client/model_probe_config.go @@ -0,0 +1,384 @@ +/* +Merlin + +API Guide for accessing Merlin's model management, deployment, and serving functionalities + +API version: 0.14.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package client + +import ( + "encoding/json" +) + +// checks if the ProbeConfig type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ProbeConfig{} + +// ProbeConfig struct for ProbeConfig +type ProbeConfig struct { + // Path for HTTP probe + Path *string `json:"path,omitempty"` + // Port for the probe + Port *int32 `json:"port,omitempty"` + // Scheme for HTTP probe (HTTP or HTTPS) + Scheme *string `json:"scheme,omitempty"` + // Initial delay before starting the probe (seconds) + InitialDelaySeconds *int32 `json:"initial_delay_seconds,omitempty"` + // Timeout for the probe (seconds) + TimeoutSeconds *int32 `json:"timeout_seconds,omitempty"` + // Period between probe checks (seconds) + PeriodSeconds *int32 `json:"period_seconds,omitempty"` + // Number of successes required to be considered healthy + SuccessThreshold *int32 `json:"success_threshold,omitempty"` + // Number of failures before considered unhealthy + FailureThreshold *int32 `json:"failure_threshold,omitempty"` +} + +// NewProbeConfig instantiates a new ProbeConfig 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 NewProbeConfig() *ProbeConfig { + this := ProbeConfig{} + return &this +} + +// NewProbeConfigWithDefaults instantiates a new ProbeConfig object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewProbeConfigWithDefaults() *ProbeConfig { + this := ProbeConfig{} + return &this +} + +// GetPath returns the Path field value if set, zero value otherwise. +func (o *ProbeConfig) GetPath() string { + if o == nil || IsNil(o.Path) { + var ret string + return ret + } + return *o.Path +} + +// GetPathOk returns a tuple with the Path field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ProbeConfig) GetPathOk() (*string, bool) { + if o == nil || IsNil(o.Path) { + return nil, false + } + return o.Path, true +} + +// HasPath returns a boolean if a field has been set. +func (o *ProbeConfig) HasPath() bool { + if o != nil && !IsNil(o.Path) { + return true + } + + return false +} + +// SetPath gets a reference to the given string and assigns it to the Path field. +func (o *ProbeConfig) SetPath(v string) { + o.Path = &v +} + +// GetPort returns the Port field value if set, zero value otherwise. +func (o *ProbeConfig) GetPort() int32 { + if o == nil || IsNil(o.Port) { + var ret int32 + return ret + } + return *o.Port +} + +// GetPortOk returns a tuple with the Port field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ProbeConfig) GetPortOk() (*int32, bool) { + if o == nil || IsNil(o.Port) { + return nil, false + } + return o.Port, true +} + +// HasPort returns a boolean if a field has been set. +func (o *ProbeConfig) HasPort() bool { + if o != nil && !IsNil(o.Port) { + return true + } + + return false +} + +// SetPort gets a reference to the given int32 and assigns it to the Port field. +func (o *ProbeConfig) SetPort(v int32) { + o.Port = &v +} + +// GetScheme returns the Scheme field value if set, zero value otherwise. +func (o *ProbeConfig) GetScheme() string { + if o == nil || IsNil(o.Scheme) { + var ret string + return ret + } + return *o.Scheme +} + +// GetSchemeOk returns a tuple with the Scheme field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ProbeConfig) GetSchemeOk() (*string, bool) { + if o == nil || IsNil(o.Scheme) { + return nil, false + } + return o.Scheme, true +} + +// HasScheme returns a boolean if a field has been set. +func (o *ProbeConfig) HasScheme() bool { + if o != nil && !IsNil(o.Scheme) { + return true + } + + return false +} + +// SetScheme gets a reference to the given string and assigns it to the Scheme field. +func (o *ProbeConfig) SetScheme(v string) { + o.Scheme = &v +} + +// GetInitialDelaySeconds returns the InitialDelaySeconds field value if set, zero value otherwise. +func (o *ProbeConfig) GetInitialDelaySeconds() int32 { + if o == nil || IsNil(o.InitialDelaySeconds) { + var ret int32 + return ret + } + return *o.InitialDelaySeconds +} + +// GetInitialDelaySecondsOk returns a tuple with the InitialDelaySeconds field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ProbeConfig) GetInitialDelaySecondsOk() (*int32, bool) { + if o == nil || IsNil(o.InitialDelaySeconds) { + return nil, false + } + return o.InitialDelaySeconds, true +} + +// HasInitialDelaySeconds returns a boolean if a field has been set. +func (o *ProbeConfig) HasInitialDelaySeconds() bool { + if o != nil && !IsNil(o.InitialDelaySeconds) { + return true + } + + return false +} + +// SetInitialDelaySeconds gets a reference to the given int32 and assigns it to the InitialDelaySeconds field. +func (o *ProbeConfig) SetInitialDelaySeconds(v int32) { + o.InitialDelaySeconds = &v +} + +// GetTimeoutSeconds returns the TimeoutSeconds field value if set, zero value otherwise. +func (o *ProbeConfig) GetTimeoutSeconds() int32 { + if o == nil || IsNil(o.TimeoutSeconds) { + var ret int32 + return ret + } + return *o.TimeoutSeconds +} + +// GetTimeoutSecondsOk returns a tuple with the TimeoutSeconds field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ProbeConfig) GetTimeoutSecondsOk() (*int32, bool) { + if o == nil || IsNil(o.TimeoutSeconds) { + return nil, false + } + return o.TimeoutSeconds, true +} + +// HasTimeoutSeconds returns a boolean if a field has been set. +func (o *ProbeConfig) HasTimeoutSeconds() bool { + if o != nil && !IsNil(o.TimeoutSeconds) { + return true + } + + return false +} + +// SetTimeoutSeconds gets a reference to the given int32 and assigns it to the TimeoutSeconds field. +func (o *ProbeConfig) SetTimeoutSeconds(v int32) { + o.TimeoutSeconds = &v +} + +// GetPeriodSeconds returns the PeriodSeconds field value if set, zero value otherwise. +func (o *ProbeConfig) GetPeriodSeconds() int32 { + if o == nil || IsNil(o.PeriodSeconds) { + var ret int32 + return ret + } + return *o.PeriodSeconds +} + +// GetPeriodSecondsOk returns a tuple with the PeriodSeconds field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ProbeConfig) GetPeriodSecondsOk() (*int32, bool) { + if o == nil || IsNil(o.PeriodSeconds) { + return nil, false + } + return o.PeriodSeconds, true +} + +// HasPeriodSeconds returns a boolean if a field has been set. +func (o *ProbeConfig) HasPeriodSeconds() bool { + if o != nil && !IsNil(o.PeriodSeconds) { + return true + } + + return false +} + +// SetPeriodSeconds gets a reference to the given int32 and assigns it to the PeriodSeconds field. +func (o *ProbeConfig) SetPeriodSeconds(v int32) { + o.PeriodSeconds = &v +} + +// GetSuccessThreshold returns the SuccessThreshold field value if set, zero value otherwise. +func (o *ProbeConfig) GetSuccessThreshold() int32 { + if o == nil || IsNil(o.SuccessThreshold) { + var ret int32 + return ret + } + return *o.SuccessThreshold +} + +// GetSuccessThresholdOk returns a tuple with the SuccessThreshold field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ProbeConfig) GetSuccessThresholdOk() (*int32, bool) { + if o == nil || IsNil(o.SuccessThreshold) { + return nil, false + } + return o.SuccessThreshold, true +} + +// HasSuccessThreshold returns a boolean if a field has been set. +func (o *ProbeConfig) HasSuccessThreshold() bool { + if o != nil && !IsNil(o.SuccessThreshold) { + return true + } + + return false +} + +// SetSuccessThreshold gets a reference to the given int32 and assigns it to the SuccessThreshold field. +func (o *ProbeConfig) SetSuccessThreshold(v int32) { + o.SuccessThreshold = &v +} + +// GetFailureThreshold returns the FailureThreshold field value if set, zero value otherwise. +func (o *ProbeConfig) GetFailureThreshold() int32 { + if o == nil || IsNil(o.FailureThreshold) { + var ret int32 + return ret + } + return *o.FailureThreshold +} + +// GetFailureThresholdOk returns a tuple with the FailureThreshold field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ProbeConfig) GetFailureThresholdOk() (*int32, bool) { + if o == nil || IsNil(o.FailureThreshold) { + return nil, false + } + return o.FailureThreshold, true +} + +// HasFailureThreshold returns a boolean if a field has been set. +func (o *ProbeConfig) HasFailureThreshold() bool { + if o != nil && !IsNil(o.FailureThreshold) { + return true + } + + return false +} + +// SetFailureThreshold gets a reference to the given int32 and assigns it to the FailureThreshold field. +func (o *ProbeConfig) SetFailureThreshold(v int32) { + o.FailureThreshold = &v +} + +func (o ProbeConfig) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o ProbeConfig) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Path) { + toSerialize["path"] = o.Path + } + if !IsNil(o.Port) { + toSerialize["port"] = o.Port + } + if !IsNil(o.Scheme) { + toSerialize["scheme"] = o.Scheme + } + if !IsNil(o.InitialDelaySeconds) { + toSerialize["initial_delay_seconds"] = o.InitialDelaySeconds + } + if !IsNil(o.TimeoutSeconds) { + toSerialize["timeout_seconds"] = o.TimeoutSeconds + } + if !IsNil(o.PeriodSeconds) { + toSerialize["period_seconds"] = o.PeriodSeconds + } + if !IsNil(o.SuccessThreshold) { + toSerialize["success_threshold"] = o.SuccessThreshold + } + if !IsNil(o.FailureThreshold) { + toSerialize["failure_threshold"] = o.FailureThreshold + } + return toSerialize, nil +} + +type NullableProbeConfig struct { + value *ProbeConfig + isSet bool +} + +func (v NullableProbeConfig) Get() *ProbeConfig { + return v.value +} + +func (v *NullableProbeConfig) Set(val *ProbeConfig) { + v.value = val + v.isSet = true +} + +func (v NullableProbeConfig) IsSet() bool { + return v.isSet +} + +func (v *NullableProbeConfig) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableProbeConfig(val *ProbeConfig) *NullableProbeConfig { + return &NullableProbeConfig{value: val, isSet: true} +} + +func (v NullableProbeConfig) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableProbeConfig) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/api/client/model_resource_request.go b/api/client/model_resource_request.go index ccd65559a..3a646cd4a 100644 --- a/api/client/model_resource_request.go +++ b/api/client/model_resource_request.go @@ -19,13 +19,15 @@ var _ MappedNullable = &ResourceRequest{} // ResourceRequest struct for ResourceRequest type ResourceRequest struct { - MinReplica *int32 `json:"min_replica,omitempty"` - MaxReplica *int32 `json:"max_replica,omitempty"` - CpuRequest *string `json:"cpu_request,omitempty"` - CpuLimit *string `json:"cpu_limit,omitempty"` - MemoryRequest *string `json:"memory_request,omitempty"` - GpuName *string `json:"gpu_name,omitempty"` - GpuRequest *string `json:"gpu_request,omitempty"` + MinReplica *int32 `json:"min_replica,omitempty"` + MaxReplica *int32 `json:"max_replica,omitempty"` + CpuRequest *string `json:"cpu_request,omitempty"` + CpuLimit *string `json:"cpu_limit,omitempty"` + MemoryRequest *string `json:"memory_request,omitempty"` + GpuName *string `json:"gpu_name,omitempty"` + GpuRequest *string `json:"gpu_request,omitempty"` + LivenessProbe *ProbeConfig `json:"liveness_probe,omitempty"` + ReadinessProbe *ProbeConfig `json:"readiness_probe,omitempty"` } // NewResourceRequest instantiates a new ResourceRequest object @@ -269,6 +271,70 @@ func (o *ResourceRequest) SetGpuRequest(v string) { o.GpuRequest = &v } +// GetLivenessProbe returns the LivenessProbe field value if set, zero value otherwise. +func (o *ResourceRequest) GetLivenessProbe() ProbeConfig { + if o == nil || IsNil(o.LivenessProbe) { + var ret ProbeConfig + return ret + } + return *o.LivenessProbe +} + +// GetLivenessProbeOk returns a tuple with the LivenessProbe field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ResourceRequest) GetLivenessProbeOk() (*ProbeConfig, bool) { + if o == nil || IsNil(o.LivenessProbe) { + return nil, false + } + return o.LivenessProbe, true +} + +// HasLivenessProbe returns a boolean if a field has been set. +func (o *ResourceRequest) HasLivenessProbe() bool { + if o != nil && !IsNil(o.LivenessProbe) { + return true + } + + return false +} + +// SetLivenessProbe gets a reference to the given ProbeConfig and assigns it to the LivenessProbe field. +func (o *ResourceRequest) SetLivenessProbe(v ProbeConfig) { + o.LivenessProbe = &v +} + +// GetReadinessProbe returns the ReadinessProbe field value if set, zero value otherwise. +func (o *ResourceRequest) GetReadinessProbe() ProbeConfig { + if o == nil || IsNil(o.ReadinessProbe) { + var ret ProbeConfig + return ret + } + return *o.ReadinessProbe +} + +// GetReadinessProbeOk returns a tuple with the ReadinessProbe field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ResourceRequest) GetReadinessProbeOk() (*ProbeConfig, bool) { + if o == nil || IsNil(o.ReadinessProbe) { + return nil, false + } + return o.ReadinessProbe, true +} + +// HasReadinessProbe returns a boolean if a field has been set. +func (o *ResourceRequest) HasReadinessProbe() bool { + if o != nil && !IsNil(o.ReadinessProbe) { + return true + } + + return false +} + +// SetReadinessProbe gets a reference to the given ProbeConfig and assigns it to the ReadinessProbe field. +func (o *ResourceRequest) SetReadinessProbe(v ProbeConfig) { + o.ReadinessProbe = &v +} + func (o ResourceRequest) MarshalJSON() ([]byte, error) { toSerialize, err := o.ToMap() if err != nil { @@ -300,6 +366,12 @@ func (o ResourceRequest) ToMap() (map[string]interface{}, error) { if !IsNil(o.GpuRequest) { toSerialize["gpu_request"] = o.GpuRequest } + if !IsNil(o.LivenessProbe) { + toSerialize["liveness_probe"] = o.LivenessProbe + } + if !IsNil(o.ReadinessProbe) { + toSerialize["readiness_probe"] = o.ReadinessProbe + } return toSerialize, nil } diff --git a/python/sdk/client/__init__.py b/python/sdk/client/__init__.py index a0bf3358e..49bed9729 100644 --- a/python/sdk/client/__init__.py +++ b/python/sdk/client/__init__.py @@ -97,6 +97,7 @@ from client.models.prediction_job_resource_request import PredictionJobResourceRequest from client.models.prediction_log_ingestion_resource_request import PredictionLogIngestionResourceRequest from client.models.prediction_logger_config import PredictionLoggerConfig +from client.models.probe_config import ProbeConfig from client.models.project import Project from client.models.protocol import Protocol from client.models.ranking_output import RankingOutput diff --git a/python/sdk/client/models/__init__.py b/python/sdk/client/models/__init__.py index 23a63b0bb..f1888a834 100644 --- a/python/sdk/client/models/__init__.py +++ b/python/sdk/client/models/__init__.py @@ -68,6 +68,7 @@ from client.models.prediction_job_resource_request import PredictionJobResourceRequest from client.models.prediction_log_ingestion_resource_request import PredictionLogIngestionResourceRequest from client.models.prediction_logger_config import PredictionLoggerConfig +from client.models.probe_config import ProbeConfig from client.models.project import Project from client.models.protocol import Protocol from client.models.ranking_output import RankingOutput diff --git a/python/sdk/client/models/probe_config.py b/python/sdk/client/models/probe_config.py new file mode 100644 index 000000000..f49a01c53 --- /dev/null +++ b/python/sdk/client/models/probe_config.py @@ -0,0 +1,102 @@ +# coding: utf-8 + +""" + Merlin + + API Guide for accessing Merlin's model management, deployment, and serving functionalities + + The version of the OpenAPI document: 0.14.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, ClassVar, Dict, List, Optional +from pydantic import BaseModel, StrictInt, StrictStr +from pydantic import Field +try: + from typing import Self +except ImportError: + from typing_extensions import Self + +class ProbeConfig(BaseModel): + """ + ProbeConfig + """ # noqa: E501 + path: Optional[StrictStr] = Field(default=None, description="Path for HTTP probe") + port: Optional[StrictInt] = Field(default=None, description="Port for the probe") + scheme: Optional[StrictStr] = Field(default=None, description="Scheme for HTTP probe (HTTP or HTTPS)") + initial_delay_seconds: Optional[StrictInt] = Field(default=None, description="Initial delay before starting the probe (seconds)") + timeout_seconds: Optional[StrictInt] = Field(default=None, description="Timeout for the probe (seconds)") + period_seconds: Optional[StrictInt] = Field(default=None, description="Period between probe checks (seconds)") + success_threshold: Optional[StrictInt] = Field(default=None, description="Number of successes required to be considered healthy") + failure_threshold: Optional[StrictInt] = Field(default=None, description="Number of failures before considered unhealthy") + __properties: ClassVar[List[str]] = ["path", "port", "scheme", "initial_delay_seconds", "timeout_seconds", "period_seconds", "success_threshold", "failure_threshold"] + + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of ProbeConfig from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + _dict = self.model_dump( + by_alias=True, + exclude={ + }, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Dict) -> Self: + """Create an instance of ProbeConfig from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "path": obj.get("path"), + "port": obj.get("port"), + "scheme": obj.get("scheme"), + "initial_delay_seconds": obj.get("initial_delay_seconds"), + "timeout_seconds": obj.get("timeout_seconds"), + "period_seconds": obj.get("period_seconds"), + "success_threshold": obj.get("success_threshold"), + "failure_threshold": obj.get("failure_threshold") + }) + return _obj + + diff --git a/python/sdk/client/models/resource_request.py b/python/sdk/client/models/resource_request.py index fc25eb77f..64bdcf4ed 100644 --- a/python/sdk/client/models/resource_request.py +++ b/python/sdk/client/models/resource_request.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictInt, StrictStr +from client.models.probe_config import ProbeConfig try: from typing import Self except ImportError: @@ -36,7 +37,9 @@ class ResourceRequest(BaseModel): memory_request: Optional[StrictStr] = None gpu_name: Optional[StrictStr] = None gpu_request: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["min_replica", "max_replica", "cpu_request", "cpu_limit", "memory_request", "gpu_name", "gpu_request"] + liveness_probe: Optional[ProbeConfig] = None + readiness_probe: Optional[ProbeConfig] = None + __properties: ClassVar[List[str]] = ["min_replica", "max_replica", "cpu_request", "cpu_limit", "memory_request", "gpu_name", "gpu_request", "liveness_probe", "readiness_probe"] model_config = { "populate_by_name": True, @@ -74,6 +77,12 @@ def to_dict(self) -> Dict[str, Any]: }, exclude_none=True, ) + # override the default output from pydantic by calling `to_dict()` of liveness_probe + if self.liveness_probe: + _dict['liveness_probe'] = self.liveness_probe.to_dict() + # override the default output from pydantic by calling `to_dict()` of readiness_probe + if self.readiness_probe: + _dict['readiness_probe'] = self.readiness_probe.to_dict() return _dict @classmethod @@ -92,7 +101,9 @@ def from_dict(cls, obj: Dict) -> Self: "cpu_limit": obj.get("cpu_limit"), "memory_request": obj.get("memory_request"), "gpu_name": obj.get("gpu_name"), - "gpu_request": obj.get("gpu_request") + "gpu_request": obj.get("gpu_request"), + "liveness_probe": ProbeConfig.from_dict(obj.get("liveness_probe")) if obj.get("liveness_probe") is not None else None, + "readiness_probe": ProbeConfig.from_dict(obj.get("readiness_probe")) if obj.get("readiness_probe") is not None else None }) return _obj