Skip to content

Commit

Permalink
fixed prototype to set termination policy to worker 0 by default when…
Browse files Browse the repository at this point in the history
… no master exists. (#444)
  • Loading branch information
raddaoui authored and k8s-ci-robot committed Mar 19, 2018
1 parent 6073021 commit 5dca627
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
10 changes: 8 additions & 2 deletions kubeflow/tf-job/prototypes/tf-job.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ local numPs = import "param://num_ps";
local numWorkers = import "param://num_workers";
local numGpus = import "param://num_gpus";

local terminationPolicy = if numMasters == 1 then
tfJob.parts.tfJobTerminationPolicy("MASTER", 0)
else
tfJob.parts.tfJobTerminationPolicy("WORKER", 0);

local workerSpec = if numGpus > 0 then
tfJob.parts.tfJobReplica("WORKER", numWorkers, args, imageGpu, numGpus)
else
Expand All @@ -46,6 +51,7 @@ std.prune(k.core.v1.list.new([
tfJob.parts.tfJob(name, namespace, [
tfJob.parts.tfJobReplica("MASTER", numMasters, args, image),
workerSpec,
tfJob.parts.tfJobReplica("PS", numPs, args, image),
]),
tfJob.parts.tfJobReplica("PS", numPs, args, image),],
terminationPolicy
),
]))
10 changes: 9 additions & 1 deletion kubeflow/tf-job/tf-job.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ local k = import "k.libsonnet";
}
else {},

tfJob(name, namespace, replicas):: {
tfJobTerminationPolicy(replicaName, replicaIndex):: {
chief: {
replicaName: replicaName,
replicaIndex: replicaIndex,
},
},

tfJob(name, namespace, replicas, tp):: {
apiVersion: "kubeflow.org/v1alpha1",
kind: "TFJob",
metadata: {
Expand All @@ -43,6 +50,7 @@ local k = import "k.libsonnet";
},
spec: {
replicaSpecs: replicas,
terminationPolicy: tp,
},
},
},
Expand Down

0 comments on commit 5dca627

Please sign in to comment.