-
Notifications
You must be signed in to change notification settings - Fork 46
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
[DRCC] Create and Update Metadata artifact content changes #1129
Conversation
ads/model/datascience_model.py
Outdated
@@ -2442,7 +2498,7 @@ def get_custom_metadata_artifact( | |||
) | |||
artifact_file_path = os.path.join(target_dir, f"{metadata_key_name}") | |||
|
|||
if not override and os.path.exists(artifact_file_path): | |||
if not override and is_path_exists(artifact_file_path): | |||
raise FileExistsError(f"File already exists: {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.
Should we say to use the override param to override?
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.
Yes we can. Will update the error message.
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.
Updated.
contents = str( | ||
read_file(file_path=artifact_path_or_content, auth=default_signer()) | ||
) | ||
contents = read_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.
just curious, why do we want to distinguish between local and OSS? Can't we use the same logic for both?
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 didn't want to change the read_file
function defintion in ads.common.utils
since it is already used in many other places.
read_file returns string content of the file and we need bytes.
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.
Now , if think we could have used same logic though without changing read_file function definition.
Updated it. Thanks!
@mrDzurb
self, artifact_path_or_content: str, path_type: MetadataArtifactPathType | ||
self, | ||
artifact_path_or_content: Union[str, bytes], | ||
path_type: MetadataArtifactPathType, | ||
): |
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 add a return statement here to be more clear:
def get_metadata_content(
self,
artifact_path_or_content: Union[str, bytes],
path_type: MetadataArtifactPathType,
) -> Union[str, bytes]:
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.
get_metadata_content
always returns bytes. Updated. Thanks!
Description
This PR is intended to improve API for creating and updating metadata artifact which was introduced as part of MS enhancements.
Issue
While uploading metadata artifact , the type of content should always be bytes. Earlier it was both bytes and strings.
Example
When uploading the content via local path
When uploading the content via OSS path
When uploading the content itself
Unit tests