|
10 | 10 |
|
11 | 11 | import fsspec |
12 | 12 | import yaml |
| 13 | +from ads.common.auth import default_signer |
13 | 14 |
|
14 | 15 | Self = TypeVar("Self", bound="Serializable") |
15 | 16 | """Special type to represent the current enclosed class. |
@@ -88,6 +89,14 @@ def _read_from_file(uri: str, **kwargs) -> str: |
88 | 89 | str |
89 | 90 | The content of the file as a string. |
90 | 91 | """ |
| 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()) |
91 | 100 | with fsspec.open(uri, "r", **kwargs) as f: |
92 | 101 | return f.read() |
93 | 102 |
|
@@ -127,7 +136,7 @@ def from_json( |
127 | 136 | json_string: str = None, |
128 | 137 | uri: str = None, |
129 | 138 | decoder: callable = json.JSONDecoder, |
130 | | - **kwargs |
| 139 | + **kwargs, |
131 | 140 | ) -> Self: |
132 | 141 | """Creates an object from JSON string provided or from URI location containing JSON string |
133 | 142 |
|
@@ -216,7 +225,7 @@ def from_yaml( |
216 | 225 | yaml_string: str = None, |
217 | 226 | uri: str = None, |
218 | 227 | loader: callable = yaml.SafeLoader, |
219 | | - **kwargs |
| 228 | + **kwargs, |
220 | 229 | ) -> Self: |
221 | 230 | """Initializes an object from YAML string or URI location containing the YAML |
222 | 231 |
|
@@ -252,7 +261,7 @@ def from_string( |
252 | 261 | obj_string: str = None, |
253 | 262 | uri: str = None, |
254 | 263 | loader: callable = yaml.SafeLoader, |
255 | | - **kwargs |
| 264 | + **kwargs, |
256 | 265 | ) -> Self: |
257 | 266 | """Initializes an object from YAML/JSON string or URI location containing the YAML/JSON |
258 | 267 |
|
|
0 commit comments