-
Notifications
You must be signed in to change notification settings - Fork 19
feat: Add API to get available resources #442
base: main
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## main #442 +/- ##
==========================================
- Coverage 48.28% 48.16% -0.13%
==========================================
Files 52 52
Lines 8708 8763 +55
==========================================
+ Hits 4205 4221 +16
- Misses 4503 4542 +39
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Let's refactor the common reusable parts from
get_available_resources()
and the above existingcheck_presets()
handler as a shared function in theai.backend.models.resource_preset
module, just likequery_allowed_sgroups()
. - Though it seems that group resource checks are not implemented yet, please apply the group resource visibility option when you do.
@@ -748,6 +856,7 @@ def create_app(default_cors_options: CORSOptions) -> Tuple[web.Application, Iter | |||
add_route = app.router.add_route | |||
cors.add(add_route('GET', '/presets', list_presets)) | |||
cors.add(add_route('POST', '/check-presets', check_presets)) | |||
cors.add(add_route('GET', '/get-resources', get_available_resources)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rename the URL to /available-resources
since the HTTP method name "GET" already indicates its a query API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add type annotations as much as possible when you write new functions.
@@ -193,3 +212,88 @@ async def mutate( | |||
.where(resource_presets.c.name == name) | |||
) | |||
return await simple_db_mutate(cls, info.context, delete_query) | |||
|
|||
|
|||
async def get_row(conn, request, params, domain_name): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please clarify the name of this function. What is the row
? Where is it from?
…rce prefix * WIP: rewriting resource check routines -- but we need to discuss the policy about visibility of scaling group capacity and the sum of other user's occupation to non-admin users, because these new APIs directly expose the exact amount of resources unlike the check-preset API. * fix: Apply consistent API logging headers (e.g., LIST_RESETS -> RESORUCE.LIST_PRESETS)
lablup/backend.ai#249
This PR adds API to get available resources in groups.
Users can get available resources by API GET method.