thadillo Claude commited on
Commit
b08ba59
·
1 Parent(s): 0a4e3e9

Fix: Use /data/models/finetuned for HF Spaces training

Browse files

Changes:
- Updated all model paths from 'models/finetuned' to '/data/models/finetuned'
- Create /data/models/finetuned directory in Dockerfile
- Fixes Permission denied error on HF Spaces training

Files updated:
- app/routes/admin.py (2 locations)
- app/fine_tuning/model_manager.py
- Dockerfile (create models directory)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

Dockerfile CHANGED
@@ -26,6 +26,9 @@ RUN mkdir -p /data && chmod 777 /data
26
  # Create cache directory for Hugging Face models
27
  RUN mkdir -p /data/.cache/huggingface && chmod -R 777 /data/.cache
28
 
 
 
 
29
  # Create model cache in container (not in /data) to save persistent storage
30
  RUN mkdir -p /app/.cache && chmod -R 777 /app/.cache
31
 
 
26
  # Create cache directory for Hugging Face models
27
  RUN mkdir -p /data/.cache/huggingface && chmod -R 777 /data/.cache
28
 
29
+ # Create models directory for fine-tuned models
30
+ RUN mkdir -p /data/models/finetuned && chmod -R 777 /data/models
31
+
32
  # Create model cache in container (not in /data) to save persistent storage
33
  RUN mkdir -p /app/.cache && chmod -R 777 /app/.cache
34
 
app/fine_tuning/model_manager.py CHANGED
@@ -29,8 +29,8 @@ class ModelManager:
29
  (defaults to MODELS_DIR env var or './models/finetuned')
30
  """
31
  if models_dir is None:
32
- # Use environment variable or local path
33
- models_dir = os.getenv('MODELS_DIR', 'models/finetuned')
34
 
35
  self.models_dir = models_dir
36
  self.base_model_name = "facebook/bart-large-mnli"
 
29
  (defaults to MODELS_DIR env var or './models/finetuned')
30
  """
31
  if models_dir is None:
32
+ # Use environment variable or /data path for HF Spaces
33
+ models_dir = os.getenv('MODELS_DIR', '/data/models/finetuned')
34
 
35
  self.models_dir = models_dir
36
  self.base_model_name = "facebook/bart-large-mnli"
app/routes/admin.py CHANGED
@@ -1088,7 +1088,7 @@ def _run_training_job(run_id: int, config: Dict):
1088
  db.session.commit()
1089
 
1090
  # Train
1091
- models_dir = os.getenv('MODELS_DIR', 'models/finetuned')
1092
  output_dir = os.path.join(models_dir, f'run_{run_id}')
1093
 
1094
  training_config = {
@@ -1656,7 +1656,7 @@ def import_model():
1656
  db.session.commit()
1657
 
1658
  # Copy model to models directory
1659
- models_dir = os.getenv('MODELS_DIR', 'models/finetuned')
1660
  destination_path = os.path.join(models_dir, f'run_{training_run.id}')
1661
 
1662
  shutil.copytree(model_dir, destination_path)
 
1088
  db.session.commit()
1089
 
1090
  # Train
1091
+ models_dir = os.getenv('MODELS_DIR', '/data/models/finetuned')
1092
  output_dir = os.path.join(models_dir, f'run_{run_id}')
1093
 
1094
  training_config = {
 
1656
  db.session.commit()
1657
 
1658
  # Copy model to models directory
1659
+ models_dir = os.getenv('MODELS_DIR', '/data/models/finetuned')
1660
  destination_path = os.path.join(models_dir, f'run_{training_run.id}')
1661
 
1662
  shutil.copytree(model_dir, destination_path)