Skip to content

Commit 23ff32b

Browse files
committed
Merge branch 'main' of https://github.com/oracle/accelerated-data-science into feature/model_group
2 parents 437a47c + 9c1095e commit 23ff32b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1777
-320
lines changed

.github/workflows/run-forecast-explainer-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ jobs:
5454
$CONDA/bin/conda init
5555
source /home/runner/.bashrc
5656
pip install -r test-requirements-operators.txt
57-
pip install "oracle-automlx[forecasting]>=25.1.1"
57+
pip install "oracle-automlx[forecasting]>=25.3.0"
5858
pip install pandas>=2.2.0
5959
python -m pytest -v -p no:warnings --durations=5 tests/operators/forecast/test_explainers.py

.github/workflows/run-forecast-unit-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@ jobs:
5656
$CONDA/bin/conda init
5757
source /home/runner/.bashrc
5858
pip install -r test-requirements-operators.txt
59-
pip install "oracle-automlx[forecasting]>=25.1.1"
59+
pip install "oracle-automlx[forecasting]>=25.3.0"
6060
pip install pandas>=2.2.0
6161
python -m pytest -v -p no:warnings --durations=5 tests/operators/forecast --ignore=tests/operators/forecast/test_explainers.py

ads/aqua/cli.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from ads.aqua.finetuning import AquaFineTuningApp
1515
from ads.aqua.model import AquaModelApp
1616
from ads.aqua.modeldeployment import AquaDeploymentApp
17+
from ads.aqua.verify_policies import AquaVerifyPoliciesApp
1718
from ads.common.utils import LOG_LEVELS
1819

1920

@@ -29,6 +30,7 @@ class AquaCommand:
2930
fine_tuning = AquaFineTuningApp
3031
deployment = AquaDeploymentApp
3132
evaluation = AquaEvaluationApp
33+
verify_policies = AquaVerifyPoliciesApp
3234

