(snapshot_path, git_helper_extras=None)
| 3151 | |
| 3152 | |
| 3153 | async def restore_snapshot(snapshot_path, git_helper_extras=None): |
| 3154 | cloned_repos = [] |
| 3155 | checkout_repos = [] |
| 3156 | enabled_repos = [] |
| 3157 | disabled_repos = [] |
| 3158 | skip_node_packs = [] |
| 3159 | switched_node_packs = [] |
| 3160 | installed_node_packs = [] |
| 3161 | failed = [] |
| 3162 | |
| 3163 | await unified_manager.reload('cache') |
| 3164 | await unified_manager.get_custom_nodes('default', 'cache') |
| 3165 | |
| 3166 | cnr_repo_map = {} |
| 3167 | for k, v in unified_manager.repo_cnr_map.items(): |
| 3168 | cnr_repo_map[v['id']] = k |
| 3169 | |
| 3170 | print("Restore snapshot.") |
| 3171 | |
| 3172 | postinstalls = [] |
| 3173 | |
| 3174 | with open(snapshot_path, 'r', encoding="UTF-8") as snapshot_file: |
| 3175 | if snapshot_path.endswith('.json'): |
| 3176 | info = json.load(snapshot_file) |
| 3177 | elif snapshot_path.endswith('.yaml'): |
| 3178 | info = yaml.load(snapshot_file, Loader=yaml.SafeLoader) |
| 3179 | info = info['custom_nodes'] |
| 3180 | |
| 3181 | if 'pips' in info and info['pips']: |
| 3182 | pips = info['pips'] |
| 3183 | else: |
| 3184 | pips = {} |
| 3185 | |
| 3186 | # for cnr restore |
| 3187 | cnr_info = info.get('cnr_custom_nodes') |
| 3188 | if cnr_info is not None: |
| 3189 | # disable not listed cnr nodes |
| 3190 | todo_disable = [] |
| 3191 | todo_checkout = [] |
| 3192 | |
| 3193 | for k, v in unified_manager.active_nodes.items(): |
| 3194 | if 'comfyui-manager' in k: |
| 3195 | continue |
| 3196 | |
| 3197 | if v[0] != 'nightly': |
| 3198 | if k not in cnr_info: |
| 3199 | todo_disable.append(k) |
| 3200 | else: |
| 3201 | cnr_ver = cnr_info[k] |
| 3202 | if v[1] != cnr_ver: |
| 3203 | todo_checkout.append((k, cnr_ver)) |
| 3204 | else: |
| 3205 | skip_node_packs.append(k) |
| 3206 | |
| 3207 | for x in todo_disable: |
| 3208 | unified_manager.unified_disable(x, False) |
| 3209 | disabled_repos.append(x) |
| 3210 |
nothing calls this directly
no test coverage detected