Spaces:
Running
Running
Skip local LoRA download on HF Spaces, clean up training uploads
Browse filesLoRA is saved to RunPod network volume (ready for generation).
Local download skipped on HF to avoid filling 1GB storage limit.
Training upload images cleaned up after upload to RunPod.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
src/content_engine/services/runpod_trainer.py
CHANGED
|
@@ -654,14 +654,17 @@ resolution = [{resolution}, {resolution}]
|
|
| 654 |
self._ssh_exec(ssh, f"cp {remote_output} /runpod-volume/loras/{name}.safetensors")
|
| 655 |
job._log(f"LoRA saved to volume: /runpod-volume/loras/{name}.safetensors")
|
| 656 |
|
| 657 |
-
#
|
| 658 |
-
|
| 659 |
-
|
| 660 |
-
|
| 661 |
-
|
| 662 |
-
|
| 663 |
-
|
| 664 |
-
|
|
|
|
|
|
|
|
|
|
| 665 |
|
| 666 |
# Done!
|
| 667 |
job.status = "completed"
|
|
@@ -689,6 +692,13 @@ resolution = [{resolution}, {resolution}]
|
|
| 689 |
except Exception:
|
| 690 |
pass
|
| 691 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 692 |
if job.pod_id:
|
| 693 |
try:
|
| 694 |
job._log("Terminating RunPod...")
|
|
|
|
| 654 |
self._ssh_exec(ssh, f"cp {remote_output} /runpod-volume/loras/{name}.safetensors")
|
| 655 |
job._log(f"LoRA saved to volume: /runpod-volume/loras/{name}.safetensors")
|
| 656 |
|
| 657 |
+
# Download locally (skip on HF Spaces — limited storage)
|
| 658 |
+
if IS_HF_SPACES:
|
| 659 |
+
job.output_path = f"/runpod-volume/loras/{name}.safetensors"
|
| 660 |
+
job._log("LoRA saved on RunPod volume (ready for generation)")
|
| 661 |
+
else:
|
| 662 |
+
job._log("Downloading LoRA to local machine...")
|
| 663 |
+
LORA_OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
|
| 664 |
+
local_path = LORA_OUTPUT_DIR / f"{name}.safetensors"
|
| 665 |
+
sftp.get(remote_output, str(local_path))
|
| 666 |
+
job.output_path = str(local_path)
|
| 667 |
+
job._log(f"LoRA saved locally to {local_path}")
|
| 668 |
|
| 669 |
# Done!
|
| 670 |
job.status = "completed"
|
|
|
|
| 692 |
except Exception:
|
| 693 |
pass
|
| 694 |
|
| 695 |
+
# Clean up local training images (saves HF Spaces storage)
|
| 696 |
+
if image_paths:
|
| 697 |
+
import shutil
|
| 698 |
+
first_image_dir = Path(image_paths[0]).parent
|
| 699 |
+
if first_image_dir.exists() and "training_uploads" in str(first_image_dir):
|
| 700 |
+
shutil.rmtree(first_image_dir, ignore_errors=True)
|
| 701 |
+
|
| 702 |
if job.pod_id:
|
| 703 |
try:
|
| 704 |
job._log("Terminating RunPod...")
|