Spaces:
Sleeping
Sleeping
Download app/utils.py from PersonaMusicGroup/PersonaAI: direct link, hf CLI and curl.
- Browser
- Download file 516 Bytes
-
https://huggingface.co/spaces/PersonaMusicGroup/PersonaAI/resolve/main/app/utils.py
- Command line
-
hf download hf://spaces/PersonaMusicGroup/PersonaAI/app/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/PersonaMusicGroup/PersonaAI/resolve/main/app/utils.py
516 Bytes
| import time | |
| from functools import wraps | |
| from typing import Any, Callable, TypeVar | |
| from app.logger import get_logger | |
| _R = TypeVar("_R", bound=Callable[..., Any]) | |
| def timing(f: _R) -> _R: | |
| def wrap(*args: Any, **kw: Any): | |
| time_start = time.time() | |
| result = f(*args, **kw) | |
| time_diff = time.time() - time_start | |
| logger = get_logger() | |
| logger.info("Timing func %s took: %2.4f sec" % (f.__name__, time_diff)) | |
| return result | |
| return wrap # type: ignore | |