Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -9,29 +9,34 @@ sys.stdout.flush()
|
|
9 |
os.environ.setdefault("NUMBA_CACHE_DIR", "/tmp/numba_cache")
|
10 |
os.makedirs(os.environ["NUMBA_CACHE_DIR"], exist_ok=True)
|
11 |
|
12 |
-
# ββ 2.
|
13 |
try:
|
14 |
-
import numba
|
15 |
from numba.core import dispatcher, caching
|
|
|
16 |
|
17 |
-
# 2-a UMAP path:
|
18 |
dispatcher.Dispatcher.enable_caching = lambda self: None
|
19 |
|
20 |
-
# 2-b
|
21 |
class _NoCache(types.SimpleNamespace):
|
22 |
-
"""Dummy replacement that never touches disk."""
|
23 |
def __init__(self, *_, **__): pass
|
24 |
-
load_overload
|
25 |
-
save_overload
|
26 |
-
enable_caching
|
27 |
-
caching.FunctionCache = _NoCache
|
28 |
|
29 |
-
# 2-c
|
|
|
|
|
|
|
|
|
30 |
os.environ["NUMBA_DISABLE_CACHE"] = "1"
|
31 |
|
32 |
except ImportError:
|
33 |
-
# numba
|
34 |
pass
|
|
|
|
|
35 |
|
36 |
# ββ 3. Heavy imports (UMAP, BERTopic, FastAPI, β¦) βββββββββββββββββββββββ
|
37 |
from typing import List
|
|
|
9 |
os.environ.setdefault("NUMBA_CACHE_DIR", "/tmp/numba_cache")
|
10 |
os.makedirs(os.environ["NUMBA_CACHE_DIR"], exist_ok=True)
|
11 |
|
12 |
+
# ββ 2. FINAL numba cache kill-switch ββββββββββββββββββββββββββββββββββββ
|
13 |
try:
|
14 |
+
import importlib, numba, types
|
15 |
from numba.core import dispatcher, caching
|
16 |
+
import numba.np.ufunc.ufuncbuilder as ufuncbuilder
|
17 |
|
18 |
+
# 2-a UMAP path: no-op dispatcher method
|
19 |
dispatcher.Dispatcher.enable_caching = lambda self: None
|
20 |
|
21 |
+
# 2-b Build a stub that pretends to be a FunctionCache
|
22 |
class _NoCache(types.SimpleNamespace):
|
|
|
23 |
def __init__(self, *_, **__): pass
|
24 |
+
load_overload = lambda *_, **__: False
|
25 |
+
save_overload = lambda *_, **__: None
|
26 |
+
enable_caching = lambda *_, **__: None
|
|
|
27 |
|
28 |
+
# 2-c Patch *every* place that still holds a reference
|
29 |
+
caching.FunctionCache = _NoCache # core path
|
30 |
+
ufuncbuilder.FunctionCache = _NoCache # PyNNDescent path
|
31 |
+
|
32 |
+
# 2-d Extra belt-and-braces flag
|
33 |
os.environ["NUMBA_DISABLE_CACHE"] = "1"
|
34 |
|
35 |
except ImportError:
|
36 |
+
# numba isn't installed yet during first pip install β harmless
|
37 |
pass
|
38 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
39 |
+
|
40 |
|
41 |
# ββ 3. Heavy imports (UMAP, BERTopic, FastAPI, β¦) βββββββββββββββββββββββ
|
42 |
from typing import List
|