Mightys commited on
Commit
90afb85
·
verified ·
1 Parent(s): cd2fdab

Update Swarmui_Lightning/symb.py

Browse files
Files changed (1) hide show
  1. Swarmui_Lightning/symb.py +8 -29
Swarmui_Lightning/symb.py CHANGED
@@ -1,43 +1,22 @@
1
- # symb.py
2
- import os
3
  import subprocess
4
  from pathlib import Path
5
 
6
- # ---------- configuración ----------
7
- TOKEN_CIVITAI = "TUTOKENCIVITAI"
8
- STORE_FILE = Path.home() / ".civitai_token.pkl" # sustituto de %store
9
- # -----------------------------------
10
-
11
- def _store(var: str, val: str) -> None:
12
- """Simula %store var val (persistente entre kernels)."""
13
- import pickle, builtins
14
- # escribe en el archivo
15
- data = {var: val}
16
- STORE_FILE.write_bytes(pickle.dumps(data))
17
- # opcional: también lo deja disponible en builtins para este kernel
18
- setattr(builtins, var, val)
19
- print(f"✅ Variable '{var}' guardada en {STORE_FILE} (persistente).")
20
-
21
  def _run(cmd: str) -> None:
22
- """Ejecuta un comando shell y muestra la salida."""
23
  print(f"+ {cmd}")
24
  subprocess.run(cmd, shell=True, check=False)
25
 
26
- def preparar():
27
- """Función principal: guarda el token y crea enlaces."""
28
- if not TOKEN_CIVITAI.strip():
29
- print("⚠️ No se ingresó token.")
30
- return
31
- _store("token_civitai", TOKEN_CIVITAI)
32
-
33
- # limpieza y enlaces
34
  cmds = [
35
  "rm -rf /teamspace/studios/this_studio/.cache",
36
  "rm -rf /teamspace/studios/this_studio/tmp ~/tmp",
37
  "ln -vs /tmp ~/tmp",
38
  "rm -rf /teamspace/studios/this_studio/SwarmUI/Models/Stable-Diffusion/tmp_models",
39
  "mkdir -p /tmp/models",
40
- "ln -vs /tmp/models /teamspace/studios/this_studio/SwarmUI/Models/Lora/tmp_lora",
41
  "rm -rf /teamspace/studios/this_studio/SwarmUI/Models/Lora/tmp_lora",
42
  "mkdir -p /tmp/lora",
43
  "ln -vs /tmp/lora /teamspace/studios/this_studio/SwarmUI/Models/Lora/tmp_lora",
@@ -56,7 +35,7 @@ def preparar():
56
  ]
57
  for c in cmds:
58
  _run(c)
59
- print("🎉 Entorno listo.")
60
 
61
  if __name__ == "__main__":
62
- preparar()
 
1
+ #!/usr/bin/env python3
2
+ # swarmui_tmp_links.py – solo enlaza carpetas temporales de SwarmUI
3
  import subprocess
4
  from pathlib import Path
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  def _run(cmd: str) -> None:
 
7
  print(f"+ {cmd}")
8
  subprocess.run(cmd, shell=True, check=False)
9
 
10
+ def enlaces_tmp_swarm() -> None:
11
+ """Crea enlaces simbólicos para que SwarmUI use /tmp y libere espacio en disco."""
12
+ base = Path("/teamspace/studios/this_studio")
 
 
 
 
 
13
  cmds = [
14
  "rm -rf /teamspace/studios/this_studio/.cache",
15
  "rm -rf /teamspace/studios/this_studio/tmp ~/tmp",
16
  "ln -vs /tmp ~/tmp",
17
  "rm -rf /teamspace/studios/this_studio/SwarmUI/Models/Stable-Diffusion/tmp_models",
18
  "mkdir -p /tmp/models",
19
+ "ln -vs /tmp/models /teamspace/studios/this_studio/SwarmUI/Models/Stable-Diffusion/tmp_models",
20
  "rm -rf /teamspace/studios/this_studio/SwarmUI/Models/Lora/tmp_lora",
21
  "mkdir -p /tmp/lora",
22
  "ln -vs /tmp/lora /teamspace/studios/this_studio/SwarmUI/Models/Lora/tmp_lora",
 
35
  ]
36
  for c in cmds:
37
  _run(c)
38
+ print(" Carpetas temporales de SwarmUI enlazadas.")
39
 
40
  if __name__ == "__main__":
41
+ enlaces_tmp_swarm()