-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Profile API #119
Added Profile API #119
Conversation
|
f61526a
to
e54712d
Compare
Thanks for your comment. I fixed linting. Could you check the documentation? If I'm not mistaken, I added the documentation within code by shortly describing each method and their parameters. |
@@ -198,3 +198,76 @@ def delete_model(self, model_id: str) -> object: | |||
method="DELETE", | |||
url=API_URL, | |||
) | |||
|
|||
def get_profile( |
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.
Can we try to merge all these 3 functions into one function?
It can be hard for customers to remember all these methods.
Can you please try to combine all these 3 functionalities into 1 function?
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.
Ok, I will try. Thank you for bringing this to my attention.
379b15a
to
d97196b
Compare
@@ -198,3 +198,44 @@ def delete_model(self, model_id: str) -> object: | |||
method="DELETE", | |||
url=API_URL, | |||
) | |||
|
|||
def get_profiles( |
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.
we need to write corresponding test to make sure this is working or not.
:rtype: object | ||
""" | ||
|
||
API_URL = f"{ML_BASE_URI}/profile" |
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 make this more robust so that we can also support scenarios like here
- GET /_plugins/_ml/profile/models --> If we see only one
model_id
is given nothing else, we can invoke this api. Example:GET /_plugins/_ml/profile/models/model_id
- GET /_plugins/_ml/profile/tasks --> if we see only one
task_id
is given nothing else, we can invoke this api.
Example:GET /_plugins/_ml/profile/tasks/task_id
- Otherwise invoke the base API. Example:
GET /_plugins/_ml/profile
{
"node_ids": ["KzONM8c8T4Od-NoUANQNGg"],
"return_all_tasks": true,
"return_all_models": true
}
Please let me know if you have any confusion.
Also don't forget to write test. Let me know if you have any question regarding writing test.
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.
- Endpoint: GET /_plugins/_ml/profile/models/model_id works fine.
- Endpoint: GET /_plugins/_ml/profile/tasks/task_id always returns empty json. So it was deleted. Instead for searching model tasks used API_BODY.
- In testing function for traversing over dictionary was added because model_id and task_id in returned json is 4 levels deeper.
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.
- GET /_plugins/_ml/profile/models --> If we see only one
model_id
is given nothing else, we can invoke this api. Example:GET /_plugins/_ml/profile/models/model_id
- GET /_plugins/_ml/profile/tasks --> if we see only one
task_id
is given nothing else, we can invoke this api.
Example:GET /_plugins/_ml/profile/tasks/task_id
- Otherwise invoke the base API. Example:
@dhrubo-os :
For 1, If we implement that, and then user wants all model profile data, its going to cause confusion. Example: User wants all tasks data and so, he doesn't pass model_id nor task_id . How are we going to conclude what user wanted here?
I think, a rather simple interface is to give users to call the respective api's separately. we should have three separate methods each returning exactly what user is requesting. Accepting model_id or task_id can be optional. I propose the following methods
get_profiles(request_body)
get_model_profile(model_id=None, request_body=None)
get_model_tasks(task_id=None, request_body=None)
195d8cd
to
9fa8232
Compare
@Merey1508 is there any update on writing unit test? Please let me know if you need any help, thanks. |
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## main #119 +/- ##
==========================================
- Coverage 89.97% 89.74% -0.23%
==========================================
Files 29 29
Lines 3491 3501 +10
==========================================
+ Hits 3141 3142 +1
- Misses 350 359 +9
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Signed-off-by: Merey <orazaly1508@gmail.com> Fixed linting Signed-off-by: Merey <orazaly1508@gmail.com> Added documentation for each method Signed-off-by: Merey <orazaly1508@gmail.com> Merged 3 functions into one Signed-off-by: Merey <orazaly1508@gmail.com> Merged 3 functions into one Signed-off-by: Merey <orazaly1508@gmail.com> Support additional scenarios Signed-off-by: Merey <orazaly1508@gmail.com> Support additional scenarios Signed-off-by: Merey <orazaly1508@gmail.com> Support additional scenarios Signed-off-by: Merey <orazaly1508@gmail.com> Support additional scenarios Signed-off-by: Merey <orazaly1508@gmail.com>
When providing path parameter task_id it returns empty json. Signed-off-by: Nurlan <nabzalbekov0@gmail.com>
url=API_URL, | ||
) | ||
|
||
if task_ids and len(model_ids) == 1: |
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.
Can we try to add a comment to describe what exactly are we doing here?
closing this pull request as this functionality is already done. |
Description
These three methods all retrieve different types of profiles from an OpenSearch cluster using the ML Commons API. Here's a brief description of each method:
def get_profile(self, node_ids: List[str] = [], return_all_tasks: bool = True, return_all_models: bool = True) -> object:
This method retrieves a profile from an OpenSearch cluster for one or more specified node IDs.
def get_profile_models(self, model_ids: List[str] = []) -> object:
This method retrieves a profile from an OpenSearch cluster for one or more specified machine learning models.
def get_profile_tasks(self, task_ids: List[str] = []) -> object:
This method retrieves a profile from an OpenSearch cluster for one or more specified machine learning tasks.
All three methods are similar in structure and use the same API endpoint to retrieve different types of profiles based on the parameters passed to them.
Issues Resolved
Link to issue: #104
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.