Spaces:
Captain3000
/
Runtime error

akhaliq HF Staff commited on
Commit
a47f768
·
1 Parent(s): 1e9598c

Fix React and Streamlit deployment: Upload files individually like transformers.js

Browse files

Issue: React and Streamlit apps were using upload_folder() which doesn't match
the original deploy.py behavior, potentially causing issues with multi-file apps.

Root cause analysis from original deploy.py:
- Transformers.js: Individual file uploads ✅ (already fixed)
- React: Individual file uploads ❌ (was using upload_folder)
- Streamlit: Individual file uploads ❌ (was using upload_folder)
- HTML (static): upload_folder() for multi-file OR upload_file() for single
- Gradio: create_commit() with atomic ops for multi-file OR upload_file()

Changes to backend_deploy.py:

1. React deployment now uses individual uploads:
- Set use_individual_uploads = True for React apps
- Parses React output to get all files
- Uploads each file individually with retry logic
- Includes Dockerfile if missing (from template)

2. Streamlit deployment now uses individual uploads:
- Set use_individual_uploads = True for Streamlit (Docker mode)
- Uploads each file individually with retry logic
- Includes Dockerfile and requirements.txt

3. Enhanced subdirectory support:
- All file writes now create parent directories if needed
- Handles nested structures like pages/, components/, styles/
- Path handling works correctly on Windows and Unix

4. Improved individual upload logic:
- Dynamically scans temp directory for all files
- Handles subdirectories with proper path separators
- Converts backslashes to forward slashes for repo paths
- Works for any number of files (not hardcoded list)

5. Better logging:
- Shows how many files are being uploaded
- Lists all file paths being uploaded
- Per-file success messages
- Retry attempt logging

Upload behavior by language:
- transformers.js: Individual uploads (index.html, index.js, style.css)
- React: Individual uploads (all parsed files + Dockerfile)
- Streamlit: Individual uploads (all parsed files + Dockerfile + requirements.txt)
- HTML: upload_folder() (works fine for static sites)
- Gradio: upload_folder() (works fine for Gradio SDK)
- ComfyUI: upload_folder() (works fine for static)

This ensures React and Streamlit apps with multiple files, nested directories,
and Dockerfiles deploy correctly, matching the original deploy.py behavior.

1 file changed +41 -12
backend_deploy.py+41-12