Skip to content

Commit 4433ad5

Browse files
authored
Making inferenceModel optional (#1024)
1 parent 1362b14 commit 4433ad5

File tree

2 files changed

+29
-22
lines changed

2 files changed

+29
-22
lines changed

pkg/epp/requestcontrol/director.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,16 @@ func (d *Director) HandleRequest(ctx context.Context, reqCtx *handlers.RequestCo
9191
return reqCtx, err
9292
}
9393

94-
// NOTE: The nil checking for the modelObject means that we DO allow passthrough currently.
95-
// This might be a security risk in the future where adapters not registered in the InferenceModel
96-
// are able to be requested by using their distinct name.
9794
modelObj := d.datastore.ModelGet(reqCtx.Model)
9895
if modelObj == nil {
99-
return reqCtx, errutil.Error{Code: errutil.BadConfiguration, Msg: fmt.Sprintf("error finding a model object in InferenceModel for input %v", reqCtx.Model)}
96+
logger.Info("No associated inferenceModel found, using default", "model", reqCtx.Model)
97+
sheddable := v1alpha2.Sheddable
98+
modelObj = &v1alpha2.InferenceModel{
99+
Spec: v1alpha2.InferenceModelSpec{
100+
ModelName: reqCtx.Model,
101+
Criticality: &sheddable,
102+
},
103+
}
100104
}
101105

102106
reqCtx.ResolvedTargetModel = reqCtx.Model

pkg/epp/requestcontrol/director_test.go

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,27 @@ func TestDirector_HandleRequest(t *testing.T) {
268268
},
269269
wantMutatedBodyModel: "resolved-target-model-A",
270270
},
271+
{
272+
name: "nonexistent target defined, use default inference model",
273+
schedulerMockSetup: func(m *mockScheduler) {
274+
m.scheduleResults = defaultSuccessfulScheduleResults
275+
},
276+
wantReqCtx: &handlers.RequestContext{
277+
Model: "food-review-1",
278+
ResolvedTargetModel: "food-review-1",
279+
TargetPod: &backend.Pod{
280+
NamespacedName: types.NamespacedName{Namespace: "default", Name: "pod1"},
281+
Address: "192.168.1.100",
282+
},
283+
TargetEndpoint: "192.168.1.100:8000",
284+
},
285+
wantMutatedBodyModel: "food-review-1",
286+
reqBodyMap: map[string]interface{}{
287+
"model": "food-review-1",
288+
"prompt": "test prompt",
289+
},
290+
mockSaturationDetector: &mockSaturationDetector{isSaturated: false},
291+
},
271292
{
272293

273294
name: "request dropped (sheddable, saturated)",
@@ -298,24 +319,6 @@ func TestDirector_HandleRequest(t *testing.T) {
298319
},
299320
wantErrCode: errutil.BadRequest,
300321
},
301-
{
302-
name: "invalid model defined, expect err",
303-
reqBodyMap: map[string]interface{}{
304-
"model": "non-existent-model",
305-
"prompt": "test prompt",
306-
},
307-
mockSaturationDetector: &mockSaturationDetector{isSaturated: false},
308-
wantErrCode: errutil.BadConfiguration,
309-
},
310-
{
311-
name: "invalid target defined, expect err",
312-
reqBodyMap: map[string]interface{}{
313-
"model": "food-review-1",
314-
"prompt": "test prompt",
315-
},
316-
mockSaturationDetector: &mockSaturationDetector{isSaturated: false},
317-
wantErrCode: errutil.BadConfiguration,
318-
},
319322
{
320323
name: "scheduler returns error",
321324
reqBodyMap: map[string]interface{}{

0 commit comments

Comments
 (0)