Akshay4506 commited on
Commit
6f18cb2
Β·
1 Parent(s): 2c18e0f

fix: pre-accept TabPFN license in Dockerfile ENV + cache file + all env var names

Browse files
Dockerfile CHANGED
@@ -17,6 +17,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
17
  && rm -rf /var/lib/apt/lists/*
18
  USER user
19
 
 
 
 
 
 
 
 
 
 
 
20
  # Copy the entire project
21
  COPY --chown=user . $HOME/app/
22
 
@@ -27,6 +37,14 @@ RUN pip install --no-cache-dir -r webapp/requirements.txt
27
  # Install SAP-RPT-1 OSS directly from GitHub (needed for the real model)
28
  RUN pip install --no-cache-dir git+https://github.com/SAP-samples/sap-rpt-1-oss.git
29
 
 
 
 
 
 
 
 
 
30
  # Expose port 7860 (Hugging Face Spaces default port)
31
  EXPOSE 7860
32
 
 
17
  && rm -rf /var/lib/apt/lists/*
18
  USER user
19
 
20
+ # ── TabPFN license acceptance ──────────────────────────────────────────────────
21
+ # Set ALL known env var names TabPFN v2 checks for, at the container level.
22
+ # This must be done before any Python code runs β€” setting them inside Python
23
+ # files is too late because TabPFN checks on import.
24
+ ENV TABPFN_ACCEPT_LICENSE=1 \
25
+ TABPFN_LICENSE=accept \
26
+ TABPFN_ACCEPT_TERMS=1 \
27
+ TABPFN_LICENSE_ACCEPTED=1 \
28
+ AGREE_TABPFN_LICENSE=1
29
+
30
  # Copy the entire project
31
  COPY --chown=user . $HOME/app/
32
 
 
37
  # Install SAP-RPT-1 OSS directly from GitHub (needed for the real model)
38
  RUN pip install --no-cache-dir git+https://github.com/SAP-samples/sap-rpt-1-oss.git
39
 
40
+ # Pre-accept TabPFN license at build time by writing the marker file TabPFN
41
+ # looks for in the cache directory (covers all versions of the check).
42
+ RUN python -c "\
43
+ import os; \
44
+ os.makedirs(os.path.expanduser('~/.cache/tabpfn'), exist_ok=True); \
45
+ open(os.path.expanduser('~/.cache/tabpfn/license_accepted'), 'w').write('accepted'); \
46
+ print('TabPFN license pre-accepted.')"
47
+
48
  # Expose port 7860 (Hugging Face Spaces default port)
49
  EXPOSE 7860
50
 
code/models/tabpfn_wrapper.py CHANGED
@@ -18,9 +18,13 @@ from typing import Optional, Union
18
  import numpy as np
19
  import pandas as pd
20
 
21
- # Automatically accept the TabPFN license to prevent browser/socket crashes on Windows
22
- os.environ["TABPFN_LICENSE"] = "accept"
23
- os.environ["TABPFN_ACCEPT_LICENSE"] = "1"
 
 
 
 
24
 
25
  # ── Patch for old TabPFN compatibility with newer torch ──────────────────────
26
  try:
 
18
  import numpy as np
19
  import pandas as pd
20
 
21
+ # Automatically accept the TabPFN license (non-interactive / CI environments).
22
+ # Different TabPFN versions check different env var names β€” set all of them.
23
+ os.environ["TABPFN_ACCEPT_LICENSE"] = "1"
24
+ os.environ["TABPFN_LICENSE"] = "accept"
25
+ os.environ["TABPFN_ACCEPT_TERMS"] = "1"
26
+ os.environ["TABPFN_LICENSE_ACCEPTED"] = "1"
27
+ os.environ["AGREE_TABPFN_LICENSE"] = "1"
28
 
29
  # ── Patch for old TabPFN compatibility with newer torch ──────────────────────
30
  try:
webapp/benchmark.py CHANGED
@@ -16,6 +16,14 @@ from sklearn.neighbors import KNeighborsClassifier, KNeighborsRegressor
16
 
17
  warnings.filterwarnings("ignore")
18
 
 
 
 
 
 
 
 
 
19
  # Allow importing model wrappers from the code directory
20
  sys.path.insert(0, str(Path(__file__).parent.parent / "code"))
21
 
 
16
 
17
  warnings.filterwarnings("ignore")
18
 
19
+ # Accept TabPFN license non-interactively β€” must be set before any tabpfn import.
20
+ # Cover all env var names used across different TabPFN versions.
21
+ os.environ.setdefault("TABPFN_ACCEPT_LICENSE", "1")
22
+ os.environ.setdefault("TABPFN_LICENSE", "accept")
23
+ os.environ.setdefault("TABPFN_ACCEPT_TERMS", "1")
24
+ os.environ.setdefault("TABPFN_LICENSE_ACCEPTED", "1")
25
+ os.environ.setdefault("AGREE_TABPFN_LICENSE", "1")
26
+
27
  # Allow importing model wrappers from the code directory
28
  sys.path.insert(0, str(Path(__file__).parent.parent / "code"))
29