Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,9 @@ from huggingface_hub import HfApi
|
|
| 3 |
from huggingface_hub.utils import HfHubHTTPError
|
| 4 |
|
| 5 |
# --- Core Functions ---
|
|
|
|
| 6 |
this_space="broadfield-dev/HF-privatize"
|
|
|
|
| 7 |
def get_my_spaces(hf_token):
|
| 8 |
"""Fetches a list of the user's public Hugging Face Spaces."""
|
| 9 |
if not hf_token:
|
|
@@ -65,8 +67,6 @@ def make_spaces_paused(hf_token, selected_spaces, progress=gr.Progress()):
|
|
| 65 |
for i, space_id in enumerate(selected_spaces):
|
| 66 |
progress((i + 1) / total_spaces, desc=f"Processing '{space_id}'...")
|
| 67 |
try:
|
| 68 |
-
# --- THIS IS THE FIX ---
|
| 69 |
-
# We must explicitly tell the API that this is a 'space'.
|
| 70 |
if not space_id == this_space:
|
| 71 |
api.pause_space(repo_id=space_id)
|
| 72 |
log_messages.append(f"β
Successfully made '{space_id}' paused.")
|
|
@@ -97,8 +97,6 @@ def make_spaces_private(hf_token, selected_spaces, progress=gr.Progress()):
|
|
| 97 |
for i, space_id in enumerate(selected_spaces):
|
| 98 |
progress((i + 1) / total_spaces, desc=f"Processing '{space_id}'...")
|
| 99 |
try:
|
| 100 |
-
# --- THIS IS THE FIX ---
|
| 101 |
-
# We must explicitly tell the API that this is a 'space'.
|
| 102 |
api.update_repo_settings(repo_id=space_id, private=True, repo_type="space")
|
| 103 |
log_messages.append(f"β
Successfully made '{space_id}' private.")
|
| 104 |
except Exception as e:
|
|
@@ -115,12 +113,12 @@ def make_spaces_private(hf_token, selected_spaces, progress=gr.Progress()):
|
|
| 115 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 116 |
gr.Markdown(
|
| 117 |
"""
|
| 118 |
-
# π‘οΈ Hugging Face Space Privacy Control
|
| 119 |
-
Quickly make your public Hugging Face Spaces private.
|
| 120 |
1. Create and paste a Hugging Face access token with **write** permission.
|
| 121 |
2. Click "List My Public Spaces".
|
| 122 |
-
3. Select the spaces you want to make private (or use "Select All").
|
| 123 |
-
4. Click the final button to update their
|
| 124 |
"""
|
| 125 |
)
|
| 126 |
|
|
|
|
| 3 |
from huggingface_hub.utils import HfHubHTTPError
|
| 4 |
|
| 5 |
# --- Core Functions ---
|
| 6 |
+
# Don't pause or privatize this_space
|
| 7 |
this_space="broadfield-dev/HF-privatize"
|
| 8 |
+
|
| 9 |
def get_my_spaces(hf_token):
|
| 10 |
"""Fetches a list of the user's public Hugging Face Spaces."""
|
| 11 |
if not hf_token:
|
|
|
|
| 67 |
for i, space_id in enumerate(selected_spaces):
|
| 68 |
progress((i + 1) / total_spaces, desc=f"Processing '{space_id}'...")
|
| 69 |
try:
|
|
|
|
|
|
|
| 70 |
if not space_id == this_space:
|
| 71 |
api.pause_space(repo_id=space_id)
|
| 72 |
log_messages.append(f"β
Successfully made '{space_id}' paused.")
|
|
|
|
| 97 |
for i, space_id in enumerate(selected_spaces):
|
| 98 |
progress((i + 1) / total_spaces, desc=f"Processing '{space_id}'...")
|
| 99 |
try:
|
|
|
|
|
|
|
| 100 |
api.update_repo_settings(repo_id=space_id, private=True, repo_type="space")
|
| 101 |
log_messages.append(f"β
Successfully made '{space_id}' private.")
|
| 102 |
except Exception as e:
|
|
|
|
| 113 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 114 |
gr.Markdown(
|
| 115 |
"""
|
| 116 |
+
# π‘οΈ Hugging Face Space Privacy & Pause Control
|
| 117 |
+
Quickly make your public Hugging Face Spaces private and paused.
|
| 118 |
1. Create and paste a Hugging Face access token with **write** permission.
|
| 119 |
2. Click "List My Public Spaces".
|
| 120 |
+
3. Select the spaces you want to make private or paused (or use "Select All").
|
| 121 |
+
4. Click the final button to update their settings.
|
| 122 |
"""
|
| 123 |
)
|
| 124 |
|