Skip to content

ADS changes for MS enhancements #1036

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

Merged
merged 61 commits into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
d681e17
Added methods for aqua-model store apis change
vikasray0208 Dec 2, 2024
77783ce
update modela and mvs list api
vikasray0208 Dec 5, 2024
804d17f
update the test file
vikasray0208 Jan 9, 2025
09f2f9b
addressed review comments
vikasray0208 Jan 9, 2025
3dd7b85
fix unit test
vikasray0208 Jan 9, 2025
0aa0df0
addressed review comments
vikasray0208 Jan 10, 2025
663e7b2
fix unit test erro
vikasray0208 Jan 10, 2025
8f7da9e
Added methods for aqua-model store apis change
vikasray0208 Dec 2, 2024
9207cce
update modela and mvs list api
vikasray0208 Dec 5, 2024
32d5695
update the test file
vikasray0208 Jan 9, 2025
446df19
addressed review comments
vikasray0208 Jan 9, 2025
0ea9c9d
fix unit test
vikasray0208 Jan 9, 2025
44e04bd
addressed review comments
vikasray0208 Jan 10, 2025
bae144e
fix unit test erro
vikasray0208 Jan 10, 2025
db59823
Merge remote-tracking branch 'origin/feature/aqua_ms_changes_2' into …
vikasray0208 Jan 10, 2025
ca4b8c9
Merge branch 'main' into feature/aqua_ms_changes_2
VipulMascarenhas Jan 10, 2025
eb3bb86
Merge branch 'main' into feature/aqua_ms_changes_2
VipulMascarenhas Jan 16, 2025
b8cb9b8
Merge branch 'main' into feature/aqua_ms_changes_2
VipulMascarenhas Jan 22, 2025
19c98cf
DataScience.from_id() for ms enchancements changes
kumar-shivam-ranjan Feb 12, 2025
2a8e4b7
Addressing review comments
kumar-shivam-ranjan Feb 13, 2025
68bcdf5
Resolving conflicts
kumar-shivam-ranjan Feb 13, 2025
0f53a8d
Updating doc string
kumar-shivam-ranjan Feb 13, 2025
d15ec0b
Resolving merge conflicts
kumar-shivam-ranjan Feb 14, 2025
4d60946
Adding back license and readme defined metadata keys
kumar-shivam-ranjan Feb 17, 2025
be3c617
Merge branch 'main' into feature/aqua_ms_changes_2
kumar-shivam-ranjan Feb 17, 2025
01e040d
Fixing UTs
kumar-shivam-ranjan Feb 17, 2025
7238c2e
Fixing UTs
kumar-shivam-ranjan Feb 17, 2025
fabb268
Extended metadata artifact apis to include oss path and content
kumar-shivam-ranjan Feb 17, 2025
134d6c5
Addressing Deployment and FT config defined metadata APIs
kumar-shivam-ranjan Feb 18, 2025
c58b2f5
Merge branch 'main' into feature/aqua_ms_changes_2
kumar-shivam-ranjan Feb 18, 2025
87dfe13
Merge branch 'main' into feature/aqua_ms_changes_2
mrDzurb Feb 20, 2025
c1020f8
Addressing review comments
kumar-shivam-ranjan Feb 25, 2025
f0091cc
Merge branch 'main' into feature/aqua_ms_changes_2
kumar-shivam-ranjan Feb 25, 2025
05e7813
Converting BytesIO to bytes
kumar-shivam-ranjan Mar 3, 2025
1784b42
Merge branch 'main' into feature/aqua_ms_changes_2
kumar-shivam-ranjan Mar 3, 2025
5b1207d
Reverting
kumar-shivam-ranjan Mar 3, 2025
5eb496e
Adding has_artifact field in model metadata ads
kumar-shivam-ranjan Mar 4, 2025
4cc32ad
Adding has_artifact field in model metadata ads
kumar-shivam-ranjan Mar 4, 2025
5c2d6e6
Updating bytes content variable name
kumar-shivam-ranjan Mar 4, 2025
cd3dd8a
Fixing UTs
kumar-shivam-ranjan Mar 4, 2025
6321fa8
Merge branch 'main' into feature/aqua_ms_changes_2
kumar-shivam-ranjan Mar 4, 2025
1a0484e
Rebasing
kumar-shivam-ranjan Mar 4, 2025
ead6753
Updating doc
kumar-shivam-ranjan Mar 5, 2025
f917ee7
Updating has_artifact field in ADS
kumar-shivam-ranjan Mar 10, 2025
f847ca3
Updating has_artifact field in ADS
kumar-shivam-ranjan Mar 10, 2025
e05cbf3
Updating update method for defined and custom metadata list
kumar-shivam-ranjan Mar 10, 2025
d8bab8a
Addressing review comments
kumar-shivam-ranjan Mar 10, 2025
0813099
Addressing review comments
kumar-shivam-ranjan Mar 10, 2025
c1b1b96
Merge branch 'main' into feature/aqua_ms_changes_2
kumar-shivam-ranjan Mar 10, 2025
1b87417
Merge branch 'main' into feature/aqua_ms_changes_2
kumar-shivam-ranjan Mar 11, 2025
40456fe
Reverting unwanted changes pushed by mistake
kumar-shivam-ranjan Mar 11, 2025
45e9014
Addressing review comments
kumar-shivam-ranjan Mar 11, 2025
782839f
Fixing UTs
kumar-shivam-ranjan Mar 11, 2025
aabbb98
Adding bool parser
kumar-shivam-ranjan Mar 11, 2025
b4999d0
Fixing UTs
kumar-shivam-ranjan Mar 11, 2025
192248a
Merge branch 'main' into feature/aqua_ms_changes_2
kumar-shivam-ranjan Mar 11, 2025
54296f1
Addressing review comments
kumar-shivam-ranjan Mar 11, 2025
39763e9
Addressing review comments
kumar-shivam-ranjan Mar 11, 2025
2eb12a3
Updating BytesIO to bytes
kumar-shivam-ranjan Mar 11, 2025
e414716
Adding path directory validation
kumar-shivam-ranjan Mar 12, 2025
5ef6f12
Merge branch 'main' into feature/aqua_ms_changes_2
kumar-shivam-ranjan Mar 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions ads/aqua/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@
is_valid_ocid,
load_config,
)
from ads.aqua.constants import UNKNOWN
from ads.common import oci_client as oc
from ads.common.auth import default_signer
from ads.common.utils import extract_region, is_path_exists
from ads.common.utils import UNKNOWN, extract_region, is_path_exists
from ads.config import (
AQUA_TELEMETRY_BUCKET,
AQUA_TELEMETRY_BUCKET_NS,
Expand Down
19 changes: 7 additions & 12 deletions ads/aqua/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from string import Template
from typing import List, Union

import fsspec
import oci
from cachetools import TTLCache, cached
from huggingface_hub.constants import HF_HUB_CACHE
Expand Down Expand Up @@ -58,7 +57,6 @@
SUPPORTED_FILE_FORMATS,
TEI_CONTAINER_DEFAULT_HOST,
TGI_INFERENCE_RESTRICTED_PARAMS,
UNKNOWN,
UNKNOWN_JSON_STR,
VLLM_INFERENCE_RESTRICTED_PARAMS,
)
Expand All @@ -68,7 +66,13 @@
from ads.common.extended_enum import ExtendedEnum
from ads.common.object_storage_details import ObjectStorageDetails
from ads.common.oci_resource import SEARCH_TYPE, OCIResource
from ads.common.utils import copy_file, get_console_link, upload_to_os
from ads.common.utils import (
UNKNOWN,
copy_file,
get_console_link,
read_file,
upload_to_os,
)
from ads.config import (
AQUA_MODEL_DEPLOYMENT_FOLDER,
AQUA_SERVICE_MODELS_BUCKET,
Expand Down Expand Up @@ -228,15 +232,6 @@ def get_artifact_path(custom_metadata_list: List) -> str:
return UNKNOWN


def read_file(file_path: str, **kwargs) -> str:
try:
with fsspec.open(file_path, "r", **kwargs.get("auth", {})) as f:
return f.read()
except Exception as e:
logger.debug(f"Failed to read file {file_path}. {e}")
return UNKNOWN


@threaded()
def load_config(file_path: str, config_file_name: str, **kwargs) -> dict:
artifact_path = f"{file_path.rstrip('/')}/{config_file_name}"
Expand Down
1 change: 0 additions & 1 deletion ads/aqua/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
"""This module defines constants used in ads.aqua module."""

UNKNOWN = ""
Copy link
Member

@lu-ohai lu-ohai Mar 12, 2025

Choose a reason for hiding this comment

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

Why do we remove UNKNOWN here, it causes some error in feature/multi_model_deploy branch. I'll add it back to the corresponding pr. @mrDzurb

Copy link
Member

@kumar-shivam-ranjan kumar-shivam-ranjan Mar 13, 2025

Choose a reason for hiding this comment

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

It was moved to ads.common.utils since this function was moved to ads.common.utils to avoid circular imports

def read_file(file_path: str, **kwargs) -> str:
    try:
        with fsspec.open(file_path, "r", **kwargs.get("auth", {})) as f:
            return f.read()
    except Exception as e:
        logger.debug(f"Failed to read file {file_path}. {e}")
        return UNKNOWN

Choose a reason for hiding this comment

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

Since this is a generic function , it was adviced to move this to ads.common.utils

UNKNOWN_VALUE = ""
READY_TO_IMPORT_STATUS = "TRUE"
UNKNOWN_DICT = {}
Expand Down
3 changes: 1 addition & 2 deletions ads/aqua/evaluation/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
JOB_INFRASTRUCTURE_TYPE_DEFAULT_NETWORKING,
LIFECYCLE_DETAILS_MISSING_JOBRUN,
NB_SESSION_IDENTIFIER,
UNKNOWN,
)
from ads.aqua.evaluation.constants import (
EVAL_TERMINATION_STATE,
Expand All @@ -79,7 +78,7 @@
from ads.aqua.evaluation.errors import EVALUATION_JOB_EXIT_CODE_MESSAGE
from ads.common.auth import default_signer
from ads.common.object_storage_details import ObjectStorageDetails
from ads.common.utils import get_console_link, get_files, get_log_links
from ads.common.utils import UNKNOWN, get_console_link, get_files, get_log_links
from ads.config import (
AQUA_JOB_SUBNET_ID,
COMPARTMENT_OCID,
Expand Down
3 changes: 1 addition & 2 deletions ads/aqua/finetuning/finetuning.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
DEFAULT_FT_REPLICA,
DEFAULT_FT_VALIDATION_SET_SIZE,
JOB_INFRASTRUCTURE_TYPE_DEFAULT_NETWORKING,
UNKNOWN,
UNKNOWN_DICT,
)
from ads.aqua.data import AquaResourceIdentifier
Expand All @@ -45,7 +44,7 @@
)
from ads.common.auth import default_signer
from ads.common.object_storage_details import ObjectStorageDetails
from ads.common.utils import get_console_link
from ads.common.utils import UNKNOWN, get_console_link
from ads.config import (
AQUA_FINETUNING_CONTAINER_OVERRIDE_FLAG_METADATA_NAME,
AQUA_JOB_SUBNET_ID,
Expand Down
3 changes: 1 addition & 2 deletions ads/aqua/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
READY_TO_IMPORT_STATUS,
TRAINING_METRICS_FINAL,
TRINING_METRICS,
UNKNOWN,
VALIDATION_METRICS,
VALIDATION_METRICS_FINAL,
)
Expand All @@ -80,7 +79,7 @@
)
from ads.common.auth import default_signer
from ads.common.oci_resource import SEARCH_TYPE, OCIResource
from ads.common.utils import get_console_link
from ads.common.utils import UNKNOWN, get_console_link
from ads.config import (
AQUA_DEPLOYMENT_CONTAINER_CMD_VAR_METADATA_NAME,
AQUA_DEPLOYMENT_CONTAINER_METADATA_NAME,
Expand Down
3 changes: 1 addition & 2 deletions ads/aqua/modeldeployment/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@
AQUA_MODEL_TYPE_CUSTOM,
AQUA_MODEL_TYPE_SERVICE,
MODEL_BY_REFERENCE_OSS_PATH_KEY,
UNKNOWN,
UNKNOWN_DICT,
)
from ads.aqua.data import AquaResourceIdentifier
from ads.aqua.finetuning.finetuning import FineTuneCustomMetadata
from ads.aqua.model import AquaModelApp
from ads.aqua.modeldeployment.entities import AquaDeployment, AquaDeploymentDetail
from ads.common.object_storage_details import ObjectStorageDetails
from ads.common.utils import get_log_links
from ads.common.utils import UNKNOWN, get_log_links
from ads.config import (
AQUA_DEPLOYMENT_CONTAINER_CMD_VAR_METADATA_NAME,
AQUA_DEPLOYMENT_CONTAINER_METADATA_NAME,
Expand Down
4 changes: 2 additions & 2 deletions ads/aqua/modeldeployment/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
)

