Skip to content

Commit 0cf4aa2

Browse files
Merge branch 'main' into aqua/ADS_MS_changes
2 parents 741067d + ba5fb25 commit 0cf4aa2

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

ads/model/datascience_model.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2528,7 +2528,9 @@ def get_custom_metadata_artifact(
25282528
artifact_file_path = os.path.join(target_dir, f"{metadata_key_name}")
25292529

25302530
if not override and is_path_exists(artifact_file_path):
2531-
raise FileExistsError(f"File already exists: {artifact_file_path}")
2531+
raise FileExistsError(
2532+
f"File already exists: {artifact_file_path}. Please use boolean override parameter to override the file content."
2533+
)
25322534

25332535
with open(artifact_file_path, "wb") as _file:
25342536
_file.write(file_content)
@@ -2567,7 +2569,9 @@ def get_defined_metadata_artifact(
25672569
artifact_file_path = os.path.join(target_dir, f"{metadata_key_name}")
25682570

25692571
if not override and is_path_exists(artifact_file_path):
2570-
raise FileExistsError(f"File already exists: {artifact_file_path}")
2572+
raise FileExistsError(
2573+
f"File already exists: {artifact_file_path}. Please use boolean override parameter to override the file content."
2574+
)
25712575

25722576
with open(artifact_file_path, "wb") as _file:
25732577
_file.write(file_content)

ads/model/service/oci_datascience_model.py

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ def get_metadata_content(
624624
self,
625625
artifact_path_or_content: Union[str, bytes],
626626
path_type: MetadataArtifactPathType,
627-
):
627+
) -> bytes:
628628
"""
629629
returns the content of the metadata artifact
630630
@@ -639,29 +639,24 @@ def get_metadata_content(
639639
640640
Returns
641641
-------
642-
metadata artifact content
642+
bytes
643+
metadata artifact content in bytes
643644
"""
644645

645646
if path_type == MetadataArtifactPathType.CONTENT:
646647
return artifact_path_or_content
647648

648-
elif path_type == MetadataArtifactPathType.LOCAL:
649-
if not utils.is_path_exists(artifact_path_or_content):
650-
raise FileNotFoundError(
651-
f"File not found: {artifact_path_or_content} . "
652-
)
653-
654-
with open(artifact_path_or_content, "rb") as f:
655-
contents = f.read()
656-
logger.info(f"The metadata artifact content - {contents}")
657-
658-
return contents
659-
660-
elif path_type == MetadataArtifactPathType.OSS:
649+
elif (
650+
path_type == MetadataArtifactPathType.LOCAL
651+
or path_type == MetadataArtifactPathType.OSS
652+
):
661653
if not utils.is_path_exists(artifact_path_or_content):
662654
raise FileNotFoundError(f"File not found: {artifact_path_or_content}")
655+
signer = (
656+
default_signer() if path_type == MetadataArtifactPathType.OSS else {}
657+
)
663658
contents = read_file(
664-
file_path=artifact_path_or_content, auth=default_signer()
659+
file_path=artifact_path_or_content, auth=signer
665660
).encode()
666661
logger.debug(f"The metadata artifact content - {contents}")
667662

0 commit comments

Comments
 (0)