Spaces:
Running
Running
Joseph Pollack
commited on
adds wandb and timeouts for trackio, removes 'syntax error'
Browse files- requirements.txt +1 -0
- scripts/__pycache__/train.cpython-313.pyc +0 -0
- scripts/__pycache__/train_lora.cpython-313.pyc +0 -0
- scripts/deploy_demo_space.py +39 -39
- scripts/train.py +2 -2
- scripts/train_lora.py +2 -2
- simple_test.py +42 -0
- tests/test_fixes.py +74 -0
- test_wandb_integration.py β tests/test_wandb_integration.py +0 -0
requirements.txt
CHANGED
@@ -6,6 +6,7 @@ datasets
|
|
6 |
peft
|
7 |
transformers
|
8 |
gradio
|
|
|
9 |
trackio
|
10 |
huggingface_hub
|
11 |
soundfile
|
|
|
6 |
peft
|
7 |
transformers
|
8 |
gradio
|
9 |
+
gradio[mcp]
|
10 |
trackio
|
11 |
huggingface_hub
|
12 |
soundfile
|
scripts/__pycache__/train.cpython-313.pyc
CHANGED
Binary files a/scripts/__pycache__/train.cpython-313.pyc and b/scripts/__pycache__/train.cpython-313.pyc differ
|
|
scripts/__pycache__/train_lora.cpython-313.pyc
CHANGED
Binary files a/scripts/__pycache__/train_lora.cpython-313.pyc and b/scripts/__pycache__/train_lora.cpython-313.pyc differ
|
|
scripts/deploy_demo_space.py
CHANGED
@@ -192,32 +192,32 @@ class DemoSpaceDeployer:
|
|
192 |
env_setup = f"""
|
193 |
# Environment variables for GPT-OSS model configuration
|
194 |
import os
|
195 |
-
os.environ['HF_MODEL_ID'] = json.dumps(self.model_id)
|
196 |
-
os.environ['LORA_MODEL_ID'] = json.dumps(self.model_id)
|
197 |
os.environ['BASE_MODEL_ID'] = 'openai/gpt-oss-20b'
|
198 |
-
os.environ['MODEL_SUBFOLDER'] = json.dumps(self.subfolder if self.subfolder else "")
|
199 |
-
os.environ['MODEL_NAME'] = json.dumps(model_name)
|
200 |
-
os.environ['MODEL_IDENTITY'] = json.dumps(self.model_identity or "")
|
201 |
-
os.environ['SYSTEM_MESSAGE'] = json.dumps(self.system_message or (self.model_identity or ""))
|
202 |
-
os.environ['DEVELOPER_MESSAGE'] = json.dumps(self.developer_message or "")
|
203 |
-
os.environ['REASONING_EFFORT'] = json.dumps((self.reasoning_effort or "medium"))
|
204 |
{"os.environ['EXAMPLES_TYPE'] = " + _json.dumps(self.examples_type) + "\n" if self.examples_type else ''}
|
205 |
{"os.environ['DISABLE_EXAMPLES'] = 'true'\n" if self.disable_examples else ("os.environ['DISABLE_EXAMPLES'] = 'false'\n" if self.disable_examples is not None else '')}
|
206 |
{"os.environ['EXAMPLES_JSON'] = " + _json.dumps(self.examples_json) + "\n" if self.examples_json else ''}
|
207 |
|
208 |
# Branding/owner variables
|
209 |
-
os.environ['HF_USERNAME'] = json.dumps(self.hf_username)
|
210 |
-
os.environ['BRAND_OWNER_NAME'] = json.dumps(self.brand_owner_name)
|
211 |
-
os.environ['BRAND_TEAM_NAME'] = json.dumps(self.brand_team_name)
|
212 |
-
os.environ['BRAND_DISCORD_URL'] = json.dumps(self.brand_discord_url)
|
213 |
-
os.environ['BRAND_HF_ORG'] = json.dumps(self.brand_hf_org)
|
214 |
-
os.environ['BRAND_HF_LABEL'] = json.dumps(self.brand_hf_label)
|
215 |
-
os.environ['BRAND_HF_URL'] = json.dumps(self.brand_hf_url)
|
216 |
-
os.environ['BRAND_GH_ORG'] = json.dumps(self.brand_gh_org)
|
217 |
-
os.environ['BRAND_GH_LABEL'] = json.dumps(self.brand_gh_label)
|
218 |
-
os.environ['BRAND_GH_URL'] = json.dumps(self.brand_gh_url)
|
219 |
-
os.environ['BRAND_PROJECT_NAME'] = json.dumps(self.brand_project_name)
|
220 |
-
os.environ['BRAND_PROJECT_URL'] = json.dumps(self.brand_project_url)
|
221 |
|
222 |
"""
|
223 |
elif self.demo_type == "voxtral":
|
@@ -230,30 +230,30 @@ os.environ['BRAND_PROJECT_URL'] = json.dumps(self.brand_project_url)}
|
|
230 |
env_setup = f"""
|
231 |
# Environment variables for model configuration
|
232 |
import os
|
233 |
-
os.environ['HF_MODEL_ID'] = json.dumps(self.model_id)
|
234 |
-
os.environ['MODEL_SUBFOLDER'] = json.dumps(self.subfolder if self.subfolder else "")
|
235 |
-
os.environ['MODEL_NAME'] = json.dumps(self.model_id.split("/")[-1])
|
236 |
-
os.environ['MODEL_IDENTITY'] = json.dumps(self.model_identity or "")
|
237 |
-
os.environ['SYSTEM_MESSAGE'] = json.dumps(self.system_message or (self.model_identity or ""))
|
238 |
-
os.environ['DEVELOPER_MESSAGE'] = json.dumps(self.developer_message or "")
|
239 |
-
os.environ['REASONING_EFFORT'] = json.dumps((self.reasoning_effort or "medium"))
|
240 |
{"os.environ['EXAMPLES_TYPE'] = " + _json.dumps(self.examples_type) + "\n" if self.examples_type else ''}
|
241 |
{"os.environ['DISABLE_EXAMPLES'] = 'true'\n" if self.disable_examples else ("os.environ['DISABLE_EXAMPLES'] = 'false'\n" if self.disable_examples is not None else '')}
|
242 |
{"os.environ['EXAMPLES_JSON'] = " + _json.dumps(self.examples_json) + "\n" if self.examples_json else ''}
|
243 |
|
244 |
# Branding/owner variables
|
245 |
-
os.environ['HF_USERNAME'] = json.dumps(self.hf_username)
|
246 |
-
os.environ['BRAND_OWNER_NAME'] = json.dumps(self.brand_owner_name)
|
247 |
-
os.environ['BRAND_TEAM_NAME'] = json.dumps(self.brand_team_name)
|
248 |
-
os.environ['BRAND_DISCORD_URL'] = json.dumps(self.brand_discord_url)
|
249 |
-
os.environ['BRAND_HF_ORG'] = json.dumps(self.brand_hf_org)
|
250 |
-
os.environ['BRAND_HF_LABEL'] = json.dumps(self.brand_hf_label)
|
251 |
-
os.environ['BRAND_HF_URL'] = json.dumps(self.brand_hf_url)
|
252 |
-
os.environ['BRAND_GH_ORG'] = json.dumps(self.brand_gh_org)
|
253 |
-
os.environ['BRAND_GH_LABEL'] = json.dumps(self.brand_gh_label)
|
254 |
-
os.environ['BRAND_GH_URL'] = json.dumps(self.brand_gh_url)
|
255 |
-
os.environ['BRAND_PROJECT_NAME'] = json.dumps(self.brand_project_name)
|
256 |
-
os.environ['BRAND_PROJECT_URL'] = json.dumps(self.brand_project_url)
|
257 |
|
258 |
"""
|
259 |
return env_setup
|
|
|
192 |
env_setup = f"""
|
193 |
# Environment variables for GPT-OSS model configuration
|
194 |
import os
|
195 |
+
os.environ['HF_MODEL_ID'] = json.dumps(self.model_id)
|
196 |
+
os.environ['LORA_MODEL_ID'] = json.dumps(self.model_id)
|
197 |
os.environ['BASE_MODEL_ID'] = 'openai/gpt-oss-20b'
|
198 |
+
os.environ['MODEL_SUBFOLDER'] = json.dumps(self.subfolder if self.subfolder else "")
|
199 |
+
os.environ['MODEL_NAME'] = json.dumps(model_name)
|
200 |
+
os.environ['MODEL_IDENTITY'] = json.dumps(self.model_identity or "")
|
201 |
+
os.environ['SYSTEM_MESSAGE'] = json.dumps(self.system_message or (self.model_identity or ""))
|
202 |
+
os.environ['DEVELOPER_MESSAGE'] = json.dumps(self.developer_message or "")
|
203 |
+
os.environ['REASONING_EFFORT'] = json.dumps((self.reasoning_effort or "medium"))
|
204 |
{"os.environ['EXAMPLES_TYPE'] = " + _json.dumps(self.examples_type) + "\n" if self.examples_type else ''}
|
205 |
{"os.environ['DISABLE_EXAMPLES'] = 'true'\n" if self.disable_examples else ("os.environ['DISABLE_EXAMPLES'] = 'false'\n" if self.disable_examples is not None else '')}
|
206 |
{"os.environ['EXAMPLES_JSON'] = " + _json.dumps(self.examples_json) + "\n" if self.examples_json else ''}
|
207 |
|
208 |
# Branding/owner variables
|
209 |
+
os.environ['HF_USERNAME'] = json.dumps(self.hf_username)
|
210 |
+
os.environ['BRAND_OWNER_NAME'] = json.dumps(self.brand_owner_name)
|
211 |
+
os.environ['BRAND_TEAM_NAME'] = json.dumps(self.brand_team_name)
|
212 |
+
os.environ['BRAND_DISCORD_URL'] = json.dumps(self.brand_discord_url)
|
213 |
+
os.environ['BRAND_HF_ORG'] = json.dumps(self.brand_hf_org)
|
214 |
+
os.environ['BRAND_HF_LABEL'] = json.dumps(self.brand_hf_label)
|
215 |
+
os.environ['BRAND_HF_URL'] = json.dumps(self.brand_hf_url)
|
216 |
+
os.environ['BRAND_GH_ORG'] = json.dumps(self.brand_gh_org)
|
217 |
+
os.environ['BRAND_GH_LABEL'] = json.dumps(self.brand_gh_label)
|
218 |
+
os.environ['BRAND_GH_URL'] = json.dumps(self.brand_gh_url)
|
219 |
+
os.environ['BRAND_PROJECT_NAME'] = json.dumps(self.brand_project_name)
|
220 |
+
os.environ['BRAND_PROJECT_URL'] = json.dumps(self.brand_project_url)
|
221 |
|
222 |
"""
|
223 |
elif self.demo_type == "voxtral":
|
|
|
230 |
env_setup = f"""
|
231 |
# Environment variables for model configuration
|
232 |
import os
|
233 |
+
os.environ['HF_MODEL_ID'] = json.dumps(self.model_id)
|
234 |
+
os.environ['MODEL_SUBFOLDER'] = json.dumps(self.subfolder if self.subfolder else "")
|
235 |
+
os.environ['MODEL_NAME'] = json.dumps(self.model_id.split("/")[-1])
|
236 |
+
os.environ['MODEL_IDENTITY'] = json.dumps(self.model_identity or "")
|
237 |
+
os.environ['SYSTEM_MESSAGE'] = json.dumps(self.system_message or (self.model_identity or ""))
|
238 |
+
os.environ['DEVELOPER_MESSAGE'] = json.dumps(self.developer_message or "")
|
239 |
+
os.environ['REASONING_EFFORT'] = json.dumps((self.reasoning_effort or "medium"))
|
240 |
{"os.environ['EXAMPLES_TYPE'] = " + _json.dumps(self.examples_type) + "\n" if self.examples_type else ''}
|
241 |
{"os.environ['DISABLE_EXAMPLES'] = 'true'\n" if self.disable_examples else ("os.environ['DISABLE_EXAMPLES'] = 'false'\n" if self.disable_examples is not None else '')}
|
242 |
{"os.environ['EXAMPLES_JSON'] = " + _json.dumps(self.examples_json) + "\n" if self.examples_json else ''}
|
243 |
|
244 |
# Branding/owner variables
|
245 |
+
os.environ['HF_USERNAME'] = json.dumps(self.hf_username)
|
246 |
+
os.environ['BRAND_OWNER_NAME'] = json.dumps(self.brand_owner_name)
|
247 |
+
os.environ['BRAND_TEAM_NAME'] = json.dumps(self.brand_team_name)
|
248 |
+
os.environ['BRAND_DISCORD_URL'] = json.dumps(self.brand_discord_url)
|
249 |
+
os.environ['BRAND_HF_ORG'] = json.dumps(self.brand_hf_org)
|
250 |
+
os.environ['BRAND_HF_LABEL'] = json.dumps(self.brand_hf_label)
|
251 |
+
os.environ['BRAND_HF_URL'] = json.dumps(self.brand_hf_url)
|
252 |
+
os.environ['BRAND_GH_ORG'] = json.dumps(self.brand_gh_org)
|
253 |
+
os.environ['BRAND_GH_LABEL'] = json.dumps(self.brand_gh_label)
|
254 |
+
os.environ['BRAND_GH_URL'] = json.dumps(self.brand_gh_url)
|
255 |
+
os.environ['BRAND_PROJECT_NAME'] = json.dumps(self.brand_project_name)
|
256 |
+
os.environ['BRAND_PROJECT_URL'] = json.dumps(self.brand_project_url)
|
257 |
|
258 |
"""
|
259 |
return env_setup
|
scripts/train.py
CHANGED
@@ -376,10 +376,10 @@ def main():
|
|
376 |
|
377 |
data_collator = VoxtralDataCollator(processor, model_checkpoint)
|
378 |
|
379 |
-
# Only report to
|
380 |
report_to = []
|
381 |
if wandb_enabled:
|
382 |
-
report_to = ["
|
383 |
|
384 |
training_args = TrainingArguments(
|
385 |
output_dir=output_dir,
|
|
|
376 |
|
377 |
data_collator = VoxtralDataCollator(processor, model_checkpoint)
|
378 |
|
379 |
+
# Only report to trackio if it's enabled and working
|
380 |
report_to = []
|
381 |
if wandb_enabled:
|
382 |
+
report_to = ["trackio"]
|
383 |
|
384 |
training_args = TrainingArguments(
|
385 |
output_dir=output_dir,
|
scripts/train_lora.py
CHANGED
@@ -405,10 +405,10 @@ def main():
|
|
405 |
|
406 |
data_collator = VoxtralDataCollator(processor, model_checkpoint)
|
407 |
|
408 |
-
# Only report to
|
409 |
report_to = []
|
410 |
if wandb_enabled:
|
411 |
-
report_to = ["
|
412 |
|
413 |
training_args = TrainingArguments(
|
414 |
output_dir=output_dir,
|
|
|
405 |
|
406 |
data_collator = VoxtralDataCollator(processor, model_checkpoint)
|
407 |
|
408 |
+
# Only report to trackio if it's enabled and working
|
409 |
report_to = []
|
410 |
if wandb_enabled:
|
411 |
+
report_to = ["trackio"]
|
412 |
|
413 |
training_args = TrainingArguments(
|
414 |
output_dir=output_dir,
|
simple_test.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python3
|
2 |
+
"""
|
3 |
+
Simple test to verify the fixes work.
|
4 |
+
"""
|
5 |
+
|
6 |
+
def test_syntax():
|
7 |
+
"""Test that all Python files have valid syntax."""
|
8 |
+
import ast
|
9 |
+
|
10 |
+
files_to_test = [
|
11 |
+
"scripts/train_lora.py",
|
12 |
+
"scripts/train.py",
|
13 |
+
"scripts/deploy_demo_space.py"
|
14 |
+
]
|
15 |
+
|
16 |
+
for file_path in files_to_test:
|
17 |
+
try:
|
18 |
+
with open(file_path, 'r', encoding='utf-8') as f:
|
19 |
+
content = f.read()
|
20 |
+
ast.parse(content)
|
21 |
+
print(f"β
{file_path} - syntax valid")
|
22 |
+
except SyntaxError as e:
|
23 |
+
print(f"β {file_path} - syntax error: {e}")
|
24 |
+
return False
|
25 |
+
except Exception as e:
|
26 |
+
print(f"β {file_path} - error: {e}")
|
27 |
+
return False
|
28 |
+
|
29 |
+
return True
|
30 |
+
|
31 |
+
if __name__ == "__main__":
|
32 |
+
print("π§ͺ Testing syntax...")
|
33 |
+
if test_syntax():
|
34 |
+
print("\nπ All files have valid syntax!")
|
35 |
+
print("\nKey fixes applied:")
|
36 |
+
print("1. β
Fixed WandbCallback error by using report_to=['trackio']")
|
37 |
+
print("2. β
Fixed f-string syntax errors in deploy_demo_space.py")
|
38 |
+
print("3. β
Removed stray } characters from json.dumps calls")
|
39 |
+
print("4. β
Fixed missing closing parenthesis")
|
40 |
+
print("\nThe training should now work correctly!")
|
41 |
+
else:
|
42 |
+
print("\nβ Some files have syntax errors.")
|
tests/test_fixes.py
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python3
|
2 |
+
"""
|
3 |
+
Test script to verify the fixes work correctly.
|
4 |
+
"""
|
5 |
+
|
6 |
+
import sys
|
7 |
+
from pathlib import Path
|
8 |
+
|
9 |
+
def test_training_scripts():
|
10 |
+
"""Test that training scripts can be imported without errors."""
|
11 |
+
print("π§ͺ Testing training script imports...")
|
12 |
+
|
13 |
+
try:
|
14 |
+
# Test train_lora.py
|
15 |
+
sys.path.insert(0, str(Path(__file__).parent / "scripts"))
|
16 |
+
from train_lora import main as train_lora_main
|
17 |
+
print("β
train_lora.py imports successfully")
|
18 |
+
|
19 |
+
# Test train.py
|
20 |
+
from train import main as train_main
|
21 |
+
print("β
train.py imports successfully")
|
22 |
+
|
23 |
+
return True
|
24 |
+
except Exception as e:
|
25 |
+
print(f"β Training script import failed: {e}")
|
26 |
+
return False
|
27 |
+
|
28 |
+
def test_deploy_script_syntax():
|
29 |
+
"""Test that deploy script has valid syntax."""
|
30 |
+
print("π§ͺ Testing deploy script syntax...")
|
31 |
+
|
32 |
+
try:
|
33 |
+
# Read the file and check for basic syntax issues
|
34 |
+
with open("scripts/deploy_demo_space.py", "r", encoding="utf-8") as f:
|
35 |
+
content = f.read()
|
36 |
+
|
37 |
+
# Check for common syntax issues
|
38 |
+
if "json.dumps(" in content and "}" in content:
|
39 |
+
# Check if there are any stray } characters after json.dumps
|
40 |
+
lines = content.split('\n')
|
41 |
+
for i, line in enumerate(lines, 1):
|
42 |
+
if "json.dumps(" in line and line.strip().endswith('}'):
|
43 |
+
print(f"β Found stray }} on line {i}: {line.strip()}")
|
44 |
+
return False
|
45 |
+
|
46 |
+
print("β
Deploy script syntax appears valid")
|
47 |
+
return True
|
48 |
+
except Exception as e:
|
49 |
+
print(f"β Deploy script syntax test failed: {e}")
|
50 |
+
return False
|
51 |
+
|
52 |
+
if __name__ == "__main__":
|
53 |
+
print("π Testing fixes...")
|
54 |
+
|
55 |
+
success = True
|
56 |
+
|
57 |
+
# Test training scripts
|
58 |
+
if not test_training_scripts():
|
59 |
+
success = False
|
60 |
+
|
61 |
+
# Test deploy script syntax
|
62 |
+
if not test_deploy_script_syntax():
|
63 |
+
success = False
|
64 |
+
|
65 |
+
if success:
|
66 |
+
print("\nπ All fixes appear to be working!")
|
67 |
+
print("\nKey fixes applied:")
|
68 |
+
print("1. β
Changed report_to from 'wandb' to 'trackio' to avoid WandbCallback error")
|
69 |
+
print("2. β
Fixed f-string syntax errors in deploy_demo_space.py")
|
70 |
+
print("3. β
Removed stray } characters from json.dumps calls")
|
71 |
+
print("\nThe training should now work correctly!")
|
72 |
+
else:
|
73 |
+
print("\nβ Some tests failed. Please check the errors above.")
|
74 |
+
sys.exit(1)
|
test_wandb_integration.py β tests/test_wandb_integration.py
RENAMED
File without changes
|