use gradio 6 in readme
Browse files298 unmodified lines2993003013023033043052 unmodified lines30830931031131231331 unmodified lines3453463473483493502 unmodified lines353354355356357358359684 unmodified lines1044104510461047104810491050298 unmodified linesreturn "gradio" # Defaultdef add_anycoder_tag_to_readme(api, repo_id: str, app_port: Optional[int] = None) -> None:"""Download existing README, add anycoder tag and app_port if needed, and upload back.Preserves all existing README content and frontmatter.2 unmodified linesapi: HuggingFace API clientrepo_id: Repository ID (username/space-name)app_port: Optional port number to set for Docker spaces (e.g., 7860)"""try:import tempfile31 unmodified linesif app_port is not None and 'app_port:' not in frontmatter:frontmatter += f'\napp_port: {app_port}'# Reconstruct the READMEnew_content = f"---\n{frontmatter}\n---{body}"else:2 unmodified lineselse:# No frontmatter, add it at the beginningapp_port_line = f'\napp_port: {app_port}' if app_port else ''new_content = f"---\ntags:\n- anycoder{app_port_line}\n---\n\n{content}"# Upload the modified READMEwith tempfile.NamedTemporaryFile("w", suffix=".md", delete=False, encoding='utf-8') as f:684 unmodified linesimport timeif not is_update:time.sleep(2) # Give HF time to generate README for new spacesadd_anycoder_tag_to_readme(api, repo_id, app_port)except Exception as e:# Don't fail deployment if README modification failsprint(f"Warning: Could not add anycoder tag to README: {e}")298 unmodified lines2993003013023033043052 unmodified lines30830931031131231331431 unmodified lines3463473483493503513523533543553563573583593603613622 unmodified lines365366367368369370371372684 unmodified lines1057105810591060106110621063298 unmodified linesreturn "gradio" # Defaultdef add_anycoder_tag_to_readme(api, repo_id: str, app_port: Optional[int] = None, sdk: Optional[str] = None) -> None:"""Download existing README, add anycoder tag and app_port if needed, and upload back.Preserves all existing README content and frontmatter.2 unmodified linesapi: HuggingFace API clientrepo_id: Repository ID (username/space-name)app_port: Optional port number to set for Docker spaces (e.g., 7860)sdk: Optional SDK type (e.g., 'gradio', 'streamlit', 'docker', 'static')"""try:import tempfile31 unmodified linesif app_port is not None and 'app_port:' not in frontmatter:frontmatter += f'\napp_port: {app_port}'# For Gradio spaces, always set sdk_version to 6.0.2if sdk == 'gradio':if 'sdk_version:' in frontmatter:# Update existing sdk_versionfrontmatter = re.sub(r'sdk_version:\s*[^\n]+', 'sdk_version: 6.0.2', frontmatter)print(f"[README] Updated sdk_version to 6.0.2 for Gradio space")else:# Add sdk_versionfrontmatter += '\nsdk_version: 6.0.2'print(f"[README] Added sdk_version: 6.0.2 for Gradio space")# Reconstruct the READMEnew_content = f"---\n{frontmatter}\n---{body}"else:2 unmodified lineselse:# No frontmatter, add it at the beginningapp_port_line = f'\napp_port: {app_port}' if app_port else ''sdk_version_line = '\nsdk_version: 6.0.2' if sdk == 'gradio' else ''new_content = f"---\ntags:\n- anycoder{app_port_line}{sdk_version_line}\n---\n\n{content}"# Upload the modified READMEwith tempfile.NamedTemporaryFile("w", suffix=".md", delete=False, encoding='utf-8') as f:684 unmodified linesimport timeif not is_update:time.sleep(2) # Give HF time to generate README for new spacesadd_anycoder_tag_to_readme(api, repo_id, app_port, sdk)except Exception as e:# Don't fail deployment if README modification failsprint(f"Warning: Could not add anycoder tag to README: {e}")
backend_deploy.py+16-3