Spaces:
Sleeping
Sleeping
| """ | |
| Deploy OpenEnv to Hugging Face Spaces | |
| This script uses the Hugging Face Hub API to deploy your space | |
| """ | |
| from huggingface_hub import HfApi, login | |
| import os | |
| # Configuration | |
| HF_TOKEN = "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" # Replace with your actual token | |
| SPACE_ID = "mahammadaftab/OpenEnv" | |
| def deploy_to_spaces(): | |
| """Deploy the local repository to Hugging Face Spaces""" | |
| # Login to Hugging Face | |
| print("Authenticating with Hugging Face...") | |
| login(token=HF_TOKEN) | |
| # Initialize API | |
| api = HfApi() | |
| # Upload the entire repository | |
| print(f"Uploading to {SPACE_ID}...") | |
| try: | |
| api.upload_folder( | |
| folder_path=".", | |
| repo_id=SPACE_ID, | |
| repo_type="space", | |
| ignore_patterns=["__pycache__", "*.pyc", ".git", "*.md"], | |
| commit_message="Deploy OpenEnv application" | |
| ) | |
| print("✅ Deployment successful!") | |
| except Exception as e: | |
| print(f"❌ Error during deployment: {e}") | |
| return False | |
| return True | |
| if __name__ == "__main__": | |
| deploy_to_spaces() | |