Skip to content

Commit

Permalink
feat: add rag controller
Browse files Browse the repository at this point in the history
  • Loading branch information
0xff-dev committed Jan 23, 2024
1 parent f2d642a commit d4287d5
Show file tree
Hide file tree
Showing 10 changed files with 1,153 additions and 9 deletions.
24 changes: 24 additions & 0 deletions api/evaluation/v1alpha1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,27 @@ type Parameter struct {
type Report struct {
// TODO
}

// Define RAG common structure and variables
const (
EvauateJobLabels = Group + "/rag"
)

func RagStatusChanged(a, b RAGStatus) bool {
if !a.CompletionTime.Equal(b.CompletionTime) {
return true
}
if a.Phase != b.Phase {
return true
}
ac, bc := a.Conditions, b.Conditions
la, lb := len(ac), len(bc)
if la != lb {
return true
}
if la == 0 {
return false
}
return ac[0].Type != bc[0].Type || ac[0].Status != bc[0].Status ||
ac[0].Reason != bc[0].Reason || ac[0].Message != bc[0].Message
}
62 changes: 62 additions & 0 deletions api/evaluation/v1alpha1/condition.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
Copyright 2024 KubeAGI.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type ConditionType string

// These are built-in conditions of a RAG's job.
const (
// JobComplete means the job has completed its execution.
Complete ConditionType = "Complete"
// JobFailed means the job has failed its execution.
Failed ConditionType = "Failed"
)

// JobCondition describes current state of a job.
type Condition struct {
// Type of job condition, Complete or Failed.
Type ConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=JobConditionType"`
// Status of the condition, one of True, False, Unknown.
Status corev1.ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status,casttype=k8s.io/api/core/v1.ConditionStatus"`
// Last time the condition was checked.
// +optional
LastProbeTime metav1.Time `json:"lastProbeTime,omitempty" protobuf:"bytes,3,opt,name=lastProbeTime"`
// Last time the condition transit from one status to another.
// +optional
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,4,opt,name=lastTransitionTime"`
// (brief) reason for the condition's last transition.
// +optional
Reason string `json:"reason,omitempty" protobuf:"bytes,5,opt,name=reason"`
// Human readable message indicating details about last transition.
// +optional
Message string `json:"message,omitempty" protobuf:"bytes,6,opt,name=message"`
}

type RAGPhase string

const (
InitPvcPhase RAGPhase = "init"
DownloadFilesPhase RAGPhase = "download"
GenerateTestFilesPhase RAGPhase = "generate"
JudgeLLMPhase RAGPhase = "judge"
UploadFilesPhase RAGPhase = "upload"
CompletePhase RAGPhase = "complte"

Check failure on line 61 in api/evaluation/v1alpha1/condition.go

View workflow job for this annotation

GitHub Actions / misspellings

complte ==> complete
)
7 changes: 6 additions & 1 deletion api/evaluation/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,14 @@ import (
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

const (
Group = "evaluation.arcadia.kubeagi.k8s.com.cn"
Version = "v1alpha1"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "evaluation.arcadia.kubeagi.k8s.com.cn", Version: "v1alpha1"}
GroupVersion = schema.GroupVersion{Group: Group, Version: Version}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
Expand Down
19 changes: 17 additions & 2 deletions api/evaluation/v1alpha1/rag_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

basev1alpha1 "github.com/kubeagi/arcadia/api/base/v1alpha1"
Expand Down Expand Up @@ -49,12 +50,26 @@ type RAGSpec struct {

// Report defines the evaluation report configurations
Report Report `json:"report,omitempty"`

// Storage storage must be provided and data needs to be saved throughout the evaluation phase.
Storage *corev1.PersistentVolumeClaimSpec `json:"storage"`

// ServiceAccountName define the user when the job is run
// +kubebuilder:default=default
ServiceAccountName string `json:"serviceAccountName,omitempty"`
}

// RAGStatus defines the observed state of RAG
type RAGStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
// CompletionTime Evaluation completion time
CompletionTime *metav1.Time `json:"completionTime,omitempty"`

// Phase evaluation current stage,
// Init,Donwload,Generate,Judge,Upload,Complete

Check failure on line 68 in api/evaluation/v1alpha1/rag_types.go

View workflow job for this annotation

GitHub Actions / misspellings

Donwload ==> Download
Phase RAGPhase `json:"phase,omitempty"`

// Conditions show the status of the job in the current stage
Conditions []Condition `json:"conditions,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
36 changes: 35 additions & 1 deletion api/evaluation/v1alpha1/zz_generated.deepcopy.go

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

Loading

0 comments on commit d4287d5

Please sign in to comment.