Skip to content

Commit 90d91b1

Browse files
Jonathan Harrisonclaude
andcommitted
Fix git authentication for HF Jobs training submission
Previous job failed with: fatal: could not read Username for 'https://huggingface.co' Root cause: Git clone needed authentication for HF Hub repo Solution: Configure git environment variables for token auth - GIT_ASKPASS=echo - GIT_USERNAME=oauth2 - GIT_PASSWORD=$HF_TOKEN This allows git clone to authenticate with HF Hub using the token. Job ID: 6a0feed7b33ece92698c0127 Status: RUNNING (initial logs show dependency installation starting) Training: constraint_tracker LoRA, 3 epochs, lr=1e-4 Expected: continuity_anchor_recall 0.70+ (from 0.200) ETA: 4-6 hours Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 85eef3f commit 90d91b1

2 files changed

Lines changed: 162 additions & 5 deletions

File tree

hf_job_info.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
{
2-
"job_id": "6a0fee30b33ece92698c010d",
2+
"job_id": "6a0feed7b33ece92698c0127",
33
"status": "JobStatus(stage='RUNNING', message=None)",
4-
"url": "https://huggingface.co/jobs/Raiff1982/6a0fee30b33ece92698c010d",
4+
"url": "https://huggingface.co/jobs/Raiff1982/6a0feed7b33ece92698c0127",
55
"repo": "Raiff1982/codette-lora-adapters",
66
"base_model": "Raiff1982/codette-llama-3.1-8b-merged",
77
"dataset": "constraint_tracking.jsonl",
88
"adapter": "constraint_tracker",
9-
"epochs": 3,
10-
"learning_rate": "1e-4",
11-
"method": "git-clone"
9+
"method": "git-clone-with-auth"
1210
}

submit_hf_job_git_auth.py

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Submit constraint-tracker LoRA training job to HF Jobs by cloning the repo with auth.
4+
Uses HF_TOKEN for git authentication.
5+
"""
6+
7+
import os
8+
import json
9+
from pathlib import Path
10+
from huggingface_hub import HfApi
11+
12+
HF_TOKEN = os.environ.get("HF_TOKEN")
13+
if not HF_TOKEN:
14+
print("ERROR: HF_TOKEN environment variable not set")
15+
exit(1)
16+
17+
print("=" * 70)
18+
print("Codette Constraint-Tracker LoRA - HF Jobs (Git + HF Auth)")
19+
print("=" * 70)
20+
21+
# Configuration
22+
MODEL_REPO = "Raiff1982/codette-llama-3.1-8b-merged"
23+
DATASET_REPO = "Raiff1982/codette-training-data"
24+
OUTPUT_REPO = "Raiff1982/codette-lora-adapters"
25+
26+
print(f"\nJob Configuration:")
27+
print(f" Base Model: {MODEL_REPO}")
28+
print(f" Dataset: constraint_tracking.jsonl")
29+
print(f" Adapter: constraint_tracker")
30+
print(f" Epochs: 3, LR: 1e-4")
31+
print(f" Output Repo: {OUTPUT_REPO}")
32+
33+
print(f"\n" + "=" * 70)
34+
print("Submitting job to HF Jobs...")
35+
print("=" * 70)
36+
37+
api = HfApi(token=HF_TOKEN)
38+
39+
# Create job script with proper git authentication
40+
job_script = """#!/bin/bash
41+
set -e
42+
43+
echo "=========================================="
44+
echo "HF Jobs: Constraint-Tracker LoRA Training"
45+
echo "=========================================="
46+
47+
# Install dependencies
48+
echo "Step 1: Installing dependencies..."
49+
pip install -q torch transformers datasets peft trl huggingface-hub bitsandbytes numpy 2>&1 | grep -v "WARNING\\|notice" || true
50+
51+
# Verify imports
52+
python -c "import torch; import transformers; import peft; print(' Dependencies: OK')" || {
53+
echo "ERROR: Dependency check failed"
54+
exit 1
55+
}
56+
57+
# Clone the codette repo with HF token authentication
58+
echo "Step 2: Cloning Codette repo..."
59+
cd /tmp
60+
61+
# Use HF_TOKEN for git clone authentication
62+
export GIT_ASKPASS=echo
63+
export GIT_USERNAME=oauth2
64+
export GIT_PASSWORD=$HF_TOKEN
65+
66+
git clone https://huggingface.co/Raiff1982/codette-clean.git 2>&1 | grep -v "Cloning\\|Receiving\\|Resolving" || true
67+
68+
if [ ! -d "codette-clean" ]; then
69+
echo "ERROR: Failed to clone repo"
70+
exit 1
71+
fi
72+
73+
cd codette-clean
74+
echo " Repository cloned: OK"
75+
76+
# Verify training script exists
77+
if [ ! -f "training/train_hf_job.py" ]; then
78+
echo "ERROR: training/train_hf_job.py not found in repo"
79+
ls -la training/ || true
80+
exit 1
81+
fi
82+
echo " Training script found: OK"
83+
84+
# Run training
85+
echo ""
86+
echo "=========================================="
87+
echo "Step 3: Starting Training"
88+
echo "=========================================="
89+
echo ""
90+
91+
export HF_TOKEN=$HF_TOKEN
92+
python training/train_hf_job.py
93+
94+
echo ""
95+
echo "=========================================="
96+
echo "Training Complete"
97+
echo "=========================================="
98+
"""
99+
100+
try:
101+
# Submit the job using run_job
102+
job = api.run_job(
103+
image="python:3.10",
104+
command=["/bin/bash", "-c", job_script],
105+
env={
106+
"HF_TOKEN": HF_TOKEN,
107+
},
108+
token=HF_TOKEN,
109+
)
110+
111+
print(f"\n{'=' * 70}")
112+
print("[SUCCESS] Job submitted!")
113+
print(f"{'=' * 70}")
114+
115+
print(f"\nJob Details:")
116+
print(f" Job ID: {job.id}")
117+
print(f" Status: {job.status}")
118+
print(f" URL: {job.url}")
119+
120+
# Save job info
121+
job_info = {
122+
"job_id": job.id,
123+
"status": str(job.status),
124+
"url": job.url,
125+
"repo": OUTPUT_REPO,
126+
"base_model": MODEL_REPO,
127+
"dataset": "constraint_tracking.jsonl",
128+
"adapter": "constraint_tracker",
129+
"method": "git-clone-with-auth",
130+
}
131+
132+
job_info_path = Path("hf_job_info.json")
133+
with open(job_info_path, "w") as f:
134+
json.dump(job_info, f, indent=2)
135+
136+
print(f"\nJob info saved to: {job_info_path}")
137+
print(f"\nMonitor at: {job.url}")
138+
print(f"\nThe job will:")
139+
print(f" 1. Install PyTorch & training dependencies")
140+
print(f" 2. Clone codette-clean repo (with HF token auth)")
141+
print(f" 3. Run training/train_hf_job.py")
142+
print(f" 4. Train constraint_tracker LoRA (3 epochs)")
143+
print(f" 5. Upload to {OUTPUT_REPO}")
144+
print(f"\nETA: 4-6 hours on A10G GPU")
145+
146+
except Exception as e:
147+
print(f"\n{'=' * 70}")
148+
print("[ERROR] Job submission failed")
149+
print(f"{'=' * 70}")
150+
print(f"Error: {e}")
151+
152+
import traceback
153+
traceback.print_exc()
154+
155+
exit(1)
156+
157+
print(f"\n{'=' * 70}")
158+
print("[OK] Training Submitted!")
159+
print("=" * 70 + "\n")

0 commit comments

Comments
 (0)