/
jointinferenceservice_types.go
142 lines (116 loc) · 5 KB
/
jointinferenceservice_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*
Copyright 2021 The KubeEdge Authors.
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 (
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:resource:shortName=ji
// +kubebuilder:subresource:status
// JointInferenceService describes the data that a jointinferenceservice resource should have
type JointInferenceService struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata"`
Spec JointInferenceServiceSpec `json:"spec"`
Status JointInferenceServiceStatus `json:"status,omitempty"`
}
// JointInferenceServiceSpec is a description of a jointinferenceservice
type JointInferenceServiceSpec struct {
EdgeWorker EdgeWorker `json:"edgeWorker"`
CloudWorker CloudWorker `json:"cloudWorker"`
}
// EdgeWorker describes the data a edge worker should have
type EdgeWorker struct {
Model SmallModel `json:"model"`
HardExampleMining HardExampleMining `json:"hardExampleMining"`
Template v1.PodTemplateSpec `json:"template"`
}
// CloudWorker describes the data a cloud worker should have
type CloudWorker struct {
Model BigModel `json:"model"`
Template v1.PodTemplateSpec `json:"template"`
}
// SmallModel describes the small model
type SmallModel struct {
Name string `json:"name"`
}
// BigModel describes the big model
type BigModel struct {
Name string `json:"name"`
}
// HardExampleMining describes the hard example algorithm to be used
type HardExampleMining struct {
Name string `json:"name"`
Parameters []ParaSpec `json:"parameters,omitempty"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// JointInferenceServiceList is a list of JointInferenceServices.
type JointInferenceServiceList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []JointInferenceService `json:"items"`
}
// JointInferenceServiceStatus represents the current state of a joint inference service.
type JointInferenceServiceStatus struct {
// The latest available observations of a joint inference service's current state.
// +optional
Conditions []JointInferenceServiceCondition `json:"conditions,omitempty"`
// Represents time when the service was acknowledged by the service controller.
// It is not guaranteed to be set in happens-before order across separate operations.
// It is represented in RFC3339 form and is in UTC.
// +optional
StartTime *metav1.Time `json:"startTime,omitempty"`
// The number of actively running workers.
// +optional
Active int32 `json:"active"`
// The number of workers which reached to Failed.
// +optional
Failed int32 `json:"failed"`
// Metrics of the joint inference service.
Metrics []Metric `json:"metrics,omitempty"`
}
// JointInferenceServiceConditionType defines the condition type
type JointInferenceServiceConditionType string
// These are valid conditions of a service.
const (
// JointInferenceServiceCondPending means the service has been accepted by the system,
// but one or more of the workers has not been started.
JointInferenceServiceCondPending JointInferenceServiceConditionType = "Pending"
// JointInferenceServiceCondFailed means the service has failed its execution.
JointInferenceServiceCondFailed JointInferenceServiceConditionType = "Failed"
// JointInferenceServiceCondRunning means the service is running.
JointInferenceServiceCondRunning JointInferenceServiceConditionType = "Running"
)
// JointInferenceServiceCondition describes current state of a service.
// see https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties for details.
type JointInferenceServiceCondition struct {
// Type of service condition, Complete or Failed.
Type JointInferenceServiceConditionType `json:"type"`
// Status of the condition, one of True, False, Unknown.
Status v1.ConditionStatus `json:"status"`
// last time we got an update on a given condition
// +optional
LastHeartbeatTime metav1.Time `json:"lastHeartbeatTime,omitempty"`
// Last time the condition transit from one status to another.
// +optional
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"`
// (brief) reason for the condition's last transition,
// one-word CamelCase reason for the condition's last transition.
// +optional
Reason string `json:"reason,omitempty"`
// Human readable message indicating details about last transition.
// +optional
Message string `json:"message,omitempty"`
}