File size: 867 Bytes
c1bc901
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import huggingface_hub as hf
import os
from dotenv import load_dotenv
class HuggingFaceManager:
    def __init__(self):
        load_dotenv(override=True)
        self.api_token = os.getenv("HF_TOKEN")
        if not self.api_token:
            raise ValueError("HF_TOKEN not found in environment variables.")
        hf.login(token=self.api_token)
       
    def delete_space(self, space_path):
        try:
            hf.delete_repo(repo_id=space_path, repo_type="space", 
                           token=self.api_token, missing_ok=True)
            print(f"Successfully deleted space: {space_path}")
        except Exception as e:
            print(f"Error deleting space {space_path}: {e}")
if __name__ == "__main__":
    manager = HuggingFaceManager()
    # Example usage:
    manager.delete_space("venkateshsrini/MySmartAssistant")