trying changes to git stuff
Browse files- colab_test_file.txt +0 -1
- scripts/train.py +12 -3
colab_test_file.txt
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
This file was created in Google Colab and pushed to the Hugging Face repo.
|
|
|
|
|
|
scripts/train.py
CHANGED
|
@@ -71,7 +71,7 @@ def main():
|
|
| 71 |
|
| 72 |
# Training arguments
|
| 73 |
training_args = TrainingArguments(
|
| 74 |
-
output_dir="./
|
| 75 |
per_device_train_batch_size=2,
|
| 76 |
gradient_accumulation_steps=8,
|
| 77 |
learning_rate=1e-4,
|
|
@@ -140,9 +140,18 @@ def main():
|
|
| 140 |
class GitPushCallback(TrainerCallback):
|
| 141 |
def on_save(self, args, state, control, **kwargs):
|
| 142 |
try:
|
| 143 |
-
print("
|
|
|
|
|
|
|
| 144 |
subprocess.run(["git", "add", "."], check=True)
|
| 145 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
subprocess.run(["git", "push"], check=True)
|
| 147 |
print("Checkpoint pushed successfully.")
|
| 148 |
except subprocess.CalledProcessError as e:
|
|
|
|
| 71 |
|
| 72 |
# Training arguments
|
| 73 |
training_args = TrainingArguments(
|
| 74 |
+
output_dir="./checkpoints",
|
| 75 |
per_device_train_batch_size=2,
|
| 76 |
gradient_accumulation_steps=8,
|
| 77 |
learning_rate=1e-4,
|
|
|
|
| 140 |
class GitPushCallback(TrainerCallback):
|
| 141 |
def on_save(self, args, state, control, **kwargs):
|
| 142 |
try:
|
| 143 |
+
print("Saving checkpoint to Git repo...")
|
| 144 |
+
|
| 145 |
+
# Add all changes (you can scope this to ./checkpoints/ if desired)
|
| 146 |
subprocess.run(["git", "add", "."], check=True)
|
| 147 |
+
|
| 148 |
+
# Skip commit if no changes
|
| 149 |
+
result = subprocess.run(["git", "diff", "--cached", "--quiet"])
|
| 150 |
+
if result.returncode == 0:
|
| 151 |
+
print("No changes to commit.")
|
| 152 |
+
return
|
| 153 |
+
|
| 154 |
+
subprocess.run(["git", "commit", "-m", f'Checkpoint at step {state.global_step}'], check=True)
|
| 155 |
subprocess.run(["git", "push"], check=True)
|
| 156 |
print("Checkpoint pushed successfully.")
|
| 157 |
except subprocess.CalledProcessError as e:
|