(model_config, model_path, extra_args)
| 323 | |
| 324 | |
| 325 | def update_local_model(model_config, model_path, extra_args): |
| 326 | if 'update_model' in extra_args and not extra_args['update_model']: |
| 327 | return |
| 328 | model_revision = None |
| 329 | if 'update_model' in extra_args: |
| 330 | if extra_args['update_model'] == 'latest': |
| 331 | model_revision = None |
| 332 | else: |
| 333 | model_revision = extra_args['update_model'] |
| 334 | if model_config.__contains__('model'): |
| 335 | model_name = model_config['model'] |
| 336 | dst_dir_root = get_model_cache_root() |
| 337 | if isinstance(model_path, str) and os.path.exists( |
| 338 | model_path) and not model_path.startswith(dst_dir_root): |
| 339 | try: |
| 340 | dst = os.path.join(dst_dir_root, '.cache/' + model_name) |
| 341 | dst_dir = os.path.dirname(dst) |
| 342 | os.makedirs(dst_dir, exist_ok=True) |
| 343 | if not os.path.exists(dst): |
| 344 | os.symlink(os.path.abspath(model_path), dst) |
| 345 | |
| 346 | snapshot_download( |
| 347 | model_name, |
| 348 | cache_dir=dst_dir_root, |
| 349 | revision=model_revision) |
| 350 | except Exception as e: |
| 351 | logger.warning(str(e)) |
| 352 | else: |
| 353 | logger.warning('Can not find model name in configuration') |
no test coverage detected
searching dependent graphs…