diff --git a/api/pkg/inference-logger/logger/mlobs_sink.go b/api/pkg/inference-logger/logger/mlobs_sink.go index 245b4c024..ccada2b26 100644 --- a/api/pkg/inference-logger/logger/mlobs_sink.go +++ b/api/pkg/inference-logger/logger/mlobs_sink.go @@ -80,6 +80,11 @@ func (m *MLObsSink) newPredictionLog(rawLogEntry *LogEntry) (*upiv1.PredictionLo if err != nil { return nil, err } + // If there is only one prediction, session id alone is enough to for unique prediction id + if len(standardModelRequest.Instances) == 1 && standardModelRequest.RowIds == nil { + standardModelRequest.RowIds = []string{""} + } + if len(standardModelRequest.RowIds) != len(standardModelResponse.Predictions) { return nil, fmt.Errorf("%w: number of row ids and predictions do not match", ErrMalformedLogEntry) } diff --git a/api/pkg/inference-logger/logger/mlobs_sink_test.go b/api/pkg/inference-logger/logger/mlobs_sink_test.go index 6043b730b..627b505bb 100644 --- a/api/pkg/inference-logger/logger/mlobs_sink_test.go +++ b/api/pkg/inference-logger/logger/mlobs_sink_test.go @@ -77,16 +77,28 @@ func TestLogEntryToPredictionLogConversion(t *testing.T) { nil, }, { - "empty row ids", + "empty row ids, multiple rows", &StandardModelRequest{ SessionId: "1234", Instances: [][]*float64{ {asInstanceValue(1.0)}, + {asInstanceValue(2.0)}, }, }, newTestStandardModelResponse([]float64{0.0}), ErrMalformedLogEntry, }, + { + "empty row ids, single rows", + &StandardModelRequest{ + SessionId: "1234", + Instances: [][]*float64{ + {asInstanceValue(1.0)}, + }, + }, + newTestStandardModelResponse([]float64{0.0}), + nil, + }, { "missing session id", &StandardModelRequest{