Skip to content

Commit e1590ce

Browse files
lowang-bhtenzen-y
andauthored
merge kubeflow/common.v1 to mpi-operator (#571)
* merge kubeflow/common.v1 to mpi-operator Signed-off-by: lowang_bh <lhui_wang@163.com> java gen Python SDK Signed-off-by: lowang_bh <lhui_wang@163.com> * update make generate and fix comment issues Signed-off-by: lowang_bh <lhui_wang@163.com> * Update pkg/apis/kubeflow/v2beta1/types.go Co-authored-by: Yuki Iwai <yuki.iwai.tz@gmail.com> * merge from master to solve conflict Signed-off-by: lowang-bh <lhui_wang@163.com> * change reference link to training-operator project Signed-off-by: lowang-bh <lhui_wang@163.com> --------- Signed-off-by: lowang_bh <lhui_wang@163.com> Signed-off-by: lowang-bh <lhui_wang@163.com> Co-authored-by: Yuki Iwai <yuki.iwai.tz@gmail.com>
1 parent 0994cfd commit e1590ce

27 files changed

+598
-548
lines changed

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ go 1.19
44

55
require (
66
github.com/google/go-cmp v0.5.9
7-
github.com/kubeflow/common v0.4.6
87
github.com/onsi/ginkgo v1.16.5
98
github.com/onsi/gomega v1.20.1
109
github.com/prometheus/client_golang v1.12.2

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,6 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
229229
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
230230
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
231231
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
232-
github.com/kubeflow/common v0.4.6 h1:yzJf/HEdS6ginD0GlVkgbOFie0Sp66VdGjXidAGZIlk=
233-
github.com/kubeflow/common v0.4.6/go.mod h1:43MAof/uhpJA2C0urynqatE3oKFQc7m2HLmJty7waqY=
234232
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
235233
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
236234
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=

hack/python-sdk/gen-sdk.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ mv pkg/apis/kubeflow/v2beta1/openapi_generated.go pkg/apis/kubeflow/v2beta1/open
3434
CODEGEN_VERSION=$(grep 'k8s.io/code-generator' go.sum | awk '{print $2}' | sed 's/\/go.mod//g' | head -1)
3535
GOBIN="${PWD}/bin" go install "k8s.io/code-generator/cmd/openapi-gen@${CODEGEN_VERSION}"
3636
echo "Generating V2 OpenAPI specification ..."
37-
"${PWD}/bin/openapi-gen" --input-dirs github.com/kubeflow/mpi-operator/pkg/apis/kubeflow/v2beta1,github.com/kubeflow/common/pkg/apis/common/v1 --output-package github.com/kubeflow/mpi-operator/pkg/apis/kubeflow/v2beta1 --go-header-file hack/boilerplate/boilerplate.go.txt
37+
"${PWD}/bin/openapi-gen" --input-dirs github.com/kubeflow/mpi-operator/pkg/apis/kubeflow/v2beta1 --output-package github.com/kubeflow/mpi-operator/pkg/apis/kubeflow/v2beta1 --go-header-file hack/boilerplate/boilerplate.go.txt
3838

3939
echo "Generating V2 swagger file ..."
4040
go run hack/python-sdk/main.go v2beta1 > ${SWAGGER_V2_CODEGEN_FILE}

hack/python-sdk/main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ func main() {
7373

7474
func swaggify(name string) string {
7575
name = strings.Replace(name, "github.com/kubeflow/mpi-operator/pkg/apis/kubeflow/", "", -1)
76-
name = strings.Replace(name, "github.com/kubeflow/common/pkg/apis/common/", "", -1)
7776
name = strings.Replace(name, "github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/", "", -1)
7877
name = strings.Replace(name, "k8s.io/api/core/", "", -1)
7978
name = strings.Replace(name, "k8s.io/apimachinery/pkg/apis/meta/", "", -1)

pkg/apis/kubeflow/v2beta1/constants.go

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,33 @@
1414

1515
package v2beta1
1616

17-
import common "github.com/kubeflow/common/pkg/apis/common/v1"
18-
1917
const (
2018
// EnvKubeflowNamespace is ENV for kubeflow namespace specified by user.
2119
EnvKubeflowNamespace = "KUBEFLOW_NAMESPACE"
2220
// DefaultRestartPolicy is default RestartPolicy for ReplicaSpec.
23-
DefaultRestartPolicy = common.RestartPolicyNever
21+
DefaultRestartPolicy = RestartPolicyNever
2422
// DefaultLauncherRestartPolicy is default RestartPolicy for Launcher Job.
25-
DefaultLauncherRestartPolicy = common.RestartPolicyOnFailure
23+
DefaultLauncherRestartPolicy = RestartPolicyOnFailure
2624
// OperatorName is the name of the operator used as value to the label common.OperatorLabelName
2725
OperatorName = "mpi-operator"
2826
)
27+
28+
// merge from common.v1
29+
// reference https://github.com/kubeflow/training-operator/blob/master/pkg/apis/kubeflow.org/v1/common_types.go
30+
const (
31+
32+
// ReplicaIndexLabel represents the label key for the replica-index, e.g. 0, 1, 2.. etc
33+
ReplicaIndexLabel = "training.kubeflow.org/replica-index"
34+
35+
// ReplicaTypeLabel represents the label key for the replica-type, e.g. ps, worker etc.
36+
ReplicaTypeLabel = "training.kubeflow.org/replica-type"
37+
38+
// OperatorNameLabel represents the label key for the operator name, e.g. tf-operator, mpi-operator, etc.
39+
OperatorNameLabel = "training.kubeflow.org/operator-name"
40+
41+
// JobNameLabel represents the label key for the job name, the value is the job name.
42+
JobNameLabel = "training.kubeflow.org/job-name"
43+
44+
// JobRoleLabel represents the label key for the job role, e.g. master.
45+
JobRoleLabel = "training.kubeflow.org/job-role"
46+
)

pkg/apis/kubeflow/v2beta1/default.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package v2beta1
1616

1717
import (
18-
common "github.com/kubeflow/common/pkg/apis/common/v1"
1918
"k8s.io/apimachinery/pkg/runtime"
2019
)
2120

@@ -24,7 +23,7 @@ func addDefaultingFuncs(scheme *runtime.Scheme) error {
2423
}
2524

2625
// setDefaultsTypeLauncher sets the default value to launcher.
27-
func setDefaultsTypeLauncher(spec *common.ReplicaSpec) {
26+
func setDefaultsTypeLauncher(spec *ReplicaSpec) {
2827
if spec == nil {
2928
return
3029
}
@@ -37,7 +36,7 @@ func setDefaultsTypeLauncher(spec *common.ReplicaSpec) {
3736
}
3837

3938
// setDefaultsTypeWorker sets the default value to worker.
40-
func setDefaultsTypeWorker(spec *common.ReplicaSpec) {
39+
func setDefaultsTypeWorker(spec *ReplicaSpec) {
4140
if spec == nil {
4241
return
4342
}

pkg/apis/kubeflow/v2beta1/default_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"testing"
1919

2020
"github.com/google/go-cmp/cmp"
21-
common "github.com/kubeflow/common/pkg/apis/common/v1"
2221
)
2322

2423
func TestSetDefaults_MPIJob(t *testing.T) {
@@ -102,7 +101,7 @@ func TestSetDefaults_MPIJob(t *testing.T) {
102101
"launcher defaults": {
103102
job: MPIJob{
104103
Spec: MPIJobSpec{
105-
MPIReplicaSpecs: map[MPIReplicaType]*common.ReplicaSpec{
104+
MPIReplicaSpecs: map[MPIReplicaType]*ReplicaSpec{
106105
MPIReplicaTypeLauncher: {},
107106
},
108107
},
@@ -116,7 +115,7 @@ func TestSetDefaults_MPIJob(t *testing.T) {
116115
SSHAuthMountPath: "/root/.ssh",
117116
MPIImplementation: MPIImplementationOpenMPI,
118117
LauncherCreationPolicy: "AtStartup",
119-
MPIReplicaSpecs: map[MPIReplicaType]*common.ReplicaSpec{
118+
MPIReplicaSpecs: map[MPIReplicaType]*ReplicaSpec{
120119
MPIReplicaTypeLauncher: {
121120
Replicas: newInt32(1),
122121
RestartPolicy: DefaultLauncherRestartPolicy,
@@ -128,7 +127,7 @@ func TestSetDefaults_MPIJob(t *testing.T) {
128127
"worker defaults": {
129128
job: MPIJob{
130129
Spec: MPIJobSpec{
131-
MPIReplicaSpecs: map[MPIReplicaType]*common.ReplicaSpec{
130+
MPIReplicaSpecs: map[MPIReplicaType]*ReplicaSpec{
132131
MPIReplicaTypeWorker: {},
133132
},
134133
},
@@ -142,7 +141,7 @@ func TestSetDefaults_MPIJob(t *testing.T) {
142141
SSHAuthMountPath: "/root/.ssh",
143142
MPIImplementation: MPIImplementationOpenMPI,
144143
LauncherCreationPolicy: "AtStartup",
145-
MPIReplicaSpecs: map[MPIReplicaType]*common.ReplicaSpec{
144+
MPIReplicaSpecs: map[MPIReplicaType]*ReplicaSpec{
146145
MPIReplicaTypeWorker: {
147146
Replicas: newInt32(0),
148147
RestartPolicy: DefaultRestartPolicy,

0 commit comments

Comments
 (0)