Skip to content

Commit

Permalink
fix: modify the code logic to check for the existence of min/max in `…
Browse files Browse the repository at this point in the history
…resource_limits`. (#1941)
  • Loading branch information
agatha197 committed Mar 29, 2024
1 parent ef0ea4d commit cfaafdd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions changes/1941.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
To update image metadata, check if the min/max values in `resource_limits` are undefined.
5 changes: 3 additions & 2 deletions src/ai/backend/manager/models/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import graphene
import sqlalchemy as sa
import trafaret as t
from graphql import Undefined
from redis.asyncio import Redis
from redis.asyncio.client import Pipeline
from sqlalchemy.ext.asyncio import AsyncSession
Expand Down Expand Up @@ -998,9 +999,9 @@ async def mutate(
resources_data = {}
for limit_option in props.resource_limits:
limit_data = {}
if limit_option.min is not None and len(limit_option.min) > 0:
if limit_option.min is not Undefined and len(limit_option.min) > 0:
limit_data["min"] = limit_option.min
if limit_option.max is not None and len(limit_option.max) > 0:
if limit_option.max is not Undefined and len(limit_option.max) > 0:
limit_data["max"] = limit_option.max
resources_data[limit_option.key] = limit_data
data["resources"] = resources_data
Expand Down

0 comments on commit cfaafdd

Please sign in to comment.