#!/usr/bin/env python3 from huggingface_hub import HfApi import os # Create fresh HuggingFace Space with corrected name api = HfApi() try: # Delete force_rebuild from README first with open('README.md', 'r') as f: content = f.read() # Remove the force_rebuild line content = content.replace('\nforce_rebuild: true', '') with open('README.md', 'w') as f: f.write(content) print("Cleaned README.md") # Create the new space space_url = api.create_repo( repo_id="pgits/stt-gpu-service-python-v5", repo_type="space", exist_ok=True, space_sdk="docker", space_hardware="t4-small", space_sleep_time=1800 # 30 minutes ) print(f"New Space created successfully: {space_url}") # Upload all files files_to_upload = [ "app.py", "requirements.txt", "Dockerfile", "README.md" ] for file in files_to_upload: if os.path.exists(file): print(f"Uploading {file}...") api.upload_file( path_or_fileobj=file, path_in_repo=file, repo_id="pgits/stt-gpu-service-python-v5", repo_type="space" ) print(f"✓ {file} uploaded") else: print(f"⚠️ {file} not found") print("🚀 Fresh Space deployment completed!") print(f"URL: https://huggingface.co/spaces/pgits/stt-gpu-service-python-v5") except Exception as e: print(f"Error: {e}")