Rogaton Claude commited on
Commit
e0bd56d
·
1 Parent(s): 4a9f7cf

Force clean Docker build to fix transformers ImportError

Browse files

- Upgraded pip, setuptools, wheel before installing requirements
- Added --no-cache-dir flags to prevent cached/corrupted packages
- Improved error handling with detailed diagnostics in UI
- Shows Python version, torch availability, and helpful troubleshooting tips

This should resolve the persistent ImportError for AutoTokenizer
by ensuring a completely fresh installation of all dependencies.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

Files changed (2) hide show
  1. Dockerfile +4 -1
  2. apertus_ui.py +25 -2
Dockerfile CHANGED
@@ -7,8 +7,11 @@ RUN apt-get update && apt-get install -y \
7
 
8
  WORKDIR /code
9
 
 
 
 
10
  COPY requirements.txt .
11
- RUN pip install -r requirements.txt
12
 
13
  COPY . .
14
 
 
7
 
8
  WORKDIR /code
9
 
10
+ # Upgrade pip and install build tools
11
+ RUN pip install --no-cache-dir --upgrade pip setuptools wheel
12
+
13
  COPY requirements.txt .
14
+ RUN pip install --no-cache-dir -r requirements.txt
15
 
16
  COPY . .
17
 
apertus_ui.py CHANGED
@@ -2,8 +2,31 @@ import streamlit as st
2
  import os
3
  import xml.etree.ElementTree as ET
4
  import re
5
- import torch
6
- from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  from huggingface_hub import InferenceClient
8
  from coptic_parser_core import CopticParserCore
9
 
 
2
  import os
3
  import xml.etree.ElementTree as ET
4
  import re
5
+ import sys
6
+
7
+ # Try importing transformers with detailed error handling
8
+ try:
9
+ import torch
10
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
11
+ except ImportError as e:
12
+ st.error(f"""
13
+ ### ❌ Transformers Import Error
14
+
15
+ Failed to import required transformers components: {e}
16
+
17
+ **Debug Info:**
18
+ - Python version: {sys.version}
19
+ - Torch available: {('torch' in sys.modules)}
20
+
21
+ **This usually means:**
22
+ 1. The Docker container is still rebuilding (wait 2-5 minutes)
23
+ 2. Dependencies weren't installed correctly
24
+ 3. There's a version conflict in requirements.txt
25
+
26
+ Please check the HuggingFace Space build logs or try rebuilding the Space.
27
+ """)
28
+ st.stop()
29
+
30
  from huggingface_hub import InferenceClient
31
  from coptic_parser_core import CopticParserCore
32