Skip to content
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

#289 - Add register, update and delete model group functionality to support Model Access Control #332

Merged

Conversation

rawwar
Copy link
Contributor

@rawwar rawwar commented Nov 3, 2023

Description

Add model group registry, update, search and deletion functionality

Issues Resolved

closes #289
closes #290
closes #292
closes #333
closes #117

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

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.

Signed-off-by: kalyan <[email protected]>
@rawwar
Copy link
Contributor Author

rawwar commented Nov 3, 2023

@dhrubo-os , can you please review and let me know if you have any feedback. I am working on adding tests

@rawwar rawwar changed the title #289 - Add register model group functionality to support Model Access Control #289 - Add register, update and delete model group functionality to support Model Access Control Nov 3, 2023
@dhrubo-os
Copy link
Collaborator

Just one suggestion, you can also mark a PR as draft if you think PR is not ready to review yet.

@rawwar rawwar marked this pull request as draft November 3, 2023 20:54
Copy link

codecov bot commented Nov 4, 2023

Codecov Report

Merging #332 (075a763) into main (fc698a7) will increase coverage by 0.11%.
The diff coverage is 96.07%.

@@            Coverage Diff             @@
##             main     #332      +/-   ##
==========================================
+ Coverage   91.36%   91.47%   +0.11%     
==========================================
  Files          38       40       +2     
  Lines        4237     4339     +102     
==========================================
+ Hits         3871     3969      +98     
- Misses        366      370       +4     
Files Coverage Δ
opensearch_py_ml/ml_commons/ml_commons_client.py 84.84% <100.00%> (+0.18%) ⬆️
...y_ml/ml_commons/validators/model_access_control.py 98.00% <98.00%> (ø)
...pensearch_py_ml/ml_commons/model_access_control.py 94.00% <94.00%> (ø)

rawwar added 12 commits November 4, 2023 15:43
Signed-off-by: kalyan <[email protected]>
Signed-off-by: kalyan <[email protected]>
Signed-off-by: kalyan <[email protected]>
Signed-off-by: kalyan <[email protected]>
Signed-off-by: kalyan <[email protected]>
Signed-off-by: kalyan <[email protected]>
Signed-off-by: kalyan <[email protected]>
Signed-off-by: kalyan <[email protected]>
Signed-off-by: kalyan <[email protected]>
@rawwar
Copy link
Contributor Author

rawwar commented Nov 6, 2023

@dhrubo-os , I fixed the issues. Can you review the PR and let me know if I need to change anything? I will work on to increase the coverage.

rawwar added 11 commits November 6, 2023 08:52
Signed-off-by: kalyan <[email protected]>
Signed-off-by: kalyan <[email protected]>
Signed-off-by: kalyan <[email protected]>
Signed-off-by: kalyan <[email protected]>
Signed-off-by: kalyan <[email protected]>
Signed-off-by: kalyan <[email protected]>
Signed-off-by: kalyan <[email protected]>
Signed-off-by: kalyan <[email protected]>
Signed-off-by: kalyan <[email protected]>
@rawwar rawwar requested a review from dhrubo-os November 6, 2023 17:56
opensearch_py_ml/ml_commons/model_access_control.py Outdated Show resolved Hide resolved
tests/common.py Outdated Show resolved Hide resolved
tests/ml_commons/test_model_access_control.py Show resolved Hide resolved
tests/ml_commons/test_model_access_control.py Outdated Show resolved Hide resolved
tests/ml_commons/test_model_access_control.py Outdated Show resolved Hide resolved
@dhrubo-os
Copy link
Collaborator

@rbhavna Could you please review this PR as you implemented the model access control. Thanks.

Signed-off-by: kalyan <[email protected]>
Signed-off-by: kalyan <[email protected]>
Signed-off-by: kalyan <[email protected]>
Signed-off-by: kalyan <[email protected]>
.ci/opensearch/Dockerfile Show resolved Hide resolved
.github/workflows/integration.yml Show resolved Hide resolved
opensearch_py_ml/ml_commons/model_access_control.py Outdated Show resolved Hide resolved
tests/ml_commons/test_model_access_control.py Outdated Show resolved Hide resolved
@dhrubo-os
Copy link
Collaborator

Overall Looks good to me

@rbhavna could you also please review this PR as you know more about model access control?

Signed-off-by: kalyanr <[email protected]>
raise ValueError("operation needs to be a string")


def validate_create_model_group_parameters(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any specific reason we are not validating all the exception cases while creating model group? Like the ones we have here: https://github.com/opensearch-project/ml-commons/blob/6efb1ebeefb8a7930f6767262457d0d5b568ac75/plugin/src/main/java/org/opensearch/ml/model/MLModelGroupManager.java#L148

Copy link
Contributor Author

@rawwar rawwar Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rbhavna , since, these validations are already being done by ml-commons, having them here as well felt like double validations. Most checks I wrote here just check for type issues and helps to make a valid API call.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, the three exception cases that we are testing here are also being validated by ml-commons. Any reason we still have them here and not the others?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. I do feel we shouldn't be having these checks in opensearch-py-ml. Because, if checks on ml-commons change, we again need to update this on the client as well. I was thinking, client libraries only purpose would be to make the calls and if any errors from the opensearch, it should be able to pass them to user without any change. Also, maybe add few utility functions to make things easier for the user.

@dhrubo-os , @rbhavna , what do you think about removing these validations form opensearch-py-ml? Or Should I go ahead with implementing the validations from ml-commons ?

Copy link
Collaborator

@dhrubo-os dhrubo-os Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As opensearch-py-ml is a client plugin for ml-commons, we should have only the client side testing similar like any web application. Some basic input validations which can be easily caught before the request reaching to the server. We don't need to add that type of validations for which we need to make a back-end call like testing if the user is admin or not.

Yeah we need to have the same basic validations in ml-commons too, as py-ml isn't the only client for ml-commons.

)


def validate_update_model_group_parameters(update_query: dict, model_group_id: str):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same doubt. Update model group also validates similar exception cases that are missing here. If we are not validating them at any other place, I would suggest we have them here.

Copy link
Collaborator

@dhrubo-os dhrubo-os Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, but I think the limitation is, during update we don't know what are the values already for model group in index. So either we need to get the model group with a server call and then check or we call leave it to the server validation.

In this case I would prefer the second not to complicate things.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes agreed @dhrubo-os

Signed-off-by: kalyanr <[email protected]>
@dhrubo-os dhrubo-os merged commit 2c3b744 into opensearch-project:main Nov 13, 2023
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants