File tree 3 files changed +6
-3
lines changed
3 files changed +6
-3
lines changed Original file line number Diff line number Diff line change
1
+ Properly handle zero-value unknown resource limits when creating session.
Original file line number Diff line number Diff line change @@ -918,17 +918,19 @@ def from_user_input(
918
918
obj : Mapping [str , Any ],
919
919
slot_types : Optional [Mapping [SlotName , SlotTypes ]],
920
920
) -> "ResourceSlot" :
921
+ pruned_obj = {k : v for k , v in obj .items () if v != 0 }
922
+
921
923
try :
922
924
if slot_types is None :
923
925
data = {
924
926
k : cls ._normalize_value (k , v , cls ._guess_slot_type (k ))
925
- for k , v in obj .items ()
927
+ for k , v in pruned_obj .items ()
926
928
if v is not None
927
929
}
928
930
else :
929
931
data = {
930
932
k : cls ._normalize_value (k , v , slot_types [SlotName (k )])
931
- for k , v in obj .items ()
933
+ for k , v in pruned_obj .items ()
932
934
if v is not None
933
935
}
934
936
# fill missing
Original file line number Diff line number Diff line change @@ -1224,7 +1224,7 @@ async def enqueue_session(
1224
1224
if (resources := creation_config .get ("resources" )) is not None :
1225
1225
# Sanitize user input: does it have "known" resource slots only?
1226
1226
for slot_key , slot_value in resources .items ():
1227
- if slot_key not in known_slot_types :
1227
+ if slot_value != 0 and slot_key not in known_slot_types :
1228
1228
raise InvalidAPIParameters (f"Unknown requested resource slot: { slot_key } " )
1229
1229
try :
1230
1230
requested_slots = ResourceSlot .from_user_input (resources , known_slot_types )
You can’t perform that action at this time.
0 commit comments