-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #180 from kubeagi/bjwswang
feat: add crd Model and define crd Worker
- Loading branch information
Showing
36 changed files
with
1,458 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
Copyright 2023 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 "fmt" | ||
|
||
const ( | ||
// LabelModelType keeps the spec.type field | ||
LabelModelType = Group + "/model-type" | ||
LabelModelFullPath = Group + "/full-path" | ||
) | ||
|
||
type ModelType string | ||
|
||
const ( | ||
ModelTypeEmbedding ModelType = "embedding" | ||
ModelTypeLLM ModelType = "llm" | ||
ModelTypeUnknown ModelType = "unknown" | ||
) | ||
|
||
func (model Model) ModelType() ModelType { | ||
if model.Spec.Type == "" { | ||
return ModelTypeUnknown | ||
} | ||
return model.Spec.Type | ||
} | ||
|
||
// FullPath with bucket and object path | ||
func (model Model) FullPath() string { | ||
return fmt.Sprintf("%s/%s", model.Namespace, model.ObjectPath()) | ||
} | ||
|
||
// ObjectPath is the path where model stored at in a bucket | ||
func (model Model) ObjectPath() string { | ||
return fmt.Sprintf("model/%s/", model.Name) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
Copyright 2023 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 ( | ||
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. | ||
|
||
// ModelSpec defines the desired state of Model | ||
type ModelSpec struct { | ||
// Creator defines dataset creator(AUTO-FILLED by webhook) | ||
Creator string `json:"creator,omitempty"` | ||
|
||
// DisplayName defines dataset display name | ||
DiplayName string `json:"displayName"` | ||
|
||
// Description defines datasource description | ||
Description string `json:"description,omitempty"` | ||
|
||
// Type defines what kind of model this is | ||
Type ModelType `json:"type,omitempty"` | ||
|
||
// TODO: extend model to utilize third party storage sources | ||
// Source *TypedObjectReference `json:"source,omitempty"` | ||
// // Path(relative to source) to the model files | ||
// Path string `json:"path,omitempty"` | ||
} | ||
|
||
// ModelStatus defines the observed state of Model | ||
type ModelStatus struct { | ||
// ConditionedStatus is the current status | ||
ConditionedStatus `json:",inline"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
//+kubebuilder:subresource:status | ||
|
||
// Model is the Schema for the models API | ||
type Model struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec ModelSpec `json:"spec,omitempty"` | ||
Status ModelStatus `json:"status,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
|
||
// ModelList contains a list of Model | ||
type ModelList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []Model `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&Model{}, &ModelList{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
Copyright 2023 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 ( | ||
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. | ||
|
||
// WorkerSpec defines the desired state of Worker | ||
type WorkerSpec struct { | ||
// Creator defines dataset creator(AUTO-FILLED by webhook) | ||
Creator string `json:"creator,omitempty"` | ||
|
||
// DisplayName defines dataset display name | ||
DiplayName string `json:"displayName"` | ||
} | ||
|
||
// WorkerStatus defines the observed state of Worker | ||
type WorkerStatus struct { | ||
// ConditionedStatus is the current status | ||
ConditionedStatus `json:",inline"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
//+kubebuilder:subresource:status | ||
|
||
// Worker is the Schema for the workers API | ||
type Worker struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec WorkerSpec `json:"spec,omitempty"` | ||
Status WorkerStatus `json:"status,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
|
||
// WorkerList contains a list of Worker | ||
type WorkerList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []Worker `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&Worker{}, &WorkerList{}) | ||
} |
Oops, something went wrong.