(index, file_path, file_list=None, with_template=False)
| 600 | |
| 601 | |
| 602 | def _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 | |
| 621 | def _load_index(file_path, with_template=False): |
no test coverage detected
searching dependent graphs…