Skip to content

Commit

Permalink
fix: provide deprecation msg to max_vfolder_size graphene field (#1644
Browse files Browse the repository at this point in the history
)
  • Loading branch information
fregataa authored Oct 23, 2023
1 parent 77c54cf commit 10662e8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
1 change: 1 addition & 0 deletions changes/1644.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Set deprecation message to `max_vfolder_size` graphene field. Set `max_vfolder_count` and `max_quota_scope_size` graphene fields optional. Update VFolder update API to use renewed column name `max_quota_scope_size`.
8 changes: 4 additions & 4 deletions src/ai/backend/manager/api/vfolder.py
Original file line number Diff line number Diff line change
Expand Up @@ -1025,10 +1025,10 @@ async def update_quota(request: web.Request, params: Any) -> web.Response:
if len(entries) == 0:
raise VFolderNotFound(extra_data=params["id"])

# Limit vfolder size quota if it is larger than max_vfolder_size of the resource policy.
max_vfolder_size = resource_policy.get("max_vfolder_size", 0)
if max_vfolder_size > 0 and (quota <= 0 or quota > max_vfolder_size):
quota = max_vfolder_size
# Limit vfolder size quota if it is larger than max_quota_scope_size of the resource policy.
max_quota_scope_size = resource_policy.get("max_quota_scope_size", 0)
if max_quota_scope_size > 0 and (quota <= 0 or quota > max_quota_scope_size):
quota = max_quota_scope_size

async with root_ctx.storage_manager.request(
proxy_name,
Expand Down
20 changes: 10 additions & 10 deletions src/ai/backend/manager/models/resource_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ class UserResourcePolicy(graphene.ObjectType):
name = graphene.String(required=True)
created_at = GQLDateTime(required=True)
max_vfolder_count = graphene.Int()
max_vfolder_size = BigInt() # aliased field
max_vfolder_size = BigInt(deprecation_reason="Deprecated since 23.09.1")
max_quota_scope_size = BigInt()

@classmethod
Expand Down Expand Up @@ -482,13 +482,13 @@ async def batch_load_by_user(


class CreateUserResourcePolicyInput(graphene.InputObjectType):
max_vfolder_count = graphene.Int(required=True)
max_quota_scope_size = BigInt(required=True)
max_vfolder_count = graphene.Int()
max_quota_scope_size = BigInt()


class ModifyUserResourcePolicyInput(graphene.InputObjectType):
max_vfolder_count = graphene.Int(required=True)
max_quota_scope_size = BigInt(required=True)
max_vfolder_count = graphene.Int()
max_quota_scope_size = BigInt()


class CreateUserResourcePolicy(graphene.Mutation):
Expand Down Expand Up @@ -586,7 +586,7 @@ class ProjectResourcePolicy(graphene.ObjectType):
name = graphene.String(required=True)
created_at = GQLDateTime(required=True)
max_vfolder_count = graphene.Int()
max_vfolder_size = BigInt() # aliased field
max_vfolder_size = BigInt(deprecation_reason="Deprecated since 23.09.1")
max_quota_scope_size = BigInt()

@classmethod
Expand Down Expand Up @@ -660,13 +660,13 @@ async def batch_load_by_project(


class CreateProjectResourcePolicyInput(graphene.InputObjectType):
max_vfolder_count = graphene.Int(required=True)
max_quota_scope_size = BigInt(required=True)
max_vfolder_count = graphene.Int()
max_quota_scope_size = BigInt()


class ModifyProjectResourcePolicyInput(graphene.InputObjectType):
max_vfolder_count = graphene.Int(required=True)
max_quota_scope_size = BigInt(required=True)
max_vfolder_count = graphene.Int()
max_quota_scope_size = BigInt()


class CreateProjectResourcePolicy(graphene.Mutation):
Expand Down

0 comments on commit 10662e8

Please sign in to comment.