Spaces:
Running
Running
File size: 353 Bytes
b9196ed | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 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)
|