Spaces:
Running
Running
Asish Karthikeya Gogineni commited on
Commit ·
b4da4fc
1
Parent(s): 511ccc3
fix: Use /tmp directory for Hugging Face compatibility
Browse files- app.py: ZIP uploads now write to tempfile.gettempdir() instead of data/
- indexing_progress.py: Extraction uses /tmp/code_chatbot_extracted
- Fixes 403 error when uploading ZIP files on Hugging Face Spaces
- app.py +4 -3
- code_chatbot/indexing_progress.py +3 -1
app.py
CHANGED
|
@@ -403,9 +403,10 @@ with st.sidebar:
|
|
| 403 |
if source_type == "ZIP File":
|
| 404 |
uploaded_file = st.file_uploader("Upload .zip file", type="zip")
|
| 405 |
if uploaded_file:
|
| 406 |
-
#
|
| 407 |
-
|
| 408 |
-
|
|
|
|
| 409 |
with open(source_input, "wb") as f:
|
| 410 |
f.write(uploaded_file.getbuffer())
|
| 411 |
elif source_type == "GitHub Repository":
|
|
|
|
| 403 |
if source_type == "ZIP File":
|
| 404 |
uploaded_file = st.file_uploader("Upload .zip file", type="zip")
|
| 405 |
if uploaded_file:
|
| 406 |
+
# Use /tmp for Hugging Face compatibility (they only allow writes to /tmp)
|
| 407 |
+
import tempfile
|
| 408 |
+
upload_dir = tempfile.gettempdir()
|
| 409 |
+
source_input = os.path.join(upload_dir, "uploaded.zip")
|
| 410 |
with open(source_input, "wb") as f:
|
| 411 |
f.write(uploaded_file.getbuffer())
|
| 412 |
elif source_type == "GitHub Repository":
|
code_chatbot/indexing_progress.py
CHANGED
|
@@ -45,7 +45,9 @@ def index_with_progress(
|
|
| 45 |
status_text.text("📦 Stage 1/4: Extracting and ingesting files...")
|
| 46 |
progress_bar.progress(0.05)
|
| 47 |
|
| 48 |
-
|
|
|
|
|
|
|
| 49 |
|
| 50 |
if os.path.exists(extract_to):
|
| 51 |
status_text.text("🧹 Cleaning previous data...")
|
|
|
|
| 45 |
status_text.text("📦 Stage 1/4: Extracting and ingesting files...")
|
| 46 |
progress_bar.progress(0.05)
|
| 47 |
|
| 48 |
+
# Use /tmp for Hugging Face compatibility (they only allow writes to /tmp)
|
| 49 |
+
import tempfile
|
| 50 |
+
extract_to = os.path.join(tempfile.gettempdir(), "code_chatbot_extracted")
|
| 51 |
|
| 52 |
if os.path.exists(extract_to):
|
| 53 |
status_text.text("🧹 Cleaning previous data...")
|