akhaliq HF Staff commited on
Commit
de14484
·
1 Parent(s): 51bcded

update PR deploy

Browse files
Files changed (1) hide show
  1. backend_deploy.py +13 -2
backend_deploy.py CHANGED
@@ -1384,14 +1384,25 @@ Generated by [AnyCoder](https://huggingface.co/spaces/akhaliq/anycoder)"""
1384
  else:
1385
  files["app.py"] = cleaned_code
1386
 
 
 
 
 
 
 
 
 
 
 
1387
  # Write files (create subdirectories if needed)
1388
  for filename, content in files.items():
1389
  file_path = temp_path / filename
1390
  file_path.parent.mkdir(parents=True, exist_ok=True)
1391
  file_path.write_text(content, encoding='utf-8')
1392
 
1393
- # Generate requirements.txt if missing for Python apps
1394
- if language in ["gradio", "streamlit"] and "requirements.txt" not in files:
 
1395
  main_app = files.get('streamlit_app.py') or files.get('app.py', '')
1396
  if main_app:
1397
  print(f"[PR] Generating requirements.txt from imports")
 
1384
  else:
1385
  files["app.py"] = cleaned_code
1386
 
1387
+ # For Gradio PRs, only include .py files (preserve existing requirements.txt, etc.)
1388
+ if language == "gradio":
1389
+ print(f"[PR] Gradio app - filtering to only .py files")
1390
+ py_files = {fname: content for fname, content in files.items() if fname.endswith('.py')}
1391
+ if not py_files:
1392
+ print(f"[PR] Warning: No .py files found in parsed output")
1393
+ return False, "No Python files found in generated code for Gradio PR", None
1394
+ files = py_files
1395
+ print(f"[PR] Will update {len(files)} Python file(s): {list(files.keys())}")
1396
+
1397
  # Write files (create subdirectories if needed)
1398
  for filename, content in files.items():
1399
  file_path = temp_path / filename
1400
  file_path.parent.mkdir(parents=True, exist_ok=True)
1401
  file_path.write_text(content, encoding='utf-8')
1402
 
1403
+ # Skip requirements.txt generation for Gradio PRs (preserve existing)
1404
+ # For Streamlit, generate requirements.txt if missing
1405
+ if language == "streamlit" and "requirements.txt" not in files:
1406
  main_app = files.get('streamlit_app.py') or files.get('app.py', '')
1407
  if main_app:
1408
  print(f"[PR] Generating requirements.txt from imports")