Upload utils.py with huggingface_hub
Browse files12318 unmodified lines222324from typing import Any, Dict18 unmodified linesitems.append((new_key, v))return dict(items)123418 unmodified lines23242526272829303132333435363738394041424344import jsonfrom typing import Any, Dict18 unmodified linesitems.append((new_key, v))return dict(items)def load_json(path):with open(path) as f:try:return json.load(f)except json.decoder.JSONDecodeError as e:with open(path) as f:file_content = "\n".join(f.readlines())raise RuntimeError(f"Failed to decode json file at '{path}' with file content:\n{file_content}") from edef save_json(path, data):with open(path, "w") as f:dumped = json.dumps(data, indent=4, ensure_ascii=False)f.write(dumped)f.write("\n")
utils.py+20