pliny-the-prompter commited on
Commit
b50f62f
Β·
verified Β·
1 Parent(s): 65030c6

Upload 133 files

Browse files
app.py CHANGED
@@ -346,7 +346,7 @@ METHODS = {
346
  # ── Community Hub push ────────────────────────────────────────────────
347
  # Shared org + token so users can auto-push without their own HF_TOKEN.
348
  # Set OBLITERATUS_HUB_TOKEN as a Space secret with write access to the org.
349
- _HUB_COMMUNITY_ORG = os.environ.get("OBLITERATUS_HUB_ORG", "OBLITERATUS-community")
350
  _HUB_COMMUNITY_TOKEN = os.environ.get("OBLITERATUS_HUB_TOKEN")
351
 
352
  # Import preset configs for Advanced Settings defaults
@@ -477,10 +477,10 @@ def _validate_hub_repo(hub_repo: str) -> str:
477
  "Invalid repo format β€” use `username/model-name` "
478
  "(letters, numbers, hyphens, dots only)"
479
  )
480
- if not os.environ.get("HF_TOKEN") and not _HUB_COMMUNITY_TOKEN:
481
  warnings.append(
482
  "No Hub token available β€” push will fail. "
483
- "Set HF_TOKEN or OBLITERATUS_HUB_TOKEN."
484
  )
485
  if warnings:
486
  return "**Warning:** " + " | ".join(warnings)
