use gradio 6 in readme
Browse files298 unmodified lines2993003013023023033043052 unmodified lines30830931031131231331431 unmodified lines3463473483493503513523533543553563573583593603613622 unmodified lines365366367368356369370371372684 unmodified lines10571058105910471060106110621063298 unmodified lines return "gradio" # Default
def add_anycoder_tag_to_readme(api, repo_id: str, app_port: Optional[int] = None) -> None:def 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 lines api: HuggingFace API client repo_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 lines if 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.2 if sdk == 'gradio': if 'sdk_version:' in frontmatter: # Update existing sdk_version frontmatter = 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_version frontmatter += '\nsdk_version: 6.0.2' print(f"[README] Added sdk_version: 6.0.2 for Gradio space") # Reconstruct the README new_content = f"---\n{frontmatter}\n---{body}" else:2 unmodified lines else: # No frontmatter, add it at the beginning app_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}\n---\n\n{content}" new_content = f"---\ntags:\n- anycoder{app_port_line}{sdk_version_line}\n---\n\n{content}" # Upload the modified README with tempfile.NamedTemporaryFile("w", suffix=".md", delete=False, encoding='utf-8') as f:684 unmodified lines import time if not is_update: time.sleep(2) # Give HF time to generate README for new spaces add_anycoder_tag_to_readme(api, repo_id, app_port) add_anycoder_tag_to_readme(api, repo_id, app_port, sdk) except Exception as e: # Don't fail deployment if README modification fails print(f"Warning: Could not add anycoder tag to README: {e}")backend_deploy.py+16-3