Skip to content

Commit 8b9ef21

Browse files
committed
Merge branch 'main' into jobs_auth
2 parents 1e4b804 + ca69485 commit 8b9ef21

File tree

9 files changed

+82
-21
lines changed

9 files changed

+82
-21
lines changed

ads/aqua/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,23 @@
66

77
import logging
88
import sys
9+
import os
10+
from ads.aqua.utils import fetch_service_compartment
11+
from ads.config import OCI_RESOURCE_PRINCIPAL_VERSION
12+
from ads import set_auth
913

1014
logger = logging.getLogger(__name__)
1115
handler = logging.StreamHandler(sys.stdout)
1216
logger.setLevel(logging.INFO)
17+
18+
if OCI_RESOURCE_PRINCIPAL_VERSION:
19+
set_auth("resource_principal")
20+
21+
ODSC_MODEL_COMPARTMENT_OCID = os.environ.get("ODSC_MODEL_COMPARTMENT_OCID")
22+
if not ODSC_MODEL_COMPARTMENT_OCID:
23+
try:
24+
ODSC_MODEL_COMPARTMENT_OCID = fetch_service_compartment()
25+
except Exception as e:
26+
logger.error(
27+
f"ODSC_MODEL_COMPARTMENT_OCID environment variable is not set for Aqua, due to {e}."
28+
)

ads/aqua/evaluation.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,11 +1392,6 @@ def load_evaluation_config(self, eval_id):
13921392
"memory_in_gbs": 128,
13931393
"block_storage_size": 200,
13941394
},
1395-
"VM.Standard.A1.Flex": {
1396-
"ocpu": 8,
1397-
"memory_in_gbs": 128,
1398-
"block_storage_size": 200,
1399-
},
14001395
},
14011396
"default": {
14021397
"ocpu": 8,

ads/aqua/extension/common_handler.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
from importlib import metadata
88

99
from ads.aqua.extension.base_handler import AquaAPIhandler
10+
from ads.aqua import ODSC_MODEL_COMPARTMENT_OCID
11+
from ads.aqua.exception import AquaResourceAccessError
1012

1113

1214
class ADSVersionHandler(AquaAPIhandler):
@@ -16,6 +18,19 @@ def get(self):
1618
self.finish({"data": metadata.version("oracle_ads")})
1719

1820

21+
class CompatibilityCheckHandler(AquaAPIhandler):
22+
"""The handler to check if the extension is compatible."""
23+
24+
def get(self):
25+
if ODSC_MODEL_COMPARTMENT_OCID:
26+
return self.finish(dict(status="ok"))
27+
else:
28+
raise AquaResourceAccessError(
29+
f"The AI Quick actions extension is not compatible in the given region."
30+
)
31+
32+
1933
__handlers__ = [
2034
("ads_version", ADSVersionHandler),
35+
("hello", CompatibilityCheckHandler),
2136
]

ads/aqua/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@
4747
AQUA_SERVICE_MODELS_BUCKET,
4848
COMPARTMENT_OCID,
4949
CONDA_BUCKET_NS,
50-
ODSC_MODEL_COMPARTMENT_OCID,
5150
PROJECT_OCID,
5251
TENANCY_OCID,
5352
)
53+
from ads.aqua import ODSC_MODEL_COMPARTMENT_OCID
5454
from ads.model import DataScienceModel
5555
from ads.model.model_metadata import MetadataTaxonomyKeys, ModelCustomMetadata
5656
from ads.telemetry import telemetry

