from huggingface_hub import HfApi import os import time api = HfApi() timestamp = int(time.time()) new_repo_id = f"cefrefdwe/warp-proxy-test-{timestamp}" token = os.environ.get('HF_TOKEN') print(f"Creating new space: {new_repo_id}") try: api.create_repo( repo_id=new_repo_id, repo_type="space", space_sdk="docker", private=False, token=token ) print(f"✅ Space created: {new_repo_id}") except Exception as e: print(f"❌ Creation failed: {e}") # If it fails, maybe it already exists, try to continue files = [ 'Dockerfile', 'warp_manager.py', 'supervisord.conf', 'worker.py', 'server.py', 'check_logs.py', 'monitor_status.py', 'requirements.txt', 'README.md', 'ip_pool.json' ] print(f"Uploading files to {new_repo_id}...") for file in files: try: path = os.path.join(os.getcwd(), file) api.upload_file( path_or_fileobj=path, path_in_repo=file, repo_id=new_repo_id, repo_type='space', token=token ) print(f"✅ Uploaded {file}") except Exception as e: print(f"❌ Failed to upload {file}: {e}") # Update monitor script with new repo ID monitor_script = "monitor_status.py" with open(monitor_script, "r") as f: content = f.read() import re new_content = re.sub(r'REPO_ID = ".*"', f'REPO_ID = "{new_repo_id}"', content) with open(monitor_script, "w") as f: f.write(new_content) print(f"✅ Updated {monitor_script} with new REPO_ID")