@@ -622,11 +622,11 @@ def push_session_to_hub(
622
  # Resolve token
623
  token = hub_token_input.strip() if hub_token_input else None
624
  if not token:
625
- token = os.environ.get("HF_TOKEN") or _HUB_COMMUNITY_TOKEN
626
  if not token:
627
  yield (
628
  "**Error:** No Hub token available. Enter a token above, "
629
- "or set `HF_TOKEN` / `OBLITERATUS_HUB_TOKEN` as an environment variable.",
630
  "",
631
  )
632
  return
@@ -1875,12 +1875,12 @@ def obliterate(model_choice: str, method_choice: str,
1875
 
1876
  # Early validation: gated model access
1877
  from obliteratus.presets import is_gated
1878
- if is_gated(model_id) and not os.environ.get("HF_TOKEN"):
1879
  yield (
1880
  f"**Error: Gated model requires authentication.**\n\n"
1881
  f"`{model_id}` is a gated HuggingFace repo. To use it:\n\n"
1882
  f"1. **Accept the license** at [huggingface.co/{model_id}](https://huggingface.co/{model_id})\n"
1883
- f"2. **Set HF_TOKEN** in your Space secrets (Settings β†’ Variables and secrets)\n"
1884
  f" or locally: `export HF_TOKEN=hf_...`\n\n"
1885
  f"Get your token at [huggingface.co/settings/tokens](https://huggingface.co/settings/tokens)\n\n"
1886
  f"Alternatively, choose a non-gated model (those without the \U0001f512 icon).",
@@ -4840,7 +4840,7 @@ with the **-OBLITERATED** tag.
4840
  label="HF Token (optional)",
4841
  placeholder="hf_...",
4842
  type="password",
4843
- info="Leave blank to use HF_TOKEN env var or community token",
4844
  )
4845
  push_repo_warning = gr.Markdown("")
4846
 
@@ -4994,6 +4994,7 @@ To opt out, set the environment variable `OBLITERATUS_TELEMETRY=0` before launch
4994
  diag.append(f"- On HF Spaces: `{_ON_HF_SPACES}`")
4995
  diag.append(f"- Repo: `{_TELEMETRY_REPO or '(not set)'}`")
4996
  diag.append(f"- HF_TOKEN set: `{bool(os.environ.get('HF_TOKEN'))}`")
 
4997
  diag.append(f"- Local file: `{TELEMETRY_FILE}`")
4998
  diag.append(f"- Local file exists: `{TELEMETRY_FILE.exists()}`")
4999
  n_records = len(read_telemetry()) if TELEMETRY_FILE.exists() else 0
 
346
  # ── Community Hub push ────────────────────────────────────────────────
347
  # Shared org + token so users can auto-push without their own HF_TOKEN.
348
  # Set OBLITERATUS_HUB_TOKEN as a Space secret with write access to the org.
349
+ _HUB_COMMUNITY_ORG = os.environ.get("OBLITERATUS_HUB_ORG", "OBLITERATUS")
350
  _HUB_COMMUNITY_TOKEN = os.environ.get("OBLITERATUS_HUB_TOKEN")
351
 
352
  # Import preset configs for Advanced Settings defaults
 
477
  "Invalid repo format β€” use `username/model-name` "
478
  "(letters, numbers, hyphens, dots only)"
479
  )
480
+ if not os.environ.get("HF_TOKEN") and not os.environ.get("HF_PUSH_TOKEN") and not _HUB_COMMUNITY_TOKEN:
481
  warnings.append(
482
  "No Hub token available β€” push will fail. "
483
+ "Set HF_PUSH_TOKEN, HF_TOKEN, or OBLITERATUS_HUB_TOKEN."
484
  )
485
  if warnings:
486
  return "**Warning:** " + " | ".join(warnings)
 
622
  # Resolve token
623
  token = hub_token_input.strip() if hub_token_input else None
624
  if not token:
625
+ token = os.environ.get("HF_PUSH_TOKEN") or os.environ.get("HF_TOKEN") or _HUB_COMMUNITY_TOKEN
626
  if not token:
627
  yield (
628
  "**Error:** No Hub token available. Enter a token above, "
629
+ "or set `HF_PUSH_TOKEN`, `HF_TOKEN`, or `OBLITERATUS_HUB_TOKEN` as an environment variable.",
630
  "",
631
  )
632
  return
 
1875
 
1876
  # Early validation: gated model access
1877
  from obliteratus.presets import is_gated
1878
+ if is_gated(model_id) and not (os.environ.get("HF_TOKEN") or os.environ.get("HF_PUSH_TOKEN")):
1879
  yield (
1880
  f"**Error: Gated model requires authentication.**\n\n"
1881
  f"`{model_id}` is a gated HuggingFace repo. To use it:\n\n"
1882
  f"1. **Accept the license** at [huggingface.co/{model_id}](https://huggingface.co/{model_id})\n"
1883
+ f"2. **Set HF_TOKEN** (or `HF_PUSH_TOKEN`) in your Space secrets (Settings β†’ Variables and secrets)\n"
1884
  f" or locally: `export HF_TOKEN=hf_...`\n\n"
1885
  f"Get your token at [huggingface.co/settings/tokens](https://huggingface.co/settings/tokens)\n\n"
1886
  f"Alternatively, choose a non-gated model (those without the \U0001f512 icon).",
 
4840
  label="HF Token (optional)",
4841
  placeholder="hf_...",
4842
  type="password",
4843
+ info="Leave blank to use HF_PUSH_TOKEN / HF_TOKEN env var or community token",
4844
  )
4845
  push_repo_warning = gr.Markdown("")
4846
 
 
4994
  diag.append(f"- On HF Spaces: `{_ON_HF_SPACES}`")
4995
  diag.append(f"- Repo: `{_TELEMETRY_REPO or '(not set)'}`")
4996
  diag.append(f"- HF_TOKEN set: `{bool(os.environ.get('HF_TOKEN'))}`")
4997
+ diag.append(f"- HF_PUSH_TOKEN set: `{bool(os.environ.get('HF_PUSH_TOKEN'))}`")
4998
  diag.append(f"- Local file: `{TELEMETRY_FILE}`")
4999
  diag.append(f"- Local file exists: `{TELEMETRY_FILE.exists()}`")
5000
  n_records = len(read_telemetry()) if TELEMETRY_FILE.exists() else 0
obliteratus/.DS_Store CHANGED
Binary files a/obliteratus/.DS_Store and b/obliteratus/.DS_Store differ
 
obliteratus/abliterate.py CHANGED
@@ -6069,7 +6069,8 @@ class AbliterationPipeline:
6069
  if self.push_to_hub:
6070
  from huggingface_hub import HfApi
6071
 
6072
- api = HfApi(token=self.hub_token) if self.hub_token else HfApi()
 
6073
 
6074
  # Resolve "auto" β†’ {namespace}/{short_model}-OBLITERATED
6075
  if self.push_to_hub == "auto":
 
6069
  if self.push_to_hub:
6070
  from huggingface_hub import HfApi
6071
 
6072
+ _fallback_token = os.environ.get("HF_PUSH_TOKEN") or os.environ.get("HF_TOKEN") or None
6073
+ api = HfApi(token=self.hub_token) if self.hub_token else (HfApi(token=_fallback_token) if _fallback_token else HfApi())
6074
 
6075
  # Resolve "auto" β†’ {namespace}/{short_model}-OBLITERATED
6076
  if self.push_to_hub == "auto":
obliteratus/telemetry.py CHANGED
@@ -325,7 +325,7 @@ def _ensure_hub_repo(repo_id: str) -> bool:
325
  return True
326
  try:
327
  from huggingface_hub import HfApi
328
- api = HfApi(token=os.environ.get("HF_TOKEN"))
329
  # First try create_repo (works if we own the namespace)
330
  try:
331
  api.create_repo(
@@ -380,7 +380,7 @@ def _sync_to_hub_bg() -> None:
380
  from huggingface_hub import HfApi
381
  if not _ensure_hub_repo(repo):
382
  return
383
- api = HfApi(token=os.environ.get("HF_TOKEN"))
384
  slug = _instance_slug()
385
  api.upload_file(
386
  path_or_fileobj=str(TELEMETRY_FILE),
@@ -869,7 +869,7 @@ def push_to_hub(repo_id: str | None = None) -> bool:
869
  if not _ensure_hub_repo(repo):
870
  return False
871
 
872
- api = HfApi(token=os.environ.get("HF_TOKEN"))
873
  slug = _instance_slug()
874
  api.upload_file(
875
  path_or_fileobj=str(TELEMETRY_FILE),
 
325
  return True
326
  try:
327
  from huggingface_hub import HfApi
328
+ api = HfApi(token=os.environ.get("HF_PUSH_TOKEN") or os.environ.get("HF_TOKEN"))
329
  # First try create_repo (works if we own the namespace)
330
  try:
331
  api.create_repo(
 
380
  from huggingface_hub import HfApi
381
  if not _ensure_hub_repo(repo):
382
  return
383
+ api = HfApi(token=os.environ.get("HF_PUSH_TOKEN") or os.environ.get("HF_TOKEN"))
384
  slug = _instance_slug()
385
  api.upload_file(
386
  path_or_fileobj=str(TELEMETRY_FILE),
 
869
  if not _ensure_hub_repo(repo):
870
  return False
871
 
872
+ api = HfApi(token=os.environ.get("HF_PUSH_TOKEN") or os.environ.get("HF_TOKEN"))
873
  slug = _instance_slug()
874
  api.upload_file(
875
  path_or_fileobj=str(TELEMETRY_FILE),
obliteratus/tourney.py CHANGED
@@ -17,6 +17,7 @@ from __future__ import annotations
17
  import gc
18
  import json
19
  import math
 
20
  import shutil
21
  import time
22
  from dataclasses import dataclass, field
@@ -1460,7 +1461,8 @@ class TourneyRunner:
1460
 
1461
  self.log(f"\nPushing winner to Hub: {repo_id}")
1462
 
1463
- api = HfApi()
 
1464
  api.create_repo(repo_id, exist_ok=True)
1465
 
1466
  # Write model card
 
17
  import gc
18
  import json
19
  import math
20
+ import os
21
  import shutil
22
  import time
23
  from dataclasses import dataclass, field
 
1461
 
1462
  self.log(f"\nPushing winner to Hub: {repo_id}")
1463
 
1464
+ _token = os.environ.get("HF_PUSH_TOKEN") or os.environ.get("HF_TOKEN") or None
1465
+ api = HfApi(token=_token) if _token else HfApi()
1466
  api.create_repo(repo_id, exist_ok=True)
1467
 
1468
  # Write model card