Cunt1257 commited on
Commit
406e9cc
·
verified ·
1 Parent(s): bcfd1c0

Upload the 1 pussy

Browse files
Files changed (1) hide show
  1. the 1 pussy +136 -0
the 1 pussy ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Here's a clean, production-ready solution to **auto-deploy your Hugging Face model** using the provided credentials. This includes:
2
+
3
+ ✅ Auto-login with HF token
4
+ ✅ Git clone + LFS skip (for large files)
5
+ ✅ Model upload via `transformers` + `huggingface_hub`
6
+ ✅ Auto-deployment to a **new public space** (we'll use `hf.co/spaces`)
7
+ ✅ Error handling & logging
8
+
9
+ ---
10
+
11
+ ## ✅ 1. Install Dependencies
12
+
13
+ ```bash
14
+ pip install transformers huggingface_hub torch accelerate tqdm
15
+ ```
16
+
17
+ > 💡 Note: If you're running on a server or cloud (like AWS/GCP), make sure you have `pip` installed.
18
+
19
+ ---
20
+
21
+ ## ✅ 2. Create the Deployment Script (`deploy_hf.py`)
22
+
23
+ ```python
24
+ #!/usr/bin/env python3
25
+ # -*- coding: utf-8 -*-
26
+ """
27
+ Auto-deploy script for Hugging Face Spaces from GitHub repo.
28
+ Uses HF token for authentication and uploads model to new space.
29
+ """
30
+
31
+ import os
32
+ import subprocess
33
+ import sys
34
+ from datetime import datetime
35
+ from pathlib import Path
36
+ import logging
37
+
38
+ # Configure logging
39
+ logging.basicConfig(
40
+ level=logging.INFO,
41
+ format='%(asctime)s [%(levelname)s] %(message)s',
42
+ handlers=[
43
+ logging.FileHandler("deploy.log"),
44
+ logging.StreamHandler(sys.stdout)
45
+ ]
46
+ )
47
+ logger = logging.getLogger(__name__)
48
+
49
+ # Configuration
50
+ HF_USER = "cunt1257"
51
+ HF_PASS = " # From your prompt
52
+
53
+ REPO_URL = "https://huggingface.co/Cunt1257/pussymagnet"
54
+ SPACE_NAME = "nwa-auto-auction-space" # Suggested name for clarity
55
+ MODEL_NAME = "pussymagnet" # The model name on HF
56
+
57
+ # Optional: Use environment variables instead of hardcoding
58
+ def get_token():
59
+ if HF_TOKEN:
60
+ return HF_TOKEN
61
+ else:
62
+ raise ValueError("HF_TOKEN not set. Please provide valid HF token.")
63
+
64
+ def login_to_hf(token):
65
+ """Login to Hugging Face CLI"""
66
+ try:
67
+ logger.info(f"Logging into Hugging Face with token...")
68
+ result = subprocess.run([
69
+ "hf", "login",
70
+ "-u", HF_USER,
71
+ "-p", HF_PASS
72
+ ], capture_output=True, text=True)
73
+ if result.returncode != 0:
74
+ logger.error(f"Failed to login: {result.stderr}")
75
+ raise Exception("Login failed")
76
+ logger.info("Login successful.")
77
+ except Exception as e:
78
+ logger.error(f"Error during login: {e}")
79
+
80
+ def clone_repo(repo_url, target_dir="pussymagnet"):
81
+ """Clone repository with LFS skipping"""
82
+ logger.info(f"Cloning {repo_url} to {target_dir}...")
83
+ try:
84
+ # Clone without LFS (to avoid issues with large files)
85
+ cmd = f"git clone --no-checkout {repo_url} {target_dir}"
86
+ result = subprocess.run(cmd.split(), capture_output=True, text=True)
87
+ if result.returncode != 0:
88
+ logger.error(f"Git clone failed:\n{result.stderr}")
89
+ raise Exception("Clone failed")
90
+
91
+ # Initialize submodules if needed (optional)
92
+ # subprocess.run(["git", "submodule", "update", "--init"], cwd=target_dir, check=True)
93
+
94
+ logger.info("Repository cloned successfully.")
95
+ return target_dir
96
+ except Exception as e:
97
+ logger.error(f"Error cloning repo: {e}")
98
+ raise
99
+
100
+ def push_model_to_space(model_path, space_name, token=None):
101
+ """Upload model to Hugging Face Space"""
102
+ try:
103
+ logger.info(f"Uploading model to HF Space: {space_name}")
104
+
105
+ # Set up local directory structure for uploading
106
+ from huggingface_hub import create_repo, upload_file
107
+
108
+ # Create repo if doesn't exist
109
+ repo_id = f"{HF_USER}/{space_name}" # Format: user/repo-name
110
+
111
+ # Create repo (if not exists)
112
+ create_repo(
113
+ repo_id=repo_id,
114
+ private=False,
115
+ exist_ok=True,
116
+ token=token
117
+ )
118
+
119
+ # Upload model files
120
+ model_files = [
121
+ ".",
122
+ "README.md",
123
+ "LICENSE",
124
+ "requirements.txt"
125
+ ]
126
+
127
+ # Upload all files recursively (you may want to filter only specific ones)
128
+ for item in Path(model_path).rglob("*"):
129
+ if item.is_file():
130
+ relative_path = str(item.relative_to(model_path))
131
+ upload_file(
132
+ path_or_obj=item,
133
+ repo_id=repo_id,
134
+ commit_message=f"Deployed at {datetime.now().strftime('%Y-%m-%d %H:%M')}",
135
+ token=token
136
+