Spaces:
raheem786
/
Paused

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

Fix transformers.js deployment: Use space name not repo_id for duplicate_space()

Browse files

Issue: 500 error when deploying transformers.js apps
Root cause: duplicate_space() was receiving 'username/space-name' but expects just 'space-name'

Key fix in backend_deploy.py:
- Changed: duplicate_space(to_id=repo_id, ...)
- To: duplicate_space(to_id=space_name, ...)

The huggingface_hub duplicate_space() function automatically prepends
the username from the token, so it expects just the space name, not
the full repo_id format.

Additional improvements:
1. Better error handling and logging for transformers.js parsing
2. Added detailed print statements to track duplication process
3. Match original deploy.py validation logic exactly:
- Use dict access (files['index.html']) instead of .get()
- Check all three files with 'or' conditions
4. Added traceback printing for easier debugging

Error flow now matches original:
1. Parse transformers.js output → extract 3 files
2. Validate all 3 files exist (KeyError if missing)
3. Write files to temp directory
4. Duplicate template space (to_id=space_name only)
5. Upload each file individually with retry logic
6. Add anycoder tag to README

This matches the exact pattern used in the original deploy.py at line 1506-1508.

1 file changed +32 -16
backend_deploy.py+32-16