MCPcopy
hub / github.com/InternLM/InternLM / _get_client

Method _get_client

internlm/utils/storage_manager.py:430–473  ·  view source on GitHub ↗

example: local:/path/to/checkpoint boto3:s3://model_weights/0331/120bi Args: path (str): _description_

(self, path=str)

Source from the content-addressed store, hash-verified

428 raise RuntimeError(f"Insufficient temporary storage space on {socket.gethostname()}")
429
430 def _get_client(self, path=str) -> Union[Boto3MetaInfo, LocalMetaInfo]:
431 """
432 example:
433 local:/path/to/checkpoint
434 boto3:s3://model_weights/0331/120bi
435
436 Args:
437 path (str): _description_
438 """
439 try:
440 backend, path = path.split(":", maxsplit=1)
441 except Exception as exc:
442 raise AttributeError(f"Given path '{path}' is not startwith backend prefix:'local/boto3'") from exc
443
444 init_args = (None,)
445 if backend == "local":
446 meta_info = get_local_meta(path)
447 backend_key = backend
448 elif backend == "boto3":
449 meta_info = get_boto3_meta(path, self.tmp_local_folder, self.async_mode)
450 backend_key = backend + ":" + meta_info.endpoint
451 init_args = (meta_info.endpoint,)
452 if (
453 "http_proxy" in os.environ
454 or "https_proxy" in os.environ
455 or "HTTP_PROXY" in os.environ
456 or "HTTPS_PROXY" in os.environ
457 ):
458 if not self.has_warning:
459 logger.warning(
460 "HTTP/HTTPS proxy is detected when using boto3, incorrectly setting \
461 the proxy may make boto3 unavailable or affect performance."
462 )
463 self.has_warning = True
464
465 assert backend in StorageManager.BACKEND_TYPE, f"Unkown backend: {backend}"
466
467 # boto3 backend need special treatment.
468 if backend_key not in StorageManager.CLI_DICT:
469 StorageManager.CLI_DICT.update({backend_key: StorageManager.BACKEND_INIT_METHOD[backend](*init_args)})
470
471 meta_info.client = StorageManager.CLI_DICT[backend_key]
472
473 return meta_info
474
475 def assert_fp_exists(self, folder) -> None:
476 meta = self._get_client(path=folder)

Callers 5

assert_fp_existsMethod · 0.95
get_fnsMethod · 0.95
saveMethod · 0.95
loadMethod · 0.95
delete_objMethod · 0.95

Calls 3

get_local_metaFunction · 0.85
get_boto3_metaFunction · 0.85
updateMethod · 0.45

Tested by

no test coverage detected