Upload utils.py with huggingface_hub
Browse files
utils.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import json
|
|
|
|
| 2 |
from typing import Any, Dict
|
| 3 |
|
| 4 |
import pkg_resources
|
|
@@ -27,6 +28,11 @@ def flatten_dict(
|
|
| 27 |
return dict(items)
|
| 28 |
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
def load_json(path):
|
| 31 |
with open(path) as f:
|
| 32 |
try:
|
|
|
|
| 1 |
import json
|
| 2 |
+
from functools import lru_cache
|
| 3 |
from typing import Any, Dict
|
| 4 |
|
| 5 |
import pkg_resources
|
|
|
|
| 28 |
return dict(items)
|
| 29 |
|
| 30 |
|
| 31 |
+
@lru_cache(maxsize=None)
|
| 32 |
+
def artifacts_json_cache(artifact_path):
|
| 33 |
+
return load_json(artifact_path)
|
| 34 |
+
|
| 35 |
+
|
| 36 |
def load_json(path):
|
| 37 |
with open(path) as f:
|
| 38 |
try:
|