Skip to content

Commit aea2791

Browse files
committed
Update jobs serializer.py
1 parent ed0694f commit aea2791

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

ads/jobs/serializer.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import fsspec
1212
import yaml
13+
from ads.common.auth import default_signer
1314

1415
Self = TypeVar("Self", bound="Serializable")
1516
"""Special type to represent the current enclosed class.
@@ -88,6 +89,14 @@ def _read_from_file(uri: str, **kwargs) -> str:
8889
str
8990
The content of the file as a string.
9091
"""
92+
# Add default signer if the uri is an object storage uri, and
93+
# the user does not specify config or signer.
94+
if (
95+
uri.startswith("oci://")
96+
and "config" not in kwargs
97+
and "signer" not in kwargs
98+
):
99+
kwargs.update(default_signer())
91100
with fsspec.open(uri, "r", **kwargs) as f:
92101
return f.read()
93102

@@ -127,7 +136,7 @@ def from_json(
127136
json_string: str = None,
128137
uri: str = None,
129138
decoder: callable = json.JSONDecoder,
130-
**kwargs
139+
**kwargs,
131140
) -> Self:
132141
"""Creates an object from JSON string provided or from URI location containing JSON string
133142
@@ -216,7 +225,7 @@ def from_yaml(
216225
yaml_string: str = None,
217226
uri: str = None,
218227
loader: callable = yaml.SafeLoader,
219-
**kwargs
228+
**kwargs,
220229
) -> Self:
221230
"""Initializes an object from YAML string or URI location containing the YAML
222231
@@ -252,7 +261,7 @@ def from_string(
252261
obj_string: str = None,
253262
uri: str = None,
254263
loader: callable = yaml.SafeLoader,
255-
**kwargs
264+
**kwargs,
256265
) -> Self:
257266
"""Initializes an object from YAML/JSON string or URI location containing the YAML/JSON
258267

0 commit comments

Comments
 (0)