Achtik commited on
Commit
a4992c5
·
verified ·
1 Parent(s): 56e95ea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -9
app.py CHANGED
@@ -84,25 +84,48 @@ def clone_trainer() -> None:
84
  try:
85
  if not (TRAINER_DIR / "sd_scripts").exists():
86
  logger.info("Cloning LoRA training scripts repository...")
 
 
87
  clone_cmd = [
88
  "git", "clone",
89
- "--depth", "1",
90
  "https://github.com/derrian-distro/LoRA_Easy_Training_scripts_Backend",
91
  str(TRAINER_DIR)
92
  ]
93
- result = subprocess.run(clone_cmd, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
94
- logger.debug(f"Clone stdout: {result.stdout}")
95
 
96
- reset_cmd = ["git", "reset", "--hard", COMMIT_HASH]
97
- subprocess.run(reset_cmd, cwd=TRAINER_DIR, check=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  logger.info("Successfully cloned and configured training scripts")
99
 
100
- if (TRAINER_DIR / "requirements.txt").exists():
 
 
101
  logger.info("Installing additional requirements...")
102
- subprocess.run(["pip", "install", "-r", str(TRAINER_DIR / "requirements.txt")], check=True)
 
 
 
 
103
  except subprocess.CalledProcessError as e:
104
- logger.error(f"Failed to clone/setup training scripts: {e.stderr}")
105
- raise RuntimeError(f"Repository setup failed: {e.stderr}")
 
106
 
107
  def validate_hf_dataset(repo_id: str) -> bool:
108
  """Validate the HuggingFace dataset before downloading"""
 
84
  try:
85
  if not (TRAINER_DIR / "sd_scripts").exists():
86
  logger.info("Cloning LoRA training scripts repository...")
87
+
88
+ # 1. Najpierw klonujemy pełne repozytorium (bez --depth 1)
89
  clone_cmd = [
90
  "git", "clone",
 
91
  "https://github.com/derrian-distro/LoRA_Easy_Training_scripts_Backend",
92
  str(TRAINER_DIR)
93
  ]
 
 
94
 
95
+ result = subprocess.run(
96
+ clone_cmd,
97
+ check=True,
98
+ stdout=subprocess.PIPE,
99
+ stderr=subprocess.PIPE,
100
+ text=True
101
+ )
102
+
103
+ # 2. Przechodzimy do konkretnej wersji
104
+ reset_cmd = ["git", "checkout", COMMIT_HASH]
105
+ subprocess.run(
106
+ reset_cmd,
107
+ cwd=TRAINER_DIR,
108
+ check=True,
109
+ stdout=subprocess.PIPE,
110
+ stderr=subprocess.PIPE,
111
+ text=True
112
+ )
113
+
114
  logger.info("Successfully cloned and configured training scripts")
115
 
116
+ # 3. Instalacja wymaganych zależności
117
+ requirements_file = TRAINER_DIR / "requirements.txt"
118
+ if requirements_file.exists():
119
  logger.info("Installing additional requirements...")
120
+ subprocess.run(
121
+ ["pip", "install", "-r", str(requirements_file)],
122
+ check=True
123
+ )
124
+
125
  except subprocess.CalledProcessError as e:
126
+ error_msg = f"Failed to clone/setup training scripts: {e.stderr or str(e)}"
127
+ logger.error(error_msg)
128
+ raise RuntimeError(error_msg)
129
 
130
  def validate_hf_dataset(repo_id: str) -> bool:
131
  """Validate the HuggingFace dataset before downloading"""