-
Notifications
You must be signed in to change notification settings - Fork 44
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
Feature/aqua ms changes #1019
base: main
Are you sure you want to change the base?
Feature/aqua ms changes #1019
Conversation
@@ -454,14 +454,16 @@ def kind(self) -> str: | |||
return "modelVersionSet" | |||
|
|||
@classmethod | |||
def list(cls, compartment_id: str = None, **kwargs) -> List["ModelVersionSet"]: | |||
def list(cls, compartment_id: str = None, category: str = "USER", **kwargs) -> List["ModelVersionSet"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move category to constants.
class ModelCategory (str, metaclass=ExtendedEnumMeta):
USER = "USER"
SERVICE = "SERVICE"
This variable is used across many modules.
@@ -1571,7 +1573,7 @@ def delete( | |||
|
|||
@classmethod | |||
def list( | |||
cls, compartment_id: str = None, project_id: str = None, **kwargs | |||
cls, compartment_id: str = None, project_id: str = None, category: str = "USER", **kwargs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move category to constants.
class ModelCategory (str, metaclass=ExtendedEnumMeta):
USER = "USER"
SERVICE = "SERVICE"
This variable is used across many modules.
) | ||
] | ||
|
||
@classmethod | ||
def list_df( | ||
cls, compartment_id: str = None, project_id: str = None, **kwargs | ||
cls, compartment_id: str = None, project_id: str = None, category: str = "USER", **kwargs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you install a pre-commit hook and validate the changed files with it. Internally we use ruff formatter.
@@ -2193,3 +2199,249 @@ def find_model_idx(): | |||
else: | |||
# model found case | |||
self.model_file_description["models"].pop(modelSearchIdx) | |||
|
|||
def create_custom_metadata_artifact(self, model_ocid: str, metadata_key_name: str, artifact_path: str) -> dict: | |||
"""Creates model custom metadata artifact for specified model. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add more description for this model. For example when this method needs to be used. Also check the parameters section, looks like there is some formatting issue.
Also it would be better if instead of dict
we return some dataclass or pydentic class.
from ads.common.serializer import DataClassSerializable
@dataclass
class MyClass():
attr1: Optional[str] = None
attr2: Optional[str] = None
OR
from pydantic import BaseModel
class MyClass(BaseModel):
attr1: Optional[str] = None
attr2: Optional[str] = None
artifact_path=artifact_path) | ||
|
||
|
||
def create_defined_metadata_artifact(self, model_ocid: str, metadata_key_name: str, artifact_path: str) -> dict: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't we have a one method and pass artifact type as a param?
def create_defined_metadata_artifact(..., type: str):
return self.dsc_model.create_defined_metadata_artifact(...)
metadata_key_name: str | ||
The name of the model metadatum in the metadata. | ||
|
||
artifact_path: str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose we will support only local paths, not OS bucket paths? If so, that needs to be mentioned in the pydocs.
artifact_file_path = os.path.join( | ||
target_dir, f"{metadata_key_name}" | ||
) | ||
with open(artifact_file_path, "wb") as _file: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the file with the given name already exists? We should allow user to override existing files and fail if they didn't set override param to True, by default it should be false.
@@ -454,14 +454,16 @@ def kind(self) -> str: | |||
return "modelVersionSet" | |||
|
|||
@classmethod | |||
def list(cls, compartment_id: str = None, **kwargs) -> List["ModelVersionSet"]: | |||
def list(cls, compartment_id: str = None, category: str = "USER", **kwargs) -> List["ModelVersionSet"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create will continue working without changes, right?
@@ -89,6 +92,12 @@ def wrapper(self, *args, **kwargs): | |||
return decorator | |||
|
|||
|
|||
def convert_response_to_dict(headers:dict,status:int): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See one of the comments above, it would be better to use dataclass or pydentic class for this.
@@ -596,3 +605,331 @@ def is_model_by_reference(self): | |||
): | |||
return True | |||
return False | |||
|
|||
def create_custom_metadata_artifact(self, model_ocid: str, metadata_key_name: str, artifact_path: str) -> dict: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See one of the comments above. Why do we need two methods for creating artifacts? Custom and Defined can be combined?
Please use pre-commit hook to format changed files. Also we use ruff plugin to autoformat and validate code. |
) | ||
with open(artifact_file_path, "wb") as _file: | ||
_file.write(file_content) | ||
print(f"Artifact downloaded to location - {artifact_file_path}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use logger instead of print throughout the PR
|
||
Parameters | ||
---------- | ||
model_ocid: str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need to accept model_ocid as input for these functions, can we use the self.id
property instead?
contents = f.read() | ||
print(contents) | ||
|
||
response = self.client.create_model_custom_metadatum_artifact(model_ocid, metadata_key_name, contents, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we do some validation of contents here to avoid incorrect values/data resulting in service errors?
try: | ||
return self.client.get_model_custom_metadatum_artifact_content(model_ocid, metadata_key_name).data.content | ||
except ServiceError as ex: | ||
if ex.status == 404: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we log error here and return the message as well with ModelMetadataArtifactNotFoundError
?
@vikasray0208 can you update the screenshots and hide/obfuscate the ocids and namespaces? |
This Pull Request is for adding/updating API for listing SMM ,Model custom and defined metadata artifact in DataScienceModel in ADS.
This PR will enable following changes
API Spec :- https://confluence.oci.oraclecorp.com/pages/viewpage.action?spaceKey=ODSC&title=API+changes+for+Model+store+for+Aqua
Design Doc :- https://confluence.oci.oraclecorp.com/display/ODSC/Model+Store+Enhancements+For+AQUA+-+Design