Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge kubeflow/common.v1 to mpi-operator #571

Merged
merged 7 commits into from
Jul 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ go 1.19

require (
github.com/google/go-cmp v0.5.9
github.com/kubeflow/common v0.4.6
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.20.1
github.com/prometheus/client_golang v1.12.2
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,6 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kubeflow/common v0.4.6 h1:yzJf/HEdS6ginD0GlVkgbOFie0Sp66VdGjXidAGZIlk=
github.com/kubeflow/common v0.4.6/go.mod h1:43MAof/uhpJA2C0urynqatE3oKFQc7m2HLmJty7waqY=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
Expand Down
2 changes: 1 addition & 1 deletion hack/python-sdk/gen-sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ mv pkg/apis/kubeflow/v2beta1/openapi_generated.go pkg/apis/kubeflow/v2beta1/open
CODEGEN_VERSION=$(grep 'k8s.io/code-generator' go.sum | awk '{print $2}' | sed 's/\/go.mod//g' | head -1)
GOBIN="${PWD}/bin" go install "k8s.io/code-generator/cmd/openapi-gen@${CODEGEN_VERSION}"
echo "Generating V2 OpenAPI specification ..."
"${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
"${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

echo "Generating V2 swagger file ..."
go run hack/python-sdk/main.go v2beta1 > ${SWAGGER_V2_CODEGEN_FILE}
Expand Down
1 change: 0 additions & 1 deletion hack/python-sdk/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ func main() {

func swaggify(name string) string {
name = strings.Replace(name, "github.com/kubeflow/mpi-operator/pkg/apis/kubeflow/", "", -1)
name = strings.Replace(name, "github.com/kubeflow/common/pkg/apis/common/", "", -1)
name = strings.Replace(name, "github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/", "", -1)
name = strings.Replace(name, "k8s.io/api/core/", "", -1)
name = strings.Replace(name, "k8s.io/apimachinery/pkg/apis/meta/", "", -1)
Expand Down
26 changes: 22 additions & 4 deletions pkg/apis/kubeflow/v2beta1/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,33 @@

package v2beta1

import common "github.com/kubeflow/common/pkg/apis/common/v1"

const (
// EnvKubeflowNamespace is ENV for kubeflow namespace specified by user.
EnvKubeflowNamespace = "KUBEFLOW_NAMESPACE"
// DefaultRestartPolicy is default RestartPolicy for ReplicaSpec.
DefaultRestartPolicy = common.RestartPolicyNever
DefaultRestartPolicy = RestartPolicyNever
// DefaultLauncherRestartPolicy is default RestartPolicy for Launcher Job.
DefaultLauncherRestartPolicy = common.RestartPolicyOnFailure
DefaultLauncherRestartPolicy = RestartPolicyOnFailure
// OperatorName is the name of the operator used as value to the label common.OperatorLabelName
OperatorName = "mpi-operator"
)

// merge from common.v1
lowang-bh marked this conversation as resolved.
Show resolved Hide resolved
// reference https://github.com/kubeflow/training-operator/blob/master/pkg/apis/kubeflow.org/v1/common_types.go
const (

// ReplicaIndexLabel represents the label key for the replica-index, e.g. 0, 1, 2.. etc
ReplicaIndexLabel = "training.kubeflow.org/replica-index"

// ReplicaTypeLabel represents the label key for the replica-type, e.g. ps, worker etc.
ReplicaTypeLabel = "training.kubeflow.org/replica-type"

// OperatorNameLabel represents the label key for the operator name, e.g. tf-operator, mpi-operator, etc.
OperatorNameLabel = "training.kubeflow.org/operator-name"

// JobNameLabel represents the label key for the job name, the value is the job name.
JobNameLabel = "training.kubeflow.org/job-name"

// JobRoleLabel represents the label key for the job role, e.g. master.
JobRoleLabel = "training.kubeflow.org/job-role"
)
5 changes: 2 additions & 3 deletions pkg/apis/kubeflow/v2beta1/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package v2beta1

import (
common "github.com/kubeflow/common/pkg/apis/common/v1"
"k8s.io/apimachinery/pkg/runtime"
)

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

// setDefaultsTypeLauncher sets the default value to launcher.
func setDefaultsTypeLauncher(spec *common.ReplicaSpec) {
func setDefaultsTypeLauncher(spec *ReplicaSpec) {
if spec == nil {
return
}
Expand All @@ -37,7 +36,7 @@ func setDefaultsTypeLauncher(spec *common.ReplicaSpec) {
}

// setDefaultsTypeWorker sets the default value to worker.
func setDefaultsTypeWorker(spec *common.ReplicaSpec) {
func setDefaultsTypeWorker(spec *ReplicaSpec) {
if spec == nil {
return
}
Expand Down
9 changes: 4 additions & 5 deletions pkg/apis/kubeflow/v2beta1/default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"testing"

"github.com/google/go-cmp/cmp"
common "github.com/kubeflow/common/pkg/apis/common/v1"
)

func TestSetDefaults_MPIJob(t *testing.T) {
Expand Down Expand Up @@ -102,7 +101,7 @@ func TestSetDefaults_MPIJob(t *testing.T) {
"launcher defaults": {
job: MPIJob{
Spec: MPIJobSpec{
MPIReplicaSpecs: map[MPIReplicaType]*common.ReplicaSpec{
MPIReplicaSpecs: map[MPIReplicaType]*ReplicaSpec{
MPIReplicaTypeLauncher: {},
},
},
Expand All @@ -116,7 +115,7 @@ func TestSetDefaults_MPIJob(t *testing.T) {
SSHAuthMountPath: "/root/.ssh",
MPIImplementation: MPIImplementationOpenMPI,
LauncherCreationPolicy: "AtStartup",
MPIReplicaSpecs: map[MPIReplicaType]*common.ReplicaSpec{
MPIReplicaSpecs: map[MPIReplicaType]*ReplicaSpec{
MPIReplicaTypeLauncher: {
Replicas: newInt32(1),
RestartPolicy: DefaultLauncherRestartPolicy,
Expand All @@ -128,7 +127,7 @@ func TestSetDefaults_MPIJob(t *testing.T) {
"worker defaults": {
job: MPIJob{
Spec: MPIJobSpec{
MPIReplicaSpecs: map[MPIReplicaType]*common.ReplicaSpec{
MPIReplicaSpecs: map[MPIReplicaType]*ReplicaSpec{
MPIReplicaTypeWorker: {},
},
},
Expand All @@ -142,7 +141,7 @@ func TestSetDefaults_MPIJob(t *testing.T) {
SSHAuthMountPath: "/root/.ssh",
MPIImplementation: MPIImplementationOpenMPI,
LauncherCreationPolicy: "AtStartup",
MPIReplicaSpecs: map[MPIReplicaType]*common.ReplicaSpec{
MPIReplicaSpecs: map[MPIReplicaType]*ReplicaSpec{
MPIReplicaTypeWorker: {
Replicas: newInt32(0),
RestartPolicy: DefaultRestartPolicy,
Expand Down
Loading