Skip to content

Commit 9b17284

Browse files
Updating get_metadata_content to have same local/oss path logic
1 parent d6b56c0 commit 9b17284

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

ads/model/service/oci_datascience_model.py

+8-14
Original file line numberDiff line numberDiff line change
@@ -645,23 +645,17 @@ def get_metadata_content(
645645
if path_type == MetadataArtifactPathType.CONTENT:
646646
return artifact_path_or_content
647647

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:
648+
elif (
649+
path_type == MetadataArtifactPathType.LOCAL
650+
or path_type == MetadataArtifactPathType.OSS
651+
):
661652
if not utils.is_path_exists(artifact_path_or_content):
662653
raise FileNotFoundError(f"File not found: {artifact_path_or_content}")
654+
signer = (
655+
default_signer() if path_type == MetadataArtifactPathType.OSS else {}
656+
)
663657
contents = read_file(
664-
file_path=artifact_path_or_content, auth=default_signer()
658+
file_path=artifact_path_or_content, auth=signer
665659
).encode()
666660
logger.debug(f"The metadata artifact content - {contents}")
667661

0 commit comments

Comments
 (0)