MogensR commited on
Commit
d03832f
·
1 Parent(s): 2449cff

Update core/app.py

Browse files
Files changed (1) hide show
  1. core/app.py +2 -29
core/app.py CHANGED
@@ -4,36 +4,9 @@
4
  Refactored modular architecture - orchestrates specialized components
5
  """
6
 
7
- # 0️⃣ Early threading/OMP sanitization (prevents libgomp + interop warnings)
8
- import os
9
- def _clean_int_env(name: str, default: str | None = None):
10
- val = os.environ.get(name)
11
- if val is None:
12
- if default is not None:
13
- os.environ[name] = str(default)
14
- return
15
- try:
16
- int(str(val).strip())
17
- except ValueError:
18
- if default is None:
19
- os.environ.pop(name, None)
20
- else:
21
- os.environ[name] = str(default)
22
-
23
- _clean_int_env("OMP_NUM_THREADS", "2")
24
- _clean_int_env("MKL_NUM_THREADS", "2")
25
- _clean_int_env("OPENBLAS_NUM_THREADS", "2")
26
- _clean_int_env("NUMEXPR_NUM_THREADS", "2")
27
-
28
- try:
29
- import torch # call thread setters BEFORE heavy parallel work starts
30
- if hasattr(torch, "set_num_interop_threads"):
31
- torch.set_num_interop_threads(2)
32
- if hasattr(torch, "set_num_threads"):
33
- torch.set_num_threads(2)
34
- except Exception:
35
- pass
36
 
 
37
  import logging
38
  import threading
39
  from pathlib import Path
 
4
  Refactored modular architecture - orchestrates specialized components
5
  """
6
 
7
+ import early_env # <<< centralizes the OMP/torch thread fix; must be first
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
+ import os
10
  import logging
11
  import threading
12
  from pathlib import Path