Skip to content

Commit

Permalink
Merge pull request #624 from 0xff-dev/rag-crd
Browse files Browse the repository at this point in the history
feat: add rag custom resource definition
  • Loading branch information
bjwswang authored Jan 24, 2024
2 parents 7dccf04 + ac9e121 commit fbc6952
Show file tree
Hide file tree
Showing 8 changed files with 552 additions and 5 deletions.
25 changes: 25 additions & 0 deletions api/evaluation/v1alpha1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,28 @@ type Parameter struct {
type Report struct {
// TODO
}

// Define RAG common structure and variables
const (
EvaluationJobLabels = Group + "/rag"
EvaluationApplicationLabel = Group + "/application"
)

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
}
27 changes: 27 additions & 0 deletions api/evaluation/v1alpha1/condition.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
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

type RAGPhase string

const (
InitPvcPhase RAGPhase = "init"
DownloadFilesPhase RAGPhase = "download"
GenerateTestFilesPhase RAGPhase = "generate"
JudgeLLMPhase RAGPhase = "judge"
UploadFilesPhase RAGPhase = "upload"
CompletePhase RAGPhase = "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
27 changes: 25 additions & 2 deletions api/evaluation/v1alpha1/rag_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package v1alpha1

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

basev1alpha1 "github.com/kubeagi/arcadia/api/base/v1alpha1"
Expand All @@ -35,6 +37,9 @@ type Dataset struct {

// RAGSpec defines the desired state of RAG
type RAGSpec struct {
// CommonSpec
basev1alpha1.CommonSpec `json:",inline"`

// Application(required) defines the target of this RAG evaluation
Application *basev1alpha1.TypedObjectReference `json:"application"`

Expand All @@ -49,12 +54,30 @@ 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"`

// Suspend suspension of the evaluation process
// +kubebuilder:default=false
Suspend bool `json:"suspend,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,download,generate,judge,upload,complete
Phase RAGPhase `json:"phase,omitempty"`

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

//+kubebuilder:object:root=true
Expand Down
21 changes: 20 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 fbc6952

Please sign in to comment.