@@ -495,9 +495,7 @@ def print_user_message(
495495 )
496496
497497 if is_documentation_mode () and is_notebook ():
498-
499498 if display_type .lower () == "tip" :
500-
501499 if "\n " in msg :
502500 t = "<b>{}:</b>" .format (title .upper ().strip ()) if title else ""
503501
@@ -567,7 +565,6 @@ def print_user_message(
567565 )
568566
569567 elif display_type .startswith ("info" ):
570-
571568 user_message = msg .strip ().replace ("\n " , "<br>" )
572569
573570 if see_also_links :
@@ -640,7 +637,6 @@ def ellipsis_strings(raw, n=24):
640637
641638 result = []
642639 for s in sequence :
643-
644640 if len (str (s )) <= n :
645641 result .append (s )
646642 else :
@@ -1136,36 +1132,44 @@ def is_data_too_wide(
11361132 return col_num > max_col_num
11371133
11381134
1139- def get_files (directory : str ):
1135+ def get_files (directory : str , auth : Optional [ Dict ] = None ):
11401136 """List out all the file names under this directory.
11411137
11421138 Parameters
11431139 ----------
11441140 directory: str
11451141 The directory to list out all the files from.
1142+ auth: (Dict, optional). Defaults to None.
1143+ The default authentication is set using `ads.set_auth` API. If you need to override the
1144+ default, use the `ads.common.auth.api_keys` or `ads.common.auth.resource_principal` to create appropriate
1145+ authentication signer and kwargs required to instantiate IdentityClient object.
11461146
11471147 Returns
11481148 -------
11491149 List
11501150 List of the files in the directory.
11511151 """
11521152 directory = directory .rstrip ("/" )
1153- if os .path .exists (os .path .join (directory , ".model-ignore" )):
1154- ignore_patterns = (
1155- Path (os .path .join (directory ), ".model-ignore" )
1156- .read_text ()
1157- .strip ()
1158- .split ("\n " )
1159- )
1153+ path_scheme = urlparse (directory ).scheme or "file"
1154+ storage_options = auth or authutil .default_signer ()
1155+ model_ignore_path = os .path .join (directory , ".model-ignore" )
1156+ if is_path_exists (model_ignore_path , auth = auth ):
1157+ with fsspec .open (model_ignore_path , "r" , ** storage_options ) as f :
1158+ ignore_patterns = f .read ().strip ().split ("\n " )
11601159 else :
11611160 ignore_patterns = []
11621161 file_names = []
1163- for root , dirs , files in os .walk (directory ):
1162+ fs = fsspec .filesystem (path_scheme , ** storage_options )
1163+ for root , dirs , files in fs .walk (directory ):
11641164 for name in files :
11651165 file_names .append (os .path .join (root , name ))
11661166 for name in dirs :
11671167 file_names .append (os .path .join (root , name ))
11681168
1169+ # return all files in remote directory.
1170+ if directory .startswith ("oci://" ):
1171+ directory = directory .lstrip ("oci://" )
1172+
11691173 for ignore in ignore_patterns :
11701174 if not ignore .startswith ("#" ) and ignore .strip () != "" :
11711175 matches = []
@@ -1228,7 +1232,7 @@ def copy_from_uri(
12281232 force_overwrite: (bool, optional). Defaults to False.
12291233 Whether to overwrite existing files or not.
12301234 auth: (Dict, optional). Defaults to None.
1231- The default authetication is set using `ads.set_auth` API. If you need to override the
1235+ The default authentication is set using `ads.set_auth` API. If you need to override the
12321236 default, use the `ads.common.auth.api_keys` or `ads.common.auth.resource_principal` to create appropriate
12331237 authentication signer and kwargs required to instantiate IdentityClient object.
12341238
@@ -1294,7 +1298,7 @@ def copy_file(
12941298 force_overwrite: (bool, optional). Defaults to False.
12951299 Whether to overwrite existing files or not.
12961300 auth: (Dict, optional). Defaults to None.
1297- The default authetication is set using `ads.set_auth` API. If you need to override the
1301+ The default authentication is set using `ads.set_auth` API. If you need to override the
12981302 default, use the `ads.common.auth.api_keys` or `ads.common.auth.resource_principal` to create appropriate
12991303 authentication signer and kwargs required to instantiate IdentityClient object.
13001304 chunk_size: (int, optinal). Defaults to `DEFAULT_BUFFER_SIZE`
@@ -1357,7 +1361,7 @@ def remove_file(file_path: str, auth: Optional[Dict] = None) -> None:
13571361 file_path: str
13581362 The path of the source file, which can be local path or OCI object storage URI.
13591363 auth: (Dict, optional). Defaults to None.
1360- The default authetication is set using `ads.set_auth` API. If you need to override the
1364+ The default authentication is set using `ads.set_auth` API. If you need to override the
13611365 default, use the `ads.common.auth.api_keys` or `ads.common.auth.resource_principal` to create appropriate
13621366 authentication signer and kwargs required to instantiate IdentityClient object.
13631367
@@ -1570,3 +1574,26 @@ def extract_region(auth: Optional[Dict] = None) -> Union[str, None]:
15701574 pass
15711575
15721576 return None
1577+
1578+
1579+ def is_path_exists (uri : str , auth : Optional [Dict ] = None ) -> bool :
1580+ """Check if the given path which can be local path or OCI object storage URI exists.
1581+
1582+ Parameters
1583+ ----------
1584+ uri: str
1585+ The URI of the target, which can be local path or OCI object storage URI.
1586+ auth: (Dict, optional). Defaults to None.
1587+ The default authentication is set using `ads.set_auth` API. If you need to override the
1588+ default, use the `ads.common.auth.api_keys` or `ads.common.auth.resource_principal` to create appropriate
1589+ authentication signer and kwargs required to instantiate IdentityClient object.
1590+
1591+ Returns
1592+ -------
1593+ bool: return True if the path exists.
1594+ """
1595+ path_scheme = urlparse (uri ).scheme or "file"
1596+ storage_options = auth or authutil .default_signer ()
1597+ if fsspec .filesystem (path_scheme , ** storage_options ).exists (uri ):
1598+ return True
1599+ return False
0 commit comments