Spaces:
Running
Running
adds better huggingface deploy
Browse files- scripts/dataset_tonic/setup_hf_dataset.py +15 -2
- scripts/training/train.py +5 -3
- test_pipeline.py +125 -0
scripts/dataset_tonic/setup_hf_dataset.py
CHANGED
@@ -267,10 +267,23 @@ def setup_trackio_dataset():
|
|
267 |
dataset.push_to_hub(
|
268 |
dataset_repo,
|
269 |
token=hf_token,
|
270 |
-
private=
|
271 |
-
readme_content=readme_content # Include README if available
|
272 |
)
|
273 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
274 |
print(f"β
Successfully created dataset: {dataset_repo}")
|
275 |
print(f"π Added {len(initial_experiments)} experiments")
|
276 |
if readme_content:
|
|
|
267 |
dataset.push_to_hub(
|
268 |
dataset_repo,
|
269 |
token=hf_token,
|
270 |
+
private=False # Make it private for security
|
|
|
271 |
)
|
272 |
|
273 |
+
# Create README separately if available
|
274 |
+
if readme_content:
|
275 |
+
try:
|
276 |
+
api.upload_file(
|
277 |
+
path_or_fileobj=readme_content.encode('utf-8'),
|
278 |
+
path_in_repo="README.md",
|
279 |
+
repo_id=dataset_repo,
|
280 |
+
repo_type="dataset",
|
281 |
+
token=hf_token
|
282 |
+
)
|
283 |
+
print("π Uploaded README.md separately")
|
284 |
+
except Exception as e:
|
285 |
+
print(f"β οΈ Could not upload README: {e}")
|
286 |
+
|
287 |
print(f"β
Successfully created dataset: {dataset_repo}")
|
288 |
print(f"π Added {len(initial_experiments)} experiments")
|
289 |
if readme_content:
|
scripts/training/train.py
CHANGED
@@ -56,11 +56,13 @@ def main():
|
|
56 |
|
57 |
args = parser.parse_args()
|
58 |
|
59 |
-
# Add the
|
60 |
-
|
|
|
61 |
|
62 |
# Import the configuration
|
63 |
try:
|
|
|
64 |
from config.train_smollm3_openhermes_fr_a100_large import get_config as get_large_config
|
65 |
from config.train_smollm3_openhermes_fr_a100_multiple_passes import get_config as get_multiple_passes_config
|
66 |
from config.train_smollm3_h100_lightweight import config as h100_lightweight_config
|
@@ -128,7 +130,7 @@ def main():
|
|
128 |
# Import and run training
|
129 |
try:
|
130 |
# Add src directory to path
|
131 |
-
src_path = str(
|
132 |
sys.path.insert(0, src_path)
|
133 |
from train import main as train_main
|
134 |
|
|
|
56 |
|
57 |
args = parser.parse_args()
|
58 |
|
59 |
+
# Add the project root to Python path
|
60 |
+
project_root = Path(__file__).parent.parent.parent
|
61 |
+
sys.path.insert(0, str(project_root))
|
62 |
|
63 |
# Import the configuration
|
64 |
try:
|
65 |
+
# Import all available configurations
|
66 |
from config.train_smollm3_openhermes_fr_a100_large import get_config as get_large_config
|
67 |
from config.train_smollm3_openhermes_fr_a100_multiple_passes import get_config as get_multiple_passes_config
|
68 |
from config.train_smollm3_h100_lightweight import config as h100_lightweight_config
|
|
|
130 |
# Import and run training
|
131 |
try:
|
132 |
# Add src directory to path
|
133 |
+
src_path = str(project_root / "src")
|
134 |
sys.path.insert(0, src_path)
|
135 |
from train import main as train_main
|
136 |
|
test_pipeline.py
ADDED
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python3
|
2 |
+
"""
|
3 |
+
Test script to verify the training pipeline works correctly
|
4 |
+
"""
|
5 |
+
|
6 |
+
import sys
|
7 |
+
import os
|
8 |
+
from pathlib import Path
|
9 |
+
|
10 |
+
# Add project root to path
|
11 |
+
project_root = Path(__file__).parent
|
12 |
+
sys.path.insert(0, str(project_root))
|
13 |
+
|
14 |
+
def test_config_imports():
|
15 |
+
"""Test that all configuration files can be imported correctly"""
|
16 |
+
print("π§ͺ Testing configuration imports...")
|
17 |
+
|
18 |
+
try:
|
19 |
+
# Test base config only
|
20 |
+
from config.train_smollm3 import SmolLM3Config, get_config
|
21 |
+
print("β
Base config imported successfully")
|
22 |
+
|
23 |
+
# Test H100 lightweight config (without triggering __post_init__)
|
24 |
+
import importlib.util
|
25 |
+
spec = importlib.util.spec_from_file_location("h100_config", "config/train_smollm3_h100_lightweight.py")
|
26 |
+
h100_module = importlib.util.module_from_spec(spec)
|
27 |
+
spec.loader.exec_module(h100_module)
|
28 |
+
print("β
H100 lightweight config imported successfully")
|
29 |
+
|
30 |
+
return True
|
31 |
+
|
32 |
+
except ImportError as e:
|
33 |
+
print(f"β Import error: {e}")
|
34 |
+
return False
|
35 |
+
|
36 |
+
def test_training_script():
|
37 |
+
"""Test that the training script can be imported"""
|
38 |
+
print("\nπ§ͺ Testing training script...")
|
39 |
+
|
40 |
+
try:
|
41 |
+
# Add src to path
|
42 |
+
src_path = str(project_root / "src")
|
43 |
+
sys.path.insert(0, src_path)
|
44 |
+
|
45 |
+
# Test importing training modules
|
46 |
+
from train import main as train_main
|
47 |
+
print("β
Training script imported successfully")
|
48 |
+
|
49 |
+
from model import SmolLM3Model
|
50 |
+
print("β
Model module imported successfully")
|
51 |
+
|
52 |
+
from data import load_dataset
|
53 |
+
print("β
Data module imported successfully")
|
54 |
+
|
55 |
+
from monitoring import SmolLM3Monitor, create_monitor_from_config
|
56 |
+
print("β
Monitoring module imported successfully")
|
57 |
+
|
58 |
+
return True
|
59 |
+
|
60 |
+
except ImportError as e:
|
61 |
+
print(f"β Import error: {e}")
|
62 |
+
return False
|
63 |
+
|
64 |
+
def test_scripts():
|
65 |
+
"""Test that the scripts can be imported"""
|
66 |
+
print("\nπ§ͺ Testing scripts...")
|
67 |
+
|
68 |
+
try:
|
69 |
+
# Test dataset setup script
|
70 |
+
sys.path.insert(0, str(project_root / "scripts" / "dataset_tonic"))
|
71 |
+
from setup_hf_dataset import setup_trackio_dataset
|
72 |
+
print("β
Dataset setup script imported successfully")
|
73 |
+
|
74 |
+
# Test trackio scripts
|
75 |
+
sys.path.insert(0, str(project_root / "scripts" / "trackio_tonic"))
|
76 |
+
from deploy_trackio_space import TrackioSpaceDeployer
|
77 |
+
print("β
Trackio deployment script imported successfully")
|
78 |
+
|
79 |
+
from configure_trackio import configure_trackio
|
80 |
+
print("β
Trackio configuration script imported successfully")
|
81 |
+
|
82 |
+
# Test model push script
|
83 |
+
sys.path.insert(0, str(project_root / "scripts" / "model_tonic"))
|
84 |
+
from push_to_huggingface import HuggingFacePusher
|
85 |
+
print("β
Model push script imported successfully")
|
86 |
+
|
87 |
+
return True
|
88 |
+
|
89 |
+
except ImportError as e:
|
90 |
+
print(f"β Import error: {e}")
|
91 |
+
return False
|
92 |
+
|
93 |
+
def main():
|
94 |
+
"""Run all tests"""
|
95 |
+
print("π Testing SmolLM3 Fine-tuning Pipeline")
|
96 |
+
print("=" * 50)
|
97 |
+
|
98 |
+
tests = [
|
99 |
+
test_config_imports,
|
100 |
+
test_training_script,
|
101 |
+
test_scripts
|
102 |
+
]
|
103 |
+
|
104 |
+
passed = 0
|
105 |
+
total = len(tests)
|
106 |
+
|
107 |
+
for test in tests:
|
108 |
+
if test():
|
109 |
+
passed += 1
|
110 |
+
print()
|
111 |
+
|
112 |
+
print("=" * 50)
|
113 |
+
print(f"π Test Results: {passed}/{total} tests passed")
|
114 |
+
|
115 |
+
if passed == total:
|
116 |
+
print("π All tests passed! Pipeline is ready to use.")
|
117 |
+
print("\nπ You can now run: ./launch.sh")
|
118 |
+
else:
|
119 |
+
print("β Some tests failed. Please check the errors above.")
|
120 |
+
return 1
|
121 |
+
|
122 |
+
return 0
|
123 |
+
|
124 |
+
if __name__ == "__main__":
|
125 |
+
exit(main())
|