Yeetek commited on
Commit
ae9a65a
Β·
verified Β·
1 Parent(s): 0d226e8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -11
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. UNIVERSAL numba cache kill-switch ───────────────────────────────
13
  try:
14
- import numba
15
  from numba.core import dispatcher, caching
 
16
 
17
- # 2-a UMAP path: make Dispatcher.enable_caching a no-op
18
  dispatcher.Dispatcher.enable_caching = lambda self: None
19
 
20
- # 2-b PyNNDescent path: replace FunctionCache with stub
21
  class _NoCache(types.SimpleNamespace):
22
- """Dummy replacement that never touches disk."""
23
  def __init__(self, *_, **__): pass
24
- load_overload = lambda *_, **__: False
25
- save_overload = lambda *_, **__: None
26
- enable_caching = lambda *_, **__: None
27
- caching.FunctionCache = _NoCache
28
 
29
- # 2-c Extra belt-and-braces env flag
 
 
 
 
30
  os.environ["NUMBA_DISABLE_CACHE"] = "1"
31
 
32
  except ImportError:
33
- # numba not yet present during first pip install – harmless
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