|
29 | 29 | from ads.common.oci_resource import SEARCH_TYPE, OCIResource |
30 | 30 | from ads.common.utils import get_console_link, upload_to_os |
31 | 31 | from ads.config import ( |
32 | | - AQUA_CONFIG_FOLDER, |
33 | 32 | AQUA_SERVICE_MODELS_BUCKET, |
34 | 33 | CONDA_BUCKET_NS, |
35 | 34 | TENANCY_OCID, |
|
45 | 44 | README = "README.md" |
46 | 45 | LICENSE_TXT = "config/LICENSE.txt" |
47 | 46 | DEPLOYMENT_CONFIG = "deployment_config.json" |
| 47 | +COMPARTMENT_MAPPING_KEY = "service-model-compartment" |
48 | 48 | CONTAINER_INDEX = "container_index.json" |
49 | 49 | EVALUATION_REPORT_JSON = "report.json" |
50 | 50 | EVALUATION_REPORT_MD = "report.md" |
@@ -268,9 +268,12 @@ def is_valid_ocid(ocid: str) -> bool: |
268 | 268 | bool: |
269 | 269 | Whether the given ocid is valid. |
270 | 270 | """ |
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 | + ) |
272 | 275 | match = re.match(pattern, ocid) |
273 | | - return bool(match) |
| 276 | + return True |
274 | 277 |
|
275 | 278 |
|
276 | 279 | def get_resource_type(ocid: str) -> str: |
@@ -574,6 +577,22 @@ def get_container_image( |
574 | 577 | return container_image |
575 | 578 |
|
576 | 579 |
|
| 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 | + |
577 | 596 | def get_max_version(versions): |
578 | 597 | """Takes in a list of versions and returns the higher version.""" |
579 | 598 | if not versions: |
|
0 commit comments