MCPcopy Index your code
hub / github.com/modelscope/modelscope / read_config

Function read_config

modelscope/utils/hub.py:40–60  ·  view source on GitHub ↗

Read config from hub or local path Args: model_id_or_path (str): Model repo name or local directory path. revision: revision of the model when getting from the hub Return: config (:obj:`Config`): config object

(model_id_or_path: str,
                revision: Optional[str] = DEFAULT_MODEL_REVISION)

Source from the content-addressed store, hash-verified

38
39
40def read_config(model_id_or_path: str,
41 revision: Optional[str] = DEFAULT_MODEL_REVISION):
42 """ Read config from hub or local path
43
44 Args:
45 model_id_or_path (str): Model repo name or local directory path.
46 revision: revision of the model when getting from the hub
47 Return:
48 config (:obj:`Config`): config object
49 """
50 if not os.path.exists(model_id_or_path):
51 local_path = model_file_download(
52 model_id_or_path, ModelFile.CONFIGURATION, revision=revision)
53 elif os.path.isdir(model_id_or_path):
54 local_path = os.path.join(model_id_or_path, ModelFile.CONFIGURATION)
55 elif os.path.isfile(model_id_or_path):
56 local_path = model_id_or_path
57 else:
58 return None
59
60 return Config.from_file(local_path)
61
62
63def auto_load(model: Union[str, List[str]]):

Callers 15

init_megatron_utilFunction · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
pipelineFunction · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
build_trainerFunction · 0.90
from_pretrainedMethod · 0.90
__init__Method · 0.90

Calls 3

model_file_downloadFunction · 0.90
from_fileMethod · 0.80
existsMethod · 0.45

Tested by 10

setUpMethod · 0.72
tearDownMethod · 0.72
build_trainerMethod · 0.72
setUpMethod · 0.72
setUpMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…