Skip to content

Commit

Permalink
feat: graphql add api to create rag
Browse files Browse the repository at this point in the history
  • Loading branch information
0xff-dev committed Jan 29, 2024
1 parent 5438d1a commit 2d22e20
Show file tree
Hide file tree
Showing 9 changed files with 741 additions and 60 deletions.
32 changes: 32 additions & 0 deletions api/evaluation/v1alpha1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ limitations under the License.

package v1alpha1

import (
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
)

type MetricsKind string

const (
Expand Down Expand Up @@ -102,3 +107,30 @@ func RagStatusChanged(a, b RAGStatus) bool {
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
}

const (
ING = "ing" // evaluating
COMPLETE = "complete"
FAILED = "failed"
SUSPEND = "suspend"
)

func RagStatus(rag *RAG) (string, RAGPhase, string) {
phase := rag.Status.Phase
status, phaseMsg := ING, ""

if len(rag.Status.Conditions) > 0 {
cond := rag.Status.Conditions[0]
phaseMsg = rag.Status.Conditions[0].Message
if phase == CompletePhase && cond.Type == batchv1.JobComplete && cond.Status == corev1.ConditionTrue {
status = COMPLETE
}
if cond.Type == batchv1.JobFailed && cond.Status == corev1.ConditionTrue {
status = FAILED
}
}
if rag.Spec.Suspend {
status = SUSPEND
}
return status, phase, phaseMsg
}
101 changes: 59 additions & 42 deletions apiserver/graph/generated/generated.go

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

10 changes: 8 additions & 2 deletions apiserver/graph/generated/models_gen.go

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

Loading

0 comments on commit 2d22e20

Please sign in to comment.