Skip to content

Commit

Permalink
Name label (#105)
Browse files Browse the repository at this point in the history
Add Name of the job to the labels.

This will make it easier to fetch resources belonging to a specific job.

* Fixes #72.
  • Loading branch information
jlewi authored Nov 1, 2017
1 parent 083bf79 commit e807068
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/trainer/replicas.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ func (s *TFReplicaSet) Labels() KubernetesLabels {
"job_type": string(s.Spec.TfReplicaType),
// runtime_id is set by Job.setup, which is called after the TfReplicaSet is created.
// this is why labels aren't a member variable.
"runtime_id": s.Job.job.Spec.RuntimeId})
"runtime_id": s.Job.job.Spec.RuntimeId,
"tf_job_name": s.Job.job.Metadata.Name,})
}

// Transforms the tfconfig to work with grpc_tensorflow_server
Expand Down
4 changes: 4 additions & 0 deletions pkg/trainer/replicas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ func TestTFReplicaSet(t *testing.T) {
clientSet := fake.NewSimpleClientset()

jobSpec := &spec.TfJob{
Metadata: meta_v1.ObjectMeta {
Name: "some-job",
},
Spec: spec.TfJobSpec{
RuntimeId: "some-runtime",
ReplicaSpecs: []*spec.TfReplicaSpec{
Expand Down Expand Up @@ -69,6 +72,7 @@ func TestTFReplicaSet(t *testing.T) {
"task_index": fmt.Sprintf("%v", index),
"job_type": "PS",
"runtime_id": "some-runtime",
"tf_job_name": "some-job",
}

// Check that a service was created.
Expand Down
1 change: 1 addition & 0 deletions pkg/trainer/tensorboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ func (s *TBReplicaSet) Labels() KubernetesLabels {
"tensorflow.org": "",
"runtime_id": s.Job.job.Spec.RuntimeId,
"app": "tensorboard",
"tf_job_name": s.Job.job.Metadata.Name,
})
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/trainer/tensorboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ func TestTBReplicaSet(t *testing.T) {
clientSet := fake.NewSimpleClientset()

jobSpec := &spec.TfJob{
Metadata: meta_v1.ObjectMeta {
Name: "some-job",
},
Spec: spec.TfJobSpec{
RuntimeId: "some-runtime",
ReplicaSpecs: []*spec.TfReplicaSpec{
Expand Down Expand Up @@ -59,6 +62,7 @@ func TestTBReplicaSet(t *testing.T) {
"tensorflow.org": "",
"app": "tensorboard",
"runtime_id": "some-runtime",
"tf_job_name": "some-job",
}

// Check that a service was created.
Expand Down

0 comments on commit e807068

Please sign in to comment.