Files
wehub-resource-sync a203934033
Lint test / lint (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:34:58 +08:00

27 lines
746 B
Python

# Copyright (c) ModelScope Contributors. All rights reserved.
from __future__ import annotations
import importlib
from typing import Any
from swift.utils.logger import get_logger
logger = get_logger()
def import_optional_module(module_name: str) -> Any | None:
try:
return importlib.import_module(module_name)
except ImportError as exc:
logger.debug('Failed to import optional module %s: %s', module_name, exc)
return None
def apply_patch_map(root: Any, patch_map: dict[str, Any]) -> None:
for path, value in patch_map.items():
current = root
parts = path.split('.')
for part in parts[:-1]:
current = getattr(current, part)
setattr(current, parts[-1], value)