-
Notifications
You must be signed in to change notification settings - Fork 50
[AQUA] CLI to verify policies to perform operations related to AQUA. #1218
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
Open
amitkrprajapati
wants to merge
5
commits into
main
Choose a base branch
from
ODSC-72417/Policy_Verification
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8c50bcb
CLI to verify policies to perform operations related to AQUA.
amitkrprajapati d3932b9
Unint Test and documentation
amitkrprajapati 201a3c4
fix for create mvs
amitkrprajapati 979e52b
Add subnet
amitkrprajapati bb1330c
Merge branch 'main' into ODSC-72417/Policy_Verification
mrDzurb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*-- | ||
|
||
# Copyright (c) 2024 Oracle and/or its affiliates. | ||
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ | ||
from ads.aqua.verify_policies.verify import AquaVerifyPoliciesApp | ||
|
||
__all__ = ["AquaVerifyPoliciesApp"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
OBS_MANAGE_TEST_FILE = "AQUA Policy Verification - OBJECT STORAGE" | ||
TEST_MODEL_NAME="AQUA Policy Verification - Model" | ||
TEST_MD_NAME="AQUA Policy Verification - Model Deployment" | ||
TEST_JOB_NAME="AQUA Policy Verification - Job" | ||
TEST_JOB_RUN_NAME="AQUA Policy Verification - Job Run" | ||
TEST_MVS_NAME="AQUA Policy Verification - Model Version Set" | ||
TEST_VM_SHAPE="VM.Standard.E4.Flex" | ||
TEST_DEFAULT_JOB_SHAPE = "VM.Standard.E3.Flex" | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from dataclasses import dataclass | ||
from ads.common.extended_enum import ExtendedEnum | ||
from ads.common.serializer import DataClassSerializable | ||
|
||
|
||
class PolicyStatus(ExtendedEnum): | ||
SUCCESS = "SUCCESS" | ||
FAILURE = "FAILURE" | ||
UNVERIFIED = "UNVERIFIED" | ||
|
||
|
||
@dataclass(repr=False) | ||
class OperationResultSuccess(DataClassSerializable): | ||
operation: str | ||
status: PolicyStatus = PolicyStatus.SUCCESS | ||
|
||
|
||
@dataclass(repr=False) | ||
class OperationResultFailure(DataClassSerializable): | ||
operation: str | ||
error: str | ||
policy_hint: str | ||
status: PolicyStatus = PolicyStatus.FAILURE | ||
|
||
|
||
@dataclass(repr=False) | ||
class CommonSettings(DataClassSerializable): | ||
compartment_id: str | ||
project_id: str |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
from ads.aqua.verify_policies.utils import VerifyPoliciesUtils | ||
|
||
utils = VerifyPoliciesUtils() | ||
operation_messages = { | ||
utils.list_compartments.__name__: { | ||
"name": "List Compartments", | ||
"error": "Unable to retrieve the list of compartments. Please verify that you have the required permissions to list compartments in your tenancy. ", | ||
"policy_hint": "Allow dynamic-group aqua-dynamic-group to inspect compartments in tenancy" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As we discussed during the syncup, let's also try to add a link to the GH docs, where the policies can be setup. |
||
}, | ||
utils.list_models.__name__: { | ||
"name": "List Models", | ||
"error": "Failed to fetch available models. Ensure that the policies allow you to list models from the Model Catalog in the selected compartment.", | ||
"policy_hint": "Allow dynamic-group aqua-dynamic-group to manage data-science-models in compartment <your-compartment-name>" | ||
}, | ||
utils.list_project.__name__: { | ||
"name": "List Projects", | ||
"error": "Failed to list Data Science projects. Verify that you have the appropriate permission to access projects in the selected compartment.", | ||
"policy_hint": "Allow dynamic-group aqua-dynamic-group to manage data-science-projects in compartment <your-compartment-name>" | ||
}, | ||
utils.list_model_version_sets.__name__: { | ||
"name": "List Model Version Sets", | ||
"error": "Unable to load model version sets. Check your access rights to list model version sets in the selected compartment.", | ||
"policy_hint": "Allow dynamic-group aqua-dynamic-group to manage data-science-modelversionsets in compartment <your-compartment-name>" | ||
}, | ||
utils.list_jobs.__name__: { | ||
"name": "List Jobs", | ||
"error": "Job list could not be retrieved. Please confirm that you have the necessary permissions to view jobs in the compartment.", | ||
"policy_hint": "Allow dynamic-group aqua-dynamic-group to manage data-science-jobs in compartment <your-compartment-name>" | ||
}, | ||
utils.list_job_runs.__name__: { | ||
"name": "List Job Runs", | ||
"error": "Job Runs list could not be retrieved. Please confirm that you have the necessary permissions to view job runs in the compartme", | ||
"policy_hint": "Allow dynamic-group aqua-dynamic-group to manage data-science-job-runs in compartment <your-compartment-name>" | ||
}, | ||
utils.list_buckets.__name__: { | ||
"name": "List Object Storage Buckets", | ||
"error": "Cannot fetch Object Storage buckets. Verify that you have access to list buckets within the specified compartment.", | ||
"policy_hint": "Allow dynamic-group aqua-dynamic-group to read objectstorage-namespaces in compartment <your-compartment-name>\nAllow dynamic-group aqua-dynamic-group to read buckets in compartment <your-compartment-name>" | ||
}, | ||
utils.manage_bucket.__name__: { | ||
"name": "Object Storage Access", | ||
"error": "Failed to access the Object Storage bucket. Verify that the bucket exists and you have write permissions.", | ||
"policy_hint": "Allow dynamic-group aqua-dynamic-group to manage object-family in compartment <your-compartment-name> where any {target.bucket.name='<your-bucket-name>'}" | ||
}, | ||
utils.list_log_groups.__name__: { | ||
"name": "List Log Groups", | ||
"error": "Log groups or logs could not be retrieved. Please confirm you have logging read access for the selected compartment.", | ||
"policy_hint": "Allow dynamic-group aqua-dynamic-group to use logging-family in compartment <your-compartment-name>" | ||
}, | ||
utils.get_resource_availability.__name__: { | ||
"name": "Verify Shape Limits", | ||
"error": "Failed to retrieve shape limits for your compartment. Make sure the required policies are in place to read shape and quota data.", | ||
"policy_hint": "Allow dynamic-group aqua-dynamic-group to read resource-availability in compartment <your-compartment-name>" | ||
}, | ||
utils.register_model.__name__: { | ||
"name": "Register Model", | ||
"error": "Model registration failed. Ensure you have the correct permissions to write to the Model Catalog and access Object Storage.", | ||
"policy_hint": "Allow dynamic-group aqua-dynamic-group to manage data-science-models in compartment <your-compartment-name>" | ||
}, | ||
utils.aqua_model.delete_model.__name__: { | ||
"name": "Delete Model", | ||
"error": "Could not delete model. Please confirm you have delete permissions for Model Catalog resources in the compartment.", | ||
"policy_hint": "Allow dynamic-group aqua-dynamic-group to manage data-science-models in compartment <your-compartment-name>" | ||
}, | ||
utils.create_job.__name__: { | ||
"name": "Create Job", | ||
"error": "Job could not be created. Please check if you have permissions to create Data Science jobs.", | ||
"policy_hint": "Allow dynamic-group aqua-dynamic-group to manage data-science-jobs in compartment <your-compartment-name>" | ||
}, | ||
utils.create_job_run.__name__: { | ||
"name": "Create Job Run", | ||
"error": "Job Run could not be created. Confirm that you are allowed to run jobs in the selected compartment.", | ||
"policy_hint": "Allow dynamic-group aqua-dynamic-group to manage data-science-job-runs in compartment <your-compartment-name>" | ||
}, | ||
"delete_job": { | ||
"name": "Delete Job", | ||
"error": "Job could not be deleted. Please check if you have permissions to delete Data Science jobs.", | ||
"policy_hint": "Allow dynamic-group aqua-dynamic-group to manage data-science-jobs in compartment <your-compartment-name>" | ||
}, | ||
utils.aqua_model.create_model_version_set.__name__: { | ||
"name": "Create Model Version Set", | ||
"error": "Unable to create a model version set for storing evaluation results. Ensure that required Model Catalog permissions are set.", | ||
"policy_hint": "Allow dynamic-group aqua-dynamic-group to manage data-science-modelversionsets in compartment <your-compartment-name>" | ||
}, | ||
utils.aqua_model.ds_client.delete_model_version_set.__name__: { | ||
"name": "Delete Model Version Set", | ||
"error": "Unable to delete a model version. Ensure that required Model Catalog permissions are set.", | ||
"policy_hint": "Allow dynamic-group aqua-dynamic-group to manage data-science-modelversionsets in compartment <your-compartment-name>" | ||
}, | ||
utils.create_model_deployment.__name__: { | ||
"name": "Create Model Deployment", | ||
"error": "Model deployment could not be created. Confirm you have correct permissions to deploy models to the Model Deployment service.", | ||
"policy_hint": "Allow dynamic-group aqua-dynamic-group to manage data-science-model-deployments in compartment <your-compartment-name>" | ||
}, | ||
utils.aqua_model.ds_client.delete_model_deployment.__name__: { | ||
"name": "Delete Model Deployment", | ||
"error": "Unable to delete the model deployment. Please check if you have appropriate permissions to manage deployments.", | ||
"policy_hint": "Allow dynamic-group aqua-dynamic-group to manage data-science-model-deployments in compartment <your-compartment-name>" | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
NIT: We are trying to move everything to pydantic classes instead.