func newConfigMap(mpiJob *kubeflow.MPIJob, workerReplicas int, gpusPerWorker int) *corev1.ConfigMap {
	kubexec := fmt.Sprintf(`#!/bin/sh
set -x
POD_NAME=$1
shift
%s/kubectl exec ${POD_NAME} -- /bin/sh -c "$*"
`, kubectlMountPath)

	// If no GPU is specified, default to 1 slot.
	slots := 1
	if gpusPerWorker > 0 {
		slots = gpusPerWorker
	}
	var buffer bytes.Buffer
	for i := 0; i < workerReplicas; i++ {
		buffer.WriteString(fmt.Sprintf("%s%s-%d slots=%d\n", mpiJob.Name, workerSuffix, i, slots))
	}

	return &corev1.ConfigMap{
		ObjectMeta: metav1.ObjectMeta{
			Name:      mpiJob.Name + configSuffix,
			Namespace: mpiJob.Namespace,
			OwnerReferences: []metav1.OwnerReference{
				*metav1.NewControllerRef(mpiJob, kubeflow.SchemeGroupVersionKind),
			},
		},
		Data: map[string]string{
			hostfileName:      buffer.String(),
			kubexecScriptName: kubexec,
		},
	}
}
// newConfigMap creates a new ConfigMap containing configurations for an MPIJob
// resource. It also sets the appropriate OwnerReferences on the resource so
// handleObject can discover the MPIJob resource that 'owns' it.
newConfigMap creates a new ConfigMap containing configurations for an MPIJob
resource. It also sets the appropriate OwnerReferences on the resource so
handleObject can discover the MPIJob resource that 'owns' it.
// newConfigMap creates a new ConfigMap containing configurations for an MPIJob // resource . It also sets the appropriate OwnerReferences on the resource so // handleObject can discover the MPIJob resource that ' owns ' it .
func newConfigMap(mpiJob *kubeflow.MPIJob, workerReplicas int, gpusPerWorker int) *corev1.ConfigMap {
	kubexec := fmt.Sprintf(`#!/bin/sh
set -x
POD_NAME=$1
shift
%s/kubectl exec ${POD_NAME} -- /bin/sh -c "$*"
`, kubectlMountPath)
	slots := 1
	if gpusPerWorker > 0 {
		slots = gpusPerWorker
	}
	var buffer bytes.Buffer
	for i := 0; i < workerReplicas; i++ {
		buffer.WriteString(fmt.Sprintf("%s%s-%d slots=%d\n", mpiJob.Name, workerSuffix, i, slots))
	}
	return &corev1.ConfigMap{
		ObjectMeta: metav1.ObjectMeta{
			Name:      mpiJob.Name + configSuffix,
			Namespace: mpiJob.Namespace,
			OwnerReferences: []metav1.OwnerReference{
				*metav1.NewControllerRef(mpiJob, kubeflow.SchemeGroupVersionKind),
			},
		},
		Data: map[string]string{
			hostfileName:      buffer.String(),
			kubexecScriptName: kubexec,
		},
	}
}
func newConfigMap ( mpiJob * kubeflow . MPIJob , workerReplicas int , gpusPerWorker int ) * corev1 . ConfigMap { kubexec := fmt . Sprintf ( `#!/bin/sh
set -x
POD_NAME=$1
shift
%s/kubectl exec ${POD_NAME} -- /bin/sh -c "$*"
` , kubectlMountPath ) slots := 1 if gpusPerWorker > 0 { slots = gpusPerWorker } var buffer bytes . Buffer for i := 0 ; i < workerReplicas ; i ++ { buffer . WriteString ( fmt . Sprintf ( " \n " , mpiJob . Name , workerSuffix , i , slots ) ) } return & corev1 . ConfigMap { ObjectMeta : metav1 . ObjectMeta { Name : mpiJob . Name + configSuffix , Namespace : mpiJob . Namespace , OwnerReferences : [ ] metav1 . OwnerReference { * metav1 . NewControllerRef ( mpiJob , kubeflow . SchemeGroupVersionKind ) , } , } , Data : map [ string ] string { hostfileName : buffer . String ( ) , kubexecScriptName : kubexec , } , } }
newConfigMap creates a new ConfigMap containing configurations for an MPIJob
resource.
newConfigMap creates a new ConfigMap containing configurations for an MPIJob resource .
// If no GPU is specified, default to 1 slot.