Skip to content

Commit

Permalink
feat: add support for trainingoperator to component
Browse files Browse the repository at this point in the history
Signed-off-by: Wen Zhou <wenzhou@redhat.com>
  • Loading branch information
zdtsw committed Nov 5, 2024
1 parent c8df75f commit 53cc7cb
Show file tree
Hide file tree
Showing 23 changed files with 664 additions and 251 deletions.
54 changes: 34 additions & 20 deletions apis/components/v1/trainingoperator_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,21 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// TrainingOperatorSpec defines the desired state of TrainingOperator
type TrainingOperatorSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
const (
TrainingOperatorComponentName = "trainingoperator"
// value should match whats set in the XValidation below
TrainingOperatorInstanceName = "default-trainingoperator"
TrainingOperatorKind = "TrainingOperator"
)

// Foo is an example field of TrainingOperator. Edit trainingoperator_types.go to remove/update
Foo string `json:"foo,omitempty"`
}

// TrainingOperatorStatus defines the observed state of TrainingOperator
type TrainingOperatorStatus struct {
components.Status `json:",inline"`
}
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster
// +kubebuilder:validation:XValidation:rule="self.metadata.name == 'default-trainingoperator'",message="TrainingOperator name must be default-trainingoperator"
// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status`,description="Ready"
// +kubebuilder:printcolumn:name="Reason",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].reason`,description="Reason"

// TrainingOperator is the Schema for the trainingoperators API
type TrainingOperator struct {
Expand All @@ -51,16 +46,21 @@ type TrainingOperator struct {
Status TrainingOperatorStatus `json:"status,omitempty"`
}

func (c *TrainingOperator) GetDevFlags() *components.DevFlags {
return nil
// TrainingOperatorSpec defines the desired state of TrainingOperator
type TrainingOperatorSpec struct {
TrainingOperatorCommonSpec `json:",inline"`
}

func (c *TrainingOperator) GetStatus() *components.Status {
return &c.Status.Status
type TrainingOperatorCommonSpec struct {
components.DevFlagsSpec `json:",inline"`
}

// +kubebuilder:object:root=true
// TrainingOperatorStatus defines the observed state of TrainingOperator
type TrainingOperatorStatus struct {
components.Status `json:",inline"`
}

// +kubebuilder:object:root=true
// TrainingOperatorList contains a list of TrainingOperator
type TrainingOperatorList struct {
metav1.TypeMeta `json:",inline"`
Expand All @@ -71,3 +71,17 @@ type TrainingOperatorList struct {
func init() {
SchemeBuilder.Register(&TrainingOperator{}, &TrainingOperatorList{})
}

func (c *TrainingOperator) GetDevFlags() *components.DevFlags {
return c.Spec.DevFlags
}
func (c *TrainingOperator) GetStatus() *components.Status {
return &c.Status.Status
}

// DSCTrainingOperator contains all the configuration exposed in DSC instance for TrainingOperator component
type DSCTrainingOperator struct {
components.ManagementSpec `json:",inline"`
// configuration fields common across components
TrainingOperatorCommonSpec `json:",inline"`
}
36 changes: 35 additions & 1 deletion apis/components/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions apis/datasciencecluster/v1/datasciencecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"github.com/opendatahub-io/opendatahub-operator/v2/components/kserve"
"github.com/opendatahub-io/opendatahub-operator/v2/components/kueue"
"github.com/opendatahub-io/opendatahub-operator/v2/components/modelmeshserving"
"github.com/opendatahub-io/opendatahub-operator/v2/components/trainingoperator"
"github.com/opendatahub-io/opendatahub-operator/v2/components/trustyai"
"github.com/opendatahub-io/opendatahub-operator/v2/components/workbenches"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster"
Expand Down Expand Up @@ -81,7 +80,7 @@ type Components struct {
ModelRegistry componentsv1.DSCModelRegistry `json:"modelregistry,omitempty"`

// Training Operator component configuration.
TrainingOperator trainingoperator.TrainingOperator `json:"trainingoperator,omitempty"`
TrainingOperator componentsv1.DSCTrainingOperator `json:"trainingoperator,omitempty"`
}

// ComponentsStatus defines the custom status of DataScienceCluster components.
Expand Down
44 changes: 39 additions & 5 deletions bundle/manifests/components.opendatahub.io_trainingoperators.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@ spec:
singular: trainingoperator
scope: Cluster
versions:
- name: v1
- additionalPrinterColumns:
- description: Ready
jsonPath: .status.conditions[?(@.type=="Ready")].status
name: Ready
type: string
- description: Reason
jsonPath: .status.conditions[?(@.type=="Ready")].reason
name: Reason
type: string
name: v1
schema:
openAPIV3Schema:
description: TrainingOperator is the Schema for the trainingoperators API
Expand All @@ -39,10 +48,32 @@ spec:
spec:
description: TrainingOperatorSpec defines the desired state of TrainingOperator
properties:
foo:
description: Foo is an example field of TrainingOperator. Edit trainingoperator_types.go
to remove/update
type: string
devFlags:
description: Add developer fields
properties:
manifests:
description: List of custom manifests for the given component
items:
properties:
contextDir:
default: manifests
description: contextDir is the relative path to the folder
containing manifests in a repository, default value "manifests"
type: string
sourcePath:
default: ""
description: 'sourcePath is the subpath within contextDir
where kustomize builds start. Examples include any sub-folder
or path: `base`, `overlays/dev`, `default`, `odh` etc.'
type: string
uri:
default: ""
description: uri is the URI point to a git repo with tag/branch.
e.g. https://github.com/org/repo/tarball/<tag/branch>
type: string
type: object
type: array
type: object
type: object
status:
description: TrainingOperatorStatus defines the observed state of TrainingOperator
Expand Down Expand Up @@ -110,6 +141,9 @@ spec:
type: string
type: object
type: object
x-kubernetes-validations:
- message: TrainingOperator name must be default-trainingoperator
rule: self.metadata.name == 'default-trainingoperator'
served: true
storage: true
subresources:
Expand Down
113 changes: 0 additions & 113 deletions components/trainingoperator/trainingoperator.go

This file was deleted.

39 changes: 0 additions & 39 deletions components/trainingoperator/zz_generated.deepcopy.go

This file was deleted.

Loading

0 comments on commit 53cc7cb

Please sign in to comment.