Spaces:
Running
Running
| from __future__ import annotations | |
| import hashlib | |
| import json | |
| from pathlib import Path | |
| from typing import Any, Dict | |
| def stable_hash(d: Dict[str, Any]) -> str: | |
| s = json.dumps(d, sort_keys=True, ensure_ascii=False) | |
| return hashlib.md5(s.encode("utf-8")).hexdigest()[:8] | |
| def ensure_dir(p: Path) -> None: | |
| p.mkdir(parents=True, exist_ok=True) | |