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

Function _save_index

modelscope/utils/ast_utils.py:602–618  ·  view source on GitHub ↗
(index, file_path, file_list=None, with_template=False)

Source from the content-addressed store, hash-verified

600
601
602def _save_index(index, file_path, file_list=None, with_template=False):
603 # convert tuple key to str key
604 index[INDEX_KEY] = {str(k): v for k, v in index[INDEX_KEY].items()}
605 from modelscope.version import __version__
606 index[VERSION_KEY] = __version__
607 index[MD5_KEY], index[FILES_MTIME_KEY] = file_scanner.files_mtime_md5(
608 file_list=file_list)
609 index[MODELSCOPE_PATH_KEY] = MODELSCOPE_PATH.as_posix()
610 json_index = json.dumps(index)
611 if with_template:
612 json_index = json_index.replace(MODELSCOPE_PATH.as_posix(),
613 TEMPLATE_PATH)
614 ensure_write(json_index.encode(), file_path)
615 index[INDEX_KEY] = {
616 ast.literal_eval(k): v
617 for k, v in index[INDEX_KEY].items()
618 }
619
620
621def _load_index(file_path, with_template=False):

Callers 2

load_indexFunction · 0.85
generate_ast_templateFunction · 0.85

Calls 6

ensure_writeFunction · 0.85
files_mtime_md5Method · 0.80
replaceMethod · 0.80
itemsMethod · 0.45
dumpsMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…