3335
def __init__(
3436
self,

ads/aqua/config/container_config.py

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -191,21 +191,28 @@ def from_service_config(
191191
additional_configurations.get("modelFormats")
192192
)
193193

194-
# Parse environment variables from `additional_configurations`.
195-
# Only keys present in the configuration will be added to the result.
196-
config_keys = {
197-
"MODEL_DEPLOY_PREDICT_ENDPOINT": UNKNOWN,
198-
"MODEL_DEPLOY_HEALTH_ENDPOINT": UNKNOWN,
199-
"PORT": UNKNOWN,
200-
"HEALTH_CHECK_PORT": UNKNOWN,
201-
"VLLM_USE_V1": UNKNOWN,
202-
}
203-
204-
env_vars = [
205-
{key: additional_configurations.get(key, default)}
206-
for key, default in config_keys.items()
207-
if key in additional_configurations
208-
]
194+
# TODO: Remove the else condition once SMC env variable config is updated everywhere
195+
if additional_configurations.get("env_vars", None):
196+
env_vars_dict = json.loads(
197+
additional_configurations.get("env_vars") or "{}"
198+
)
199+
env_vars = [
200+
{key: str(value)} for key, value in env_vars_dict.items()
201+
]
202+
else:
203+
config_keys = {
204+
"MODEL_DEPLOY_PREDICT_ENDPOINT": UNKNOWN,
205+
"MODEL_DEPLOY_HEALTH_ENDPOINT": UNKNOWN,
206+
"PORT": UNKNOWN,
207+
"HEALTH_CHECK_PORT": UNKNOWN,
208+
"VLLM_USE_V1": UNKNOWN,
209+
}
210+
211+
env_vars = [
212+
{key: additional_configurations.get(key, default)}
213+
for key, default in config_keys.items()
214+
if key in additional_configurations
215+
]
209216

210217
# Build container spec
211218
container_item.spec = AquaContainerConfigSpec(

ads/aqua/extension/model_handler.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# Copyright (c) 2024, 2025 Oracle and/or its affiliates.
33
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
4-
4+
import json
55
from typing import Optional
66
from urllib.parse import urlparse
77

@@ -341,9 +341,13 @@ def get(self, model_id):
341341
):
342342
try:
343343
oci_data_science_model = OCIDataScienceModel.from_id(model_id)
344+
chat_template = oci_data_science_model.get_custom_metadata_artifact("chat_template")
345+
chat_template = chat_template.decode("utf-8")
346+
347+
return self.finish(json.dumps({"chat_template": chat_template}))
348+
344349
except Exception as e:
345-
raise HTTPError(404, f"Model not found for id: {model_id}. Details: {str(e)}")
346-
return self.finish(oci_data_science_model.get_custom_metadata_artifact("chat_template"))
350+
raise HTTPError(404, f"Failed to fetch chat template for model_id={model_id}. Details: {str(e)}")
347351

348352
raise HTTPError(400, f"The request {self.request.path} is invalid.")
349353

ads/aqua/modeldeployment/deployment.py

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,6 @@ def _create_deployment(
11281128
logger.info(
11291129
f"Aqua model deployment {deployment_id} created for model {aqua_model_id}. Work request Id is {deployment.dsc_model_deployment.workflow_req_id}"
11301130
)
1131-
status_list = []
11321131

11331132
progress_thread = threading.Thread(
11341133
target=self.get_deployment_status,
@@ -1228,14 +1227,17 @@ def list(self, **kwargs) -> List["AquaDeployment"]:
12281227
aqua_model_id = model_deployment.freeform_tags.get(
12291228
Tags.AQUA_MODEL_ID_TAG, UNKNOWN
12301229
)
1231-
if "datasciencemodelgroup" in aqua_model_id:
1230+
if (
1231+
"datasciencemodelgroup" in aqua_model_id
1232+
or model_deployment.model_deployment_configuration_details.deployment_type
1233+
== "UNKNOWN_ENUM_VALUE"
1234+
):
12321235
continue
12331236
results.append(
12341237
AquaDeployment.from_oci_model_deployment(
12351238
model_deployment, self.region
12361239
)
12371240
)
1238-
12391241
# log telemetry if MD is in active or failed state
12401242
deployment_id = model_deployment.id
12411243
state = model_deployment.lifecycle_state.upper()
@@ -1686,45 +1688,24 @@ def get_deployment_status(
16861688
poll_interval=DEFAULT_POLL_INTERVAL,
16871689
)
16881690
except Exception:
1689-
status = ""
1690-
logs = deployment.show_logs().sort_values(by="time", ascending=False)
1691-
1692-
if logs and len(logs) > 0:
1693-
status = logs.iloc[0]["message"]
1694-
1695-
status = re.sub(r"[^a-zA-Z0-9]", " ", status)
1696-
16971691
if data_science_work_request._error_message:
16981692
error_str = ""
16991693
for error in data_science_work_request._error_message:
17001694
error_str = error_str + " " + error.message
17011695

17021696
error_str = re.sub(r"[^a-zA-Z0-9]", " ", error_str)
1703-
telemetry_kwargs = {
1704-
"ocid": ocid,
1705-
"model_name": model_name,
1706-
"work_request_error": error_str,
1707-
"status": status,
1708-
}
17091697

1710-
self.telemetry.record_event(
1711-
category=f"aqua/{model_type}/deployment/status",
1712-
action="FAILED",
1713-
**telemetry_kwargs,
1714-
)
1715-
else:
17161698
telemetry_kwargs = {
17171699
"ocid": ocid,
17181700
"model_name": model_name,
1719-
"status": status,
1701+
"work_request_error": error_str,
17201702
}
17211703

17221704
self.telemetry.record_event(
17231705
category=f"aqua/{model_type}/deployment/status",
17241706
action="FAILED",
17251707
**telemetry_kwargs,
17261708
)
1727-
17281709
else:
17291710
telemetry_kwargs = {"ocid": ocid, "model_name": model_name}
17301711
self.telemetry.record_event(
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*--
3+
4+
# Copyright (c) 2024 Oracle and/or its affiliates.
5+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
6+
from ads.aqua.verify_policies.verify import AquaVerifyPoliciesApp
7+
8+
__all__ = ["AquaVerifyPoliciesApp"]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
OBS_MANAGE_TEST_FILE = "AQUA Policy Verification - OBJECT STORAGE"
2+
TEST_MODEL_NAME="AQUA Policy Verification - Model"
3+
TEST_MD_NAME="AQUA Policy Verification - Model Deployment"
4+
TEST_JOB_NAME="AQUA Policy Verification - Job"
5+
TEST_JOB_RUN_NAME="AQUA Policy Verification - Job Run"
6+
TEST_MVS_NAME="AQUA Policy Verification - Model Version Set"
7+
TEST_VM_SHAPE="VM.Standard.E4.Flex"
8+
TEST_DEFAULT_JOB_SHAPE = "VM.Standard.E3.Flex"
9+
TEST_LIMIT_NAME = "ds-gpu-a10-count"
10+
DUMMY_TEST_BYTE = b"7IV6cktUGcHIhur4bXTv"
11+
POLICY_HELP_LINK = "https://github.com/oracle-samples/oci-data-science-ai-samples/blob/main/ai-quick-actions/policies/README.md"
12+
13+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from dataclasses import dataclass
2+
from ads.common.extended_enum import ExtendedEnum
3+
from ads.common.serializer import DataClassSerializable
4+
5+
6+
class PolicyStatus(ExtendedEnum):
7+
SUCCESS = "SUCCESS"
8+
FAILURE = "FAILURE"
9+
UNVERIFIED = "UNVERIFIED"
10+
11+
12+
@dataclass(repr=False)
13+
class OperationResultSuccess(DataClassSerializable):
14+
operation: str
15+
status: PolicyStatus = PolicyStatus.SUCCESS
16+
17+
18+
@dataclass(repr=False)
19+
class OperationResultFailure(DataClassSerializable):
20+
operation: str
21+
error: str
22+
policy_hint: str
23+
status: PolicyStatus = PolicyStatus.FAILURE
24+
25+
26+
@dataclass(repr=False)
27+
class CommonSettings(DataClassSerializable):
28+
compartment_id: str
29+
project_id: str
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
from ads.aqua.verify_policies.utils import VerifyPoliciesUtils
2+
3+
utils = VerifyPoliciesUtils()
4+
operation_messages = {
5+
utils.list_compartments.__name__: {
6+
"name": "List Compartments",
7+
"error": "Unable to retrieve the list of compartments. Please verify that you have the required permissions to list compartments in your tenancy. ",
8+
"policy_hint": "Allow dynamic-group aqua-dynamic-group to inspect compartments in tenancy"
9+
},
10+
utils.list_models.__name__: {
11+
"name": "List Models",
12+
"error": "Failed to fetch available models. Ensure that the policies allow you to list models from the Model Catalog in the selected compartment.",
13+
"policy_hint": "Allow dynamic-group aqua-dynamic-group to manage data-science-models in compartment <your-compartment-name>"
14+
},
15+
utils.list_project.__name__: {
16+
"name": "List Projects",
17+
"error": "Failed to list Data Science projects. Verify that you have the appropriate permission to access projects in the selected compartment.",
18+
"policy_hint": "Allow dynamic-group aqua-dynamic-group to manage data-science-projects in compartment <your-compartment-name>"
19+
},
20+
utils.list_model_version_sets.__name__: {
21+
"name": "List Model Version Sets",
22+
"error": "Unable to load model version sets. Check your access rights to list model version sets in the selected compartment.",
23+
"policy_hint": "Allow dynamic-group aqua-dynamic-group to manage data-science-modelversionsets in compartment <your-compartment-name>"
24+
},
25+
utils.list_jobs.__name__: {
26+
"name": "List Jobs",
27+
"error": "Job list could not be retrieved. Please confirm that you have the necessary permissions to view jobs in the compartment.",
28+
"policy_hint": "Allow dynamic-group aqua-dynamic-group to manage data-science-jobs in compartment <your-compartment-name>"
29+
},
30+
utils.list_job_runs.__name__: {
31+
"name": "List Job Runs",
32+
"error": "Job Runs list could not be retrieved. Please confirm that you have the necessary permissions to view job runs in the compartme",
33+
"policy_hint": "Allow dynamic-group aqua-dynamic-group to manage data-science-job-runs in compartment <your-compartment-name>"
34+
},
35+
utils.list_buckets.__name__: {
36+
"name": "List Object Storage Buckets",
37+
"error": "Cannot fetch Object Storage buckets. Verify that you have access to list buckets within the specified compartment.",
38+
"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>"
39+
},
40+
utils.manage_bucket.__name__: {
41+
"name": "Object Storage Access",
42+
"error": "Failed to access the Object Storage bucket. Verify that the bucket exists and you have write permissions.",
43+
"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>'}"
44+
},
45+
utils.list_log_groups.__name__: {
46+
"name": "List Log Groups",
47+
"error": "Log groups or logs could not be retrieved. Please confirm you have logging read access for the selected compartment.",
48+
"policy_hint": "Allow dynamic-group aqua-dynamic-group to use logging-family in compartment <your-compartment-name>"
49+
},
50+
utils.get_resource_availability.__name__: {
51+
"name": "Verify Shape Limits",
52+
"error": "Failed to retrieve shape limits for your compartment. Make sure the required policies are in place to read shape and quota data.",
53+
"policy_hint": "Allow dynamic-group aqua-dynamic-group to read resource-availability in compartment <your-compartment-name>"
54+
},
55+
utils.register_model.__name__: {
56+
"name": "Register Model",
57+
"error": "Model registration failed. Ensure you have the correct permissions to write to the Model Catalog and access Object Storage.",
58+
"policy_hint": "Allow dynamic-group aqua-dynamic-group to manage data-science-models in compartment <your-compartment-name>"
59+
},
60+
utils.aqua_model.delete_model.__name__: {
61+
"name": "Delete Model",
62+
"error": "Could not delete model. Please confirm you have delete permissions for Model Catalog resources in the compartment.",
63+
"policy_hint": "Allow dynamic-group aqua-dynamic-group to manage data-science-models in compartment <your-compartment-name>"
64+
},
65+
utils.create_job.__name__: {
66+
"name": "Create Job",
67+
"error": "Job could not be created. Please check if you have permissions to create Data Science jobs.",
68+
"policy_hint": "Allow dynamic-group aqua-dynamic-group to manage data-science-jobs in compartment <your-compartment-name>"
69+
},
70+
utils.create_job_run.__name__: {
71+
"name": "Create Job Run",
72+
"error": "Job Run could not be created. Confirm that you are allowed to run jobs in the selected compartment.",
73+
"policy_hint": "Allow dynamic-group aqua-dynamic-group to manage data-science-job-runs in compartment <your-compartment-name>"
74+
},
75+
"delete_job": {
76+
"name": "Delete Job",
77+
"error": "Job could not be deleted. Please check if you have permissions to delete Data Science jobs.",
78+
"policy_hint": "Allow dynamic-group aqua-dynamic-group to manage data-science-jobs in compartment <your-compartment-name>"
79+
},
80+
utils.aqua_model.create_model_version_set.__name__: {
81+
"name": "Create Model Version Set",
82+
"error": "Unable to create a model version set for storing evaluation results. Ensure that required Model Catalog permissions are set.",
83+
"policy_hint": "Allow dynamic-group aqua-dynamic-group to manage data-science-modelversionsets in compartment <your-compartment-name>"
84+
},
85+
utils.aqua_model.ds_client.delete_model_version_set.__name__: {
86+
"name": "Delete Model Version Set",
87+
"error": "Unable to delete a model version. Ensure that required Model Catalog permissions are set.",
88+
"policy_hint": "Allow dynamic-group aqua-dynamic-group to manage data-science-modelversionsets in compartment <your-compartment-name>"
89+
},
90+
utils.create_model_deployment.__name__: {
91+
"name": "Create Model Deployment",
92+
"error": "Model deployment could not be created. Confirm you have correct permissions to deploy models to the Model Deployment service.",
93+
"policy_hint": "Allow dynamic-group aqua-dynamic-group to manage data-science-model-deployments in compartment <your-compartment-name>"
94+
},
95+
utils.aqua_model.ds_client.delete_model_deployment.__name__: {
96+
"name": "Delete Model Deployment",
97+
"error": "Unable to delete the model deployment. Please check if you have appropriate permissions to manage deployments.",
98+
"policy_hint": "Allow dynamic-group aqua-dynamic-group to manage data-science-model-deployments in compartment <your-compartment-name>"
99+
}
100+
101+
}

0 commit comments

Comments
 (0)