from ads.aqua.common.enums import Tags
from ads.aqua.constants import UNKNOWN, UNKNOWN_DICT
from ads.aqua.constants import UNKNOWN_DICT
from ads.aqua.data import AquaResourceIdentifier
from ads.common.serializer import DataClassSerializable
from ads.common.utils import get_console_link
from ads.common.utils import UNKNOWN, get_console_link


@dataclass
Expand Down
52 changes: 51 additions & 1 deletion ads/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from enum import Enum
from io import DEFAULT_BUFFER_SIZE
from textwrap import fill
from typing import Dict, Optional, Tuple, Union
from typing import Any, Dict, Optional, Tuple, Union
from urllib import request
from urllib.parse import urlparse

Expand Down Expand Up @@ -63,6 +63,8 @@
# Maximum distinct values by cardinality will be used for plotting
MAX_DISPLAY_VALUES = 10

UNKNOWN = ""

# par link of the index json file.
PAR_LINK = "https://objectstorage.us-ashburn-1.oraclecloud.com/p/WyjtfVIG0uda-P3-2FmAfwaLlXYQZbvPZmfX1qg0-sbkwEQO6jpwabGr2hMDBmBp/n/ociodscdev/b/service-conda-packs/o/service_pack/index.json"

Expand All @@ -82,6 +84,7 @@
color=["teal", "blueviolet", "forestgreen", "peru", "y", "dodgerblue", "r"]
)


