Skip to content

Commit

Permalink
PUID typo and error constant fix
Browse files Browse the repository at this point in the history
Signed-off-by: glindsell <gl@seldon.io>
  • Loading branch information
glindsell committed May 18, 2020
1 parent 5e03400 commit 1d3ca47
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions executor/api/grpc/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ func TestAddPuid(t *testing.T) {

func TestExistingPuid(t *testing.T) {
g := NewGomegaWithT(t)
guid := "1"
puid := "1"

ctx := metadata.NewIncomingContext(context.TODO(), metadata.New(map[string]string{payload.SeldonPUIDHeader: guid}))
ctx := metadata.NewIncomingContext(context.TODO(), metadata.New(map[string]string{payload.SeldonPUIDHeader: puid}))
meta := CollectMetadata(ctx)

g.Expect(meta.Get(payload.SeldonPUIDHeader)).NotTo(BeNil())
g.Expect(meta.Get(payload.SeldonPUIDHeader)[0]).To(Equal(guid))
g.Expect(meta.Get(payload.SeldonPUIDHeader)[0]).To(Equal(puid))
}
4 changes: 3 additions & 1 deletion executor/predictor/predictor_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
v1 "github.com/seldonio/seldon-core/operator/apis/machinelearning.seldon.io/v1"
)

const NilPUIDError = "context value for Seldon PUID Header is nil"

type PredictorProcess struct {
Ctx context.Context
Client client.SeldonApiClient
Expand Down Expand Up @@ -270,7 +272,7 @@ func (p *PredictorProcess) getPUIDHeader() (string, error) {
if puid, ok := p.Ctx.Value(payload.SeldonPUIDHeader).(string); ok {
return puid, nil
}
return "", fmt.Errorf("context value Seldon PUID Header is nil: interface to string conversion failed")
return "", fmt.Errorf(NilPUIDError)
}

func (p *PredictorProcess) Predict(node *v1.PredictiveUnit, msg payload.SeldonPayload) (payload.SeldonPayload, error) {
Expand Down
2 changes: 1 addition & 1 deletion executor/predictor/predictor_process_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,5 +472,5 @@ func TestPredictNilPUIDError(t *testing.T) {
graph := &v1.PredictiveUnit{}
_, err := createPredictorProcessWithoutPUIDInContext(t).Predict(graph, createPredictPayload(g))
g.Expect(err).NotTo(BeNil())
g.Expect(err.Error()).Should(Equal("context value Seldon PUID Header is nil: interface to string conversion failed"))
g.Expect(err.Error()).Should(Equal(NilPUIDError))
}

0 comments on commit 1d3ca47

Please sign in to comment.