MCPcopy Create free account
hub / github.com/modelscope/modelscope / update_local_model

Function update_local_model

modelscope/utils/audio/audio_utils.py:325–353  ·  view source on GitHub ↗
(model_config, model_path, extra_args)

Source from the content-addressed store, hash-verified

323
324
325def 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')

Callers 3

get_cmdMethod · 0.90
get_cmdMethod · 0.90
get_cmdMethod · 0.90

Calls 3

get_model_cache_rootFunction · 0.90
snapshot_downloadFunction · 0.90
existsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…