geekwrestler commited on
Commit
1901fee
·
verified ·
1 Parent(s): 5f43c7d

Deploy Her (Gradio Server / ZeroGPU + bucket + per-client isolation + enrichment)

Browse files
Files changed (1) hide show
  1. scripts/deploy.py +20 -0
scripts/deploy.py CHANGED
@@ -20,6 +20,7 @@ from __future__ import annotations
20
 
21
  import argparse
22
  import os
 
23
  import sys
24
  import time
25
 
@@ -33,6 +34,7 @@ IGNORE = [
33
  ".venv-deploy/**", ".venv/**", "venv/**", "**/.venv*/**",
34
  "**/__pycache__/**", "**/*.pyc", "node_modules/**", "**/node_modules/**",
35
  ".uploads/**", "her-staging/**", "**/*.gguf", "models/**", "fixtures/*.jsonl",
 
36
  "ui/public/fixture-analysis*.json", "ui/public/binary-logos/**",
37
  "narrator/knowledge/binaries.learned.json", "narrator/.cache/**",
38
  "**/*.log", ".env", ".env.*", "cloudflare/**", "**/.DS_Store",
@@ -112,6 +114,24 @@ def main() -> int:
112
  commit_message="Bundle sanitized demo session")
113
  print(" bundled demo session", flush=True)
114
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  # 6) ZeroGPU
116
  if not args.no_zerogpu:
117
  try:
 
20
 
21
  import argparse
22
  import os
23
+ import re
24
  import sys
25
  import time
26
 
 
34
  ".venv-deploy/**", ".venv/**", "venv/**", "**/.venv*/**",
35
  "**/__pycache__/**", "**/*.pyc", "node_modules/**", "**/node_modules/**",
36
  ".uploads/**", "her-staging/**", "**/*.gguf", "models/**", "fixtures/*.jsonl",
37
+ "scripts/her_upload.py", # shipped via a per-space-patched step below, not verbatim
38
  "ui/public/fixture-analysis*.json", "ui/public/binary-logos/**",
39
  "narrator/knowledge/binaries.learned.json", "narrator/.cache/**",
40
  "**/*.log", ".env", ".env.*", "cloudflare/**", "**/.DS_Store",
 
114
  commit_message="Bundle sanitized demo session")
115
  print(" bundled demo session", flush=True)
116
 
117
+ # 5c) the bundled uploader (her_upload.py) — ship a copy whose DEFAULT_SPACE points at
118
+ # THIS space, not the author's. Otherwise a visitor who grabs it from the public Files
119
+ # tab would upload their sessions into someone else's Space. Excluded from the folder
120
+ # upload above; patched + shipped here so each deploy self-references its own target.
121
+ up = os.path.join(REPO_DIR, "scripts", "her_upload.py")
122
+ if os.path.isfile(up):
123
+ src = open(up, encoding="utf-8").read()
124
+ patched, n = re.subn(r'^DEFAULT_SPACE = "[^"]*"',
125
+ f'DEFAULT_SPACE = "{args.space}"', src, count=1, flags=re.M)
126
+ if n != 1:
127
+ print(" !! could not patch her_upload.py DEFAULT_SPACE — shipping verbatim", flush=True)
128
+ patched = src
129
+ api.upload_file(path_or_fileobj=patched.encode("utf-8"),
130
+ path_in_repo="scripts/her_upload.py",
131
+ repo_id=args.space, repo_type="space",
132
+ commit_message=f"Point bundled uploader at {args.space}")
133
+ print(f" bundled uploader → DEFAULT_SPACE={args.space}", flush=True)
134
+
135
  # 6) ZeroGPU
136
  if not args.no_zerogpu:
137
  try: