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

Conversation

vikasray0208
Copy link
Member

@vikasray0208 vikasray0208 commented Jan 9, 2025

Description

This PR is intended to add/update the following changes in ADS in accordance with AQUA MS enhancements

  • Listing service and custom models
  • CRUD APIs for defined and custom metadata artifact

This PR will enable following changes

  • Service Model Listing: Enable the listing of service models without requiring the service compartment ID and cross-tenancy access.
  • Metadata Storage: Enable additional metadata store , such as license content, README.md, deployment config and fine-tuning config. Also, implement a search functionality for the license and keys from the README via RQS.

Example


ds_model=DataScienceModel.from_id("ocid1.datasciencemodel.oc1.iad.xxxxx")

# creating defined metadata artifact for key DeploymentConfiguration
ds_model.create_defined_metadata_artifact("DeploymentConfiguration",deployment_config_path,"local")

# Downloading the defined metadata artifact
ds_model.get_defined_metadata_artifact("DeploymentConfiguration",target_dir="/Users/path/to/local/folder")

Unit tests with latest preview oci sdk

Version: 2.142.1+preview.1.1

Screenshot 2025-03-05 at 2 57 42 AM

References

UPDATE:

public oci sdk has been released: https://github.com/oracle/oci-python-sdk/releases/tag/v2.148.0

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Jan 9, 2025
Copy link

github-actions bot commented Jan 9, 2025

📌 Cov diff with main:

Coverage-32%

📌 Overall coverage:

Coverage-19.72%

Copy link
Member

@VipulMascarenhas VipulMascarenhas left a comment

Choose a reason for hiding this comment

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

left some minor comments, overall looks good.

@vikasray0208 vikasray0208 dismissed VipulMascarenhas’s stale review January 10, 2025 19:13

The merge-base changed after approval.

Copy link

📌 Cov diff with main:

Coverage-60%

📌 Overall coverage:

Coverage-57.28%

mrDzurb
mrDzurb previously approved these changes Jan 11, 2025
Copy link

📌 Cov diff with main:

Coverage-45%

📌 Overall coverage:

Coverage-19.58%

Copy link

📌 Cov diff with main:

Coverage-45%

📌 Overall coverage:

Coverage-19.58%

@kumar-shivam-ranjan kumar-shivam-ranjan self-requested a review March 11, 2025 16:54
@@ -82,6 +85,14 @@
color=["teal", "blueviolet", "forestgreen", "peru", "y", "dodgerblue", "r"]
)


# Metadata artifact path type can be either local path or OSS path. It can also be the content itself.
class MetadataArtifactPathType(ExtendedEnum):
Copy link
Member

Choose a reason for hiding this comment

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

If the class will be used only within ads.models, then it might make sense to move it to the ads.models.common.utils.py?

Choose a reason for hiding this comment

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

Updated. Thanks!

Choose a reason for hiding this comment

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

Updated. Thanks!

@@ -212,6 +239,15 @@ def random_valid_ocid(prefix="ocid1.dataflowapplication.oc1.iad"):
return f"{left}.{fake}"


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)

if isinstance(key_value_map["value"], str):
try:
key_value_map["value"] = json.loads(oci_metadata_item.get("value"))
key_value_map["has_artifact"] = bool(
Copy link
Member

Choose a reason for hiding this comment

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

I think we should use some bool parser method for this?

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)

Choose a reason for hiding this comment

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

Updated. Thanks!

Copy link

📌 Cov diff with main:

Coverage-46%

📌 Overall coverage:

Coverage-19.58%


Returns
-------
Dict
Copy link
Member

Choose a reason for hiding this comment

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

Some of the comments in this file are still incorrect, for instance, the return type of this API is ModelMetadataArtifactDetails, notDict. Could you update all of them?

Choose a reason for hiding this comment

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

Updated. Thanks!

)

def get_custom_metadata_artifact(
self, metadata_key_name: str, target_dir: str, override: bool = False
Copy link
Member

Choose a reason for hiding this comment

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

Would it be better if we have some logic in this API to return the file_content directly if no target_dir is provided? @mrDzurb @mayoor

Copy link
Member

Choose a reason for hiding this comment

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

I like this idea, we can do this in both cases, even if the target_dir provided, we can still return the content.

Choose a reason for hiding this comment

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

Updated. Thanks!

Copy link

📌 Cov diff with main:

Coverage-73%

📌 Overall coverage:

Coverage-58.59%

Copy link

📌 Cov diff with main:

Coverage-71%

📌 Overall coverage:

Coverage-58.57%

Copy link

📌 Cov diff with main:

Coverage-71%

📌 Overall coverage:

Coverage-58.57%

@kumar-shivam-ranjan kumar-shivam-ranjan merged commit e7e3f19 into main Mar 12, 2025
20 of 21 checks passed
@@ -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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants