Spaces:
Sleeping
Sleeping
errors
Browse files
app.py
CHANGED
|
@@ -11,19 +11,24 @@ sys.path.append('./KNN')
|
|
| 11 |
|
| 12 |
|
| 13 |
|
|
|
|
|
|
|
| 14 |
def load_pickle_file(file_name):
|
| 15 |
try:
|
| 16 |
with open(file_name, "rb") as f:
|
| 17 |
loaded_file = pickle.load(f)
|
| 18 |
return loaded_file
|
| 19 |
except pickle.UnpicklingError:
|
| 20 |
-
|
|
|
|
|
|
|
| 21 |
return None
|
| 22 |
except Exception as exc:
|
| 23 |
-
|
|
|
|
|
|
|
| 24 |
return None
|
| 25 |
|
| 26 |
-
|
| 27 |
# def build_knn_from_pca_package(package):
|
| 28 |
# if package is None:
|
| 29 |
# return None
|
|
|
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
+
loading_errors = {}
|
| 15 |
+
|
| 16 |
def load_pickle_file(file_name):
|
| 17 |
try:
|
| 18 |
with open(file_name, "rb") as f:
|
| 19 |
loaded_file = pickle.load(f)
|
| 20 |
return loaded_file
|
| 21 |
except pickle.UnpicklingError:
|
| 22 |
+
error_msg = f"{file_name} is not a valid pickle. Run `git lfs pull`."
|
| 23 |
+
print(error_msg, flush=True)
|
| 24 |
+
loading_errors[file_name] = error_msg
|
| 25 |
return None
|
| 26 |
except Exception as exc:
|
| 27 |
+
error_msg = f"Could not load {file_name}: {exc}"
|
| 28 |
+
print(error_msg, flush=True)
|
| 29 |
+
loading_errors[file_name] = error_msg
|
| 30 |
return None
|
| 31 |
|
|
|
|
| 32 |
# def build_knn_from_pca_package(package):
|
| 33 |
# if package is None:
|
| 34 |
# return None
|