# sqlalchemy engines
_engines = {}

Expand Down Expand Up @@ -149,6 +152,22 @@ def oci_key_location():
)


def text_sanitizer(content):
if isinstance(content, str):
return (
content.replace("“", '"')
.replace("”", '"')
.replace("’", "'")
.replace("‘", "'")
.replace("—", "-")
.encode("utf-8", "ignore")
.decode("utf-8", "ignore")
)
if isinstance(content, dict):
return json.dumps(content)
return str(content)


@deprecated(
"2.5.10",
details="Deprecated, use: from ads.common.auth import AuthState; AuthState().oci_config_path",
Expand Down Expand Up @@ -212,6 +231,37 @@ def random_valid_ocid(prefix="ocid1.dataflowapplication.oc1.iad"):
return f"{left}.{fake}"


def parse_bool(value: Any) -> bool:
"""
Converts a value to boolean. For strings, it interprets 'true', '1', or 'yes'
(case insensitive) as True; everything else as False.

Parameters
----------
value : Any
The value to convert to boolean.

Returns
-------
bool
The boolean interpretation of the value.
"""
if isinstance(value, bool):
return value
if isinstance(value, str):
return value.strip().lower() in ("true", "1", "yes")
return bool(value)


def read_file(file_path: str, **kwargs) -> str:
Copy link
Member

Choose a reason for hiding this comment

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

Could you double check, we might already have something similar in common utils

Choose a reason for hiding this comment

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

I didn't create this function , just moved it from ads.aqua.common.utils to ads.common.utils due to circular import issue.
Link to the comment: #1036 (comment)

try:
with fsspec.open(file_path, "r", **kwargs.get("auth", {})) as f:
return f.read()
except Exception as e:
logger.debug(f"Failed to read file {file_path}. {e}")
return UNKNOWN


def get_dataframe_styles(max_width=75):
"""Styles used for dataframe, example usage:

Expand Down
3 changes: 3 additions & 0 deletions ads/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@
DEBUG_TELEMETRY = os.environ.get("DEBUG_TELEMETRY", None)
AQUA_SERVICE_NAME = "aqua"
DATA_SCIENCE_SERVICE_NAME = "data-science"
USER = "USER"
SERVICE = "SERVICE"



THREADED_DEFAULT_TIMEOUT = 5
Expand Down
18 changes: 15 additions & 3 deletions ads/model/common/utils.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*--

# Copyright (c) 2022, 2023 Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/

import json
import os
import tempfile
import yaml
from typing import Any, Dict, Optional
from zipfile import ZipFile
from ads.common import utils

import yaml

from ads.common import utils
from ads.common.extended_enum import ExtendedEnum

DEPRECATE_AS_ONNX_WARNING = "This attribute `as_onnx` will be deprecated in the future. You can choose specific format by setting `model_save_serializer`."
DEPRECATE_USE_TORCH_SCRIPT_WARNING = "This attribute `use_torch_script` will be deprecated in the future. You can choose specific format by setting `model_save_serializer`."


class MetadataArtifactPathType(ExtendedEnum):
"""
Enum for defining metadata artifact path type.
Can be either local path or OSS path. It can also be the content itself.
"""

LOCAL = "local"
OSS = "oss"
CONTENT = "content"


def _extract_locals(
locals: Dict[str, Any], filter_out_nulls: Optional[bool] = True
) -> Dict[str, Any]:
Expand Down
Loading
Loading