ads/aqua/utils.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
from ads.common.oci_resource import SEARCH_TYPE, OCIResource
3030
from ads.common.utils import get_console_link, upload_to_os
3131
from ads.config import (
32-
AQUA_CONFIG_FOLDER,
3332
AQUA_SERVICE_MODELS_BUCKET,
3433
CONDA_BUCKET_NS,
3534
TENANCY_OCID,
@@ -45,6 +44,7 @@
4544
README = "README.md"
4645
LICENSE_TXT = "config/LICENSE.txt"
4746
DEPLOYMENT_CONFIG = "deployment_config.json"
47+
COMPARTMENT_MAPPING_KEY = "service-model-compartment"
4848
CONTAINER_INDEX = "container_index.json"
4949
EVALUATION_REPORT_JSON = "report.json"
5050
EVALUATION_REPORT_MD = "report.md"
@@ -268,9 +268,12 @@ def is_valid_ocid(ocid: str) -> bool:
268268
bool:
269269
Whether the given ocid is valid.
270270
"""
271-
pattern = r"^ocid1\.([a-z0-9_]+)\.([a-z0-9]+)\.([a-z0-9]*)(\.[^.]+)?\.([a-z0-9_]+)$"
271+
# TODO: revisit pattern
272+
pattern = (
273+
r"^ocid1\.([a-z0-9_]+)\.([a-z0-9]+)\.([a-z0-9-]*)(\.[^.]+)?\.([a-z0-9_]+)$"
274+
)
272275
match = re.match(pattern, ocid)
273-
return bool(match)
276+
return True
274277

275278

276279
def get_resource_type(ocid: str) -> str:
@@ -574,6 +577,22 @@ def get_container_image(
574577
return container_image
575578

576579

580+
def fetch_service_compartment():
581+
"""Loads the compartment mapping json from service bucket"""
582+
config_file_name = (
583+
f"oci://{AQUA_SERVICE_MODELS_BUCKET}@{CONDA_BUCKET_NS}/service_models/config"
584+
)
585+
586+
config = load_config(
587+
file_path=config_file_name,
588+
config_file_name=CONTAINER_INDEX,
589+
)
590+
compartment_mapping = config.get(COMPARTMENT_MAPPING_KEY)
591+
if compartment_mapping:
592+
return compartment_mapping.get(CONDA_BUCKET_NS)
593+
return None
594+
595+
577596
def get_max_version(versions):
578597
"""Takes in a list of versions and returns the higher version."""
579598
if not versions:

ads/config.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,6 @@
8383
AQUA_SERVICE_NAME = "aqua"
8484
DATA_SCIENCE_SERVICE_NAME = "data-science"
8585

86-
compartment_mapping = {
87-
"idoaxnz5ar4s": "ocid1.compartment.oc1..aaaaaaaabxqyb6w4kj5y4fwwkc47auxdothlqc7jpm3zbah5aamflvp7th3q",
88-
"id19sfcrra6z": "ocid1.compartment.oc1..aaaaaaaasdur4tm5apdm6qyapaba7apdiyv22n2mwt6zquyubqevk3uo7nha",
89-
}
90-
default_compartment = compartment_mapping.get(CONDA_BUCKET_NS)
91-
ODSC_MODEL_COMPARTMENT_OCID = (
92-
default_compartment
93-
if default_compartment
94-
else os.environ.get("ODSC_MODEL_COMPARTMENT_OCID")
95-
)
96-
9786

9887
def export(
9988
uri: Optional[str] = DEFAULT_CONFIG_PATH,

docs/source/release_notes.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,31 @@
22
Release Notes
33
=============
44

5+
2.11.6
6+
------
7+
Release date: April 3, 2024
8+
9+
* Fixed bugs and introduced enhancements following our recent release, which included internal adjustments for future features and updates for the Jupyter Lab 3 upgrade.
10+
11+
12+
2.11.5
13+
------
14+
Release date: March 25, 2024
15+
16+
* Fixed bugs and introduced enhancements following our recent release, which included internal adjustments for future features and updates for the Jupyter Lab 3 upgrade.
17+
18+
2.11.4
19+
------
20+
Release date: March 25, 2024
21+
22+
* Fixed bugs and introduced enhancements following our recent release, which included internal adjustments for future features and updates for the Jupyter Lab 3 upgrade.
23+
24+
2.11.3
25+
------
26+
Release date: March 22, 2024
27+
28+
* Fixed bugs and introduced enhancements following our recent release, which included internal adjustments for future features and updates for the Jupyter Lab 3 upgrade.
29+
530
2.11.2
631
------
732
Release date: March 21, 2024

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ build-backend = "flit_core.buildapi"
2121

2222
# Required
2323
name = "oracle_ads" # the install (PyPI) name; name for local build in [tool.flit.module] section below
24-
version = "2.11.2"
24+
version = "2.11.6"
2525

2626
# Optional
2727
description = "Oracle Accelerated Data Science SDK"

tests/unitary/with_extras/aqua/test_model.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,15 @@ def setUpClass(cls):
7878
os.environ["CONDA_BUCKET_NS"] = "test-namespace"
7979
os.environ["ODSC_MODEL_COMPARTMENT_OCID"] = TestDataset.SERVICE_COMPARTMENT_ID
8080
reload(ads.config)
81+
reload(ads.aqua)
8182
reload(ads.aqua.model)
8283

8384
@classmethod
8485
def tearDownClass(cls):
8586
os.environ.pop("CONDA_BUCKET_NS", None)
8687
os.environ.pop("ODSC_MODEL_COMPARTMENT_OCID", None)
8788
reload(ads.config)
89+
reload(ads.aqua)
8890
reload(ads.aqua.model)
8991

9092
def test_list_service_models(self):

0 commit comments

Comments
 (0)