Spaces:
Sleeping
Sleeping
File size: 1,094 Bytes
2a44712 a23c324 2a44712 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | """
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()
|