-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtrainer.py
More file actions
2313 lines (2119 loc) · 91 KB
/
Copy pathtrainer.py
File metadata and controls
2313 lines (2119 loc) · 91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from __future__ import annotations
import json
import time
from dataclasses import dataclass, field
from pathlib import Path
from typing import Any, Dict, List
from openadapt_ml.schema import ActionType
from openadapt_ml.training.shared_ui import (
get_shared_header_css as _get_shared_header_css,
generate_shared_header_html as _generate_shared_header_html,
build_nav_links as _build_nav_links,
)
from openadapt_ml.training.viewer import (
generate_unified_viewer_from_output_dir,
)
from openadapt_ml.training.benchmark_viewer import (
_get_azure_jobs_panel_css,
_get_azure_jobs_panel_html,
)
def setup_job_directory(base_dir: str | Path, job_id: str) -> Path:
"""Set up job-scoped directory structure with symlink.
Creates:
{base_dir}/{job_id}/ - Job-specific directory
{base_dir}/current - Symlink to current job directory
Args:
base_dir: Base output directory (e.g., "training_output")
job_id: Unique job identifier (e.g., "20251214_200417")
Returns:
Path to the job-specific directory
"""
base_dir = Path(base_dir)
job_dir = base_dir / job_id
current_link = base_dir / "current"
# Create base and job directories
base_dir.mkdir(parents=True, exist_ok=True)
job_dir.mkdir(parents=True, exist_ok=True)
# Atomically update the 'current' symlink
# Use a temp link then rename for atomic operation
temp_link = base_dir / f".current_temp_{job_id}"
try:
# Remove temp link if it exists from a previous failed attempt
if temp_link.exists() or temp_link.is_symlink():
temp_link.unlink()
# Create temp symlink pointing to job_id (relative path)
temp_link.symlink_to(job_id)
# Atomically replace current with temp
temp_link.rename(current_link)
except Exception as e:
# Clean up temp link on failure
if temp_link.exists() or temp_link.is_symlink():
temp_link.unlink()
raise RuntimeError(f"Failed to create current symlink: {e}")
return job_dir
def get_current_job_directory(base_dir: str | Path) -> Path | None:
"""Get the current job directory from symlink.
Returns:
Path to current job directory, or None if no current symlink
"""
base_dir = Path(base_dir)
current_link = base_dir / "current"
if current_link.is_symlink():
return current_link.resolve()
return None
def update_current_symlink_to_latest(
base_dir: str | Path = "training_output",
) -> Path | None:
"""Point the 'current' symlink at the most recent job directory.
Scans base_dir for job directories (any real subdirectory other than
the 'current' symlink itself) and atomically updates the symlink to
the most recently modified one.
Args:
base_dir: Base output directory containing job directories.
Returns:
Path to the latest job directory, or None if none exist.
"""
base_dir = Path(base_dir)
if not base_dir.is_dir():
return None
job_dirs = [
d
for d in base_dir.iterdir()
if d.is_dir() and not d.is_symlink() and not d.name.startswith(".")
]
if not job_dirs:
return None
# Prefer directories that look like training runs over stray dirs
# (e.g. a top-level "checkpoints" directory from the old flat layout).
run_like = [
d
for d in job_dirs
if (d / "training_log.json").exists() or (d / "dashboard.html").exists()
]
candidates = run_like or job_dirs
latest = max(candidates, key=lambda d: d.stat().st_mtime)
current_link = base_dir / "current"
temp_link = base_dir / f".current_temp_{latest.name}"
try:
if temp_link.exists() or temp_link.is_symlink():
temp_link.unlink()
temp_link.symlink_to(latest.name)
temp_link.rename(current_link)
except Exception as e:
if temp_link.exists() or temp_link.is_symlink():
temp_link.unlink()
raise RuntimeError(f"Failed to update current symlink: {e}")
return latest
@dataclass
class TrainingConfig:
# Model / LoRA-related fields are handled elsewhere; this covers loop hyperparams.
num_train_epochs: int = 1
per_device_train_batch_size: int = 1
gradient_accumulation_steps: int = 1
learning_rate: float = 2e-4
warmup_ratio: float = 0.03
weight_decay: float = 0.0
max_grad_norm: float = 1.0
logging_steps: int = 10
# Learning rate scheduler
lr_scheduler_type: str = "linear" # Options: linear, cosine, constant, none
# Early stopping: stop when loss is below threshold for patience consecutive steps
early_stop_loss: float = 1e-4
early_stop_patience: int = 10
# Output directory for logs and visualizations
output_dir: str = "training_output"
# Checkpoint saving
save_checkpoint_every_epoch: bool = True
checkpoint_dir: str = "checkpoints"
# Evaluation during training
eval_every_epoch: bool = True
eval_samples: int = 3 # Number of samples to evaluate per epoch
@dataclass
class TrainingState:
"""Tracks training progress for visualization."""
# Job identification
job_id: str = field(default_factory=lambda: time.strftime("%Y%m%d_%H%M%S"))
hostname: str = field(default_factory=lambda: __import__("socket").gethostname())
capture_path: str = ""
config_path: str = ""
goal: str = "" # Task goal/description for the training run
# Model configuration
model_name: str = "" # e.g. "Qwen/Qwen3-VL-2B-Instruct"
lora_r: int = 0 # LoRA rank
lora_alpha: int = 0 # LoRA alpha
load_in_4bit: bool = False # Quantization
# Training progress
epoch: int = 0
step: int = 0
total_steps: int = 0
total_epochs: int = 1 # Set by logger from config
loss: float = 0.0
learning_rate: float = 0.0
samples_seen: int = 0
start_time: float = field(default_factory=time.time)
elapsed_time: float = 0.0 # For historical data loaded from JSON
losses: List[Dict[str, Any]] = field(default_factory=list)
evaluations: List[Dict[str, Any]] = field(default_factory=list)
# Cloud info (optional)
instance_type: str = ""
instance_ip: str = ""
# Cloud provider info (for dashboard link)
cloud_provider: str = "" # e.g. "lambda", "azure"
cloud_dashboard_url: str = "" # e.g. "https://cloud.lambda.ai/instances"
cloud_instance_id: str = "" # Provider-specific instance ID
# Setup status tracking
setup_status: str = "" # e.g. "booting", "installing", "training", "complete"
setup_logs: List[str] = field(default_factory=list) # Setup progress messages
# Termination tracking
termination_status: str = (
"" # e.g. "auto_low_loss", "auto_complete", "user_stop", "running"
)
termination_message: str = "" # Human-readable termination reason
def log_step(self, epoch: int, step: int, loss: float, lr: float = 0.0) -> None:
"""Log a training step."""
self.epoch = epoch
self.step = step
self.loss = loss
self.learning_rate = lr
self.losses.append(
{
"epoch": epoch,
"step": step,
"loss": loss,
"lr": lr,
"time": time.time() - self.start_time,
}
)
def log_evaluation(
self,
epoch: int,
sample_idx: int,
image_path: str,
human_action: Dict,
predicted_action: Dict,
) -> None:
"""Log an evaluation sample."""
# Calculate distance for click actions
distance = 0.0
if (
human_action.get("type") == "click"
and predicted_action.get("type") == "click"
):
hx, hy = human_action.get("x", 0), human_action.get("y", 0)
px, py = predicted_action.get("x", 0), predicted_action.get("y", 0)
distance = ((hx - px) ** 2 + (hy - py) ** 2) ** 0.5
self.evaluations.append(
{
"epoch": epoch,
"sample_idx": sample_idx,
"image_path": image_path,
"human_action": human_action,
"predicted_action": predicted_action,
"distance": distance,
"correct": distance < 50, # Within 50 pixels is "correct"
}
)
def to_dict(self) -> Dict[str, Any]:
"""Convert state to serializable dict."""
return {
# Job metadata
"job_id": self.job_id,
"hostname": self.hostname,
"capture_path": self.capture_path,
"config_path": self.config_path,
"goal": self.goal,
# Model configuration
"model_name": self.model_name,
"lora_r": self.lora_r,
"lora_alpha": self.lora_alpha,
"load_in_4bit": self.load_in_4bit,
"instance_type": self.instance_type,
"instance_ip": self.instance_ip,
"started_at": time.strftime(
"%Y-%m-%dT%H:%M:%SZ", time.gmtime(self.start_time)
),
# Cloud provider info
"cloud_provider": self.cloud_provider,
"cloud_dashboard_url": self.cloud_dashboard_url,
"cloud_instance_id": self.cloud_instance_id,
"setup_status": self.setup_status,
"setup_logs": self.setup_logs,
# Training progress
"epoch": self.epoch,
"step": self.step,
"total_steps": self.total_steps,
"total_epochs": self.total_epochs,
"loss": self.loss,
"learning_rate": self.learning_rate,
"samples_seen": self.samples_seen,
"elapsed_time": time.time() - self.start_time,
"losses": self.losses,
"evaluations": self.evaluations,
# Termination tracking
"termination_status": self.termination_status,
"termination_message": self.termination_message,
}
class TrainingLogger:
"""Logs training progress and generates visualization."""
def __init__(
self,
output_dir: str | Path,
config: TrainingConfig,
capture_path: str = "",
config_path: str = "",
goal: str = "",
instance_ip: str = "",
instance_type: str = "",
cloud_provider: str = "",
cloud_dashboard_url: str = "",
cloud_instance_id: str = "",
job_id: str = "",
# Model configuration
model_name: str = "",
lora_r: int = 0,
lora_alpha: int = 0,
load_in_4bit: bool = False,
):
# Generate job_id if not provided
if not job_id:
job_id = time.strftime("%Y%m%d_%H%M%S")
# Set up job-scoped directory with symlink
base_dir = Path(output_dir)
self.base_dir = base_dir
self.output_dir = setup_job_directory(base_dir, job_id)
self.config = config
self.state = TrainingState(
job_id=job_id,
capture_path=capture_path,
config_path=config_path,
goal=goal,
model_name=model_name,
lora_r=lora_r,
lora_alpha=lora_alpha,
load_in_4bit=load_in_4bit,
instance_ip=instance_ip,
instance_type=instance_type,
total_epochs=config.num_train_epochs,
cloud_provider=cloud_provider,
cloud_dashboard_url=cloud_dashboard_url,
cloud_instance_id=cloud_instance_id,
)
self.log_file = self.output_dir / "training_log.json"
self.terminal_log_file = self.output_dir / "training.log"
self.terminal_log_handle = None
# Save config snapshot
self._save_config_snapshot()
def _log_to_terminal(self, message: str):
"""Write message to training.log file.
Args:
message: Message to log
"""
from datetime import datetime
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
log_line = f"[{timestamp}] {message}"
# Open file on first write (line buffered)
if self.terminal_log_handle is None:
self.terminal_log_handle = open(self.terminal_log_file, "w", buffering=1)
self.terminal_log_handle.write(log_line + "\n")
self.terminal_log_handle.flush()
def on_step(self, epoch: int, step: int, loss: float, lr: float = 0.0) -> None:
"""Called after each training step."""
self.state.log_step(epoch, step, loss, lr)
self._save_log()
def on_epoch_end(self, epoch: int) -> None:
"""Called at the end of each epoch."""
self.state.epoch = epoch
self._save_log()
self._generate_dashboard()
def on_train_end(self) -> None:
"""Called at the end of training."""
self._save_log()
self._generate_dashboard()
print(f"Training dashboard: {self.output_dir / 'dashboard.html'}")
# Close terminal log file
if self.terminal_log_handle:
self.terminal_log_handle.close()
self.terminal_log_handle = None
def _save_config_snapshot(self) -> None:
"""Save training config snapshot to JSON."""
from dataclasses import asdict
config_file = self.output_dir / "config.json"
config_dict = asdict(self.config)
with open(config_file, "w") as f:
json.dump(config_dict, f, indent=2)
def _save_log(self) -> None:
"""Save training log to JSON."""
with open(self.log_file, "w") as f:
json.dump(self.state.to_dict(), f, indent=2)
def _generate_dashboard(self) -> None:
"""Generate HTML training dashboard."""
dashboard_path = self.output_dir / "dashboard.html"
html = generate_training_dashboard(self.state, self.config)
dashboard_path.write_text(html)
def _generate_termination_status_html(
state: TrainingState, is_training_complete: bool
) -> str:
"""Generate HTML for termination status section."""
# Check if we have termination info
if state.termination_status:
# Map termination status to colors and icons
status_styles = {
"auto_complete": {
"color": "#22c55e",
"icon": "✓",
"label": "Training Complete",
},
"auto_low_loss": {
"color": "#22c55e",
"icon": "✓",
"label": "Auto-Stopped (Low Loss)",
},
"user_stop": {"color": "#f59e0b", "icon": "■", "label": "Stopped by User"},
}
style = status_styles.get(
state.termination_status,
{"color": "#22c55e", "icon": "✓", "label": "Complete"},
)
return f"""<div style="display: flex; flex-direction: column; gap: 8px;">
<div style="display: flex; align-items: center; gap: 8px; color: {style["color"]};">
<span style="font-size: 1.2rem;">{style["icon"]}</span>
<span style="font-weight: 600;">{style["label"]}</span>
</div>
{f'<div style="font-size: 0.85rem; color: var(--text-muted); margin-left: 28px;">{state.termination_message}</div>' if state.termination_message else ""}
</div>"""
elif is_training_complete:
return """<div style="display: flex; align-items: center; gap: 8px; color: #22c55e;">
<span style="font-size: 1.2rem;">✓</span>
<span style="font-weight: 600;">Training Complete</span>
</div>"""
else:
return """<button id="stop-training-btn" onclick="stopTraining()" style="
background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
color: white;
border: none;
padding: 12px 24px;
border-radius: 8px;
font-size: 0.9rem;
font-weight: 600;
cursor: pointer;
display: flex;
align-items: center;
gap: 8px;
transition: all 0.2s;
">
<span style="font-size: 1.1rem;">■</span> Stop Training
</button>
<p id="stop-status" style="margin-top: 8px; font-size: 0.75rem; color: var(--text-muted);"></p>"""
def generate_training_dashboard(state: TrainingState, config: TrainingConfig) -> str:
"""Generate an HTML dashboard for training visualization."""
losses_json = json.dumps(state.losses)
# Use stored elapsed_time if available (historical data), otherwise calculate
elapsed = (
state.elapsed_time if state.elapsed_time > 0 else time.time() - state.start_time
)
elapsed_str = f"{int(elapsed // 60)}m {int(elapsed % 60)}s"
# Calculate stats
if state.losses:
min_loss = min(loss["loss"] for loss in state.losses)
sum(loss["loss"] for loss in state.losses) / len(state.losses)
recent_losses = state.losses[-10:] if len(state.losses) >= 10 else state.losses
recent_avg = sum(loss["loss"] for loss in recent_losses) / len(recent_losses)
# Calculate step times
step_times = []
for i in range(1, len(state.losses)):
step_times.append(state.losses[i]["time"] - state.losses[i - 1]["time"])
avg_step_time = sum(step_times) / len(step_times) if step_times else 0
# Loss by epoch
epoch_losses: dict = {}
for loss in state.losses:
ep = loss["epoch"]
if ep not in epoch_losses:
epoch_losses[ep] = []
epoch_losses[ep].append(loss["loss"])
epoch_avg = {
ep: sum(losses) / len(losses) for ep, losses in epoch_losses.items()
}
# Estimate ETA
# Steps per epoch = steps in completed epochs / completed epochs
completed_epochs = state.epoch
steps_in_completed = sum(
1 for loss in state.losses if loss["epoch"] < completed_epochs
)
if completed_epochs > 0 and steps_in_completed > 0:
steps_per_epoch = steps_in_completed / completed_epochs
else:
# Estimate from current epoch progress
steps_per_epoch = (
len(state.losses) / (state.epoch + 1)
if state.epoch >= 0
else len(state.losses)
)
total_epochs = (
state.total_epochs if state.total_epochs > 0 else config.num_train_epochs
)
total_steps_estimate = steps_per_epoch * total_epochs
remaining_steps = max(0, total_steps_estimate - len(state.losses))
eta_seconds = remaining_steps * avg_step_time if avg_step_time > 0 else 0
# Check if training is complete (all steps done)
is_training_complete = remaining_steps == 0 and len(state.losses) > 0
else:
min_loss = recent_avg = avg_step_time = 0.0
epoch_avg = {}
eta_seconds = 0
steps_per_epoch = 0
total_steps_estimate = 0
remaining_steps = 0
is_training_complete = False
epoch_avg_json = json.dumps(list(epoch_avg.items()))
# Generate comparison viewer preview if capture path available
if state.capture_path:
try:
from openadapt_ml.scripts.compare import generate_comparison_html
from openadapt_ml.ingest.capture import capture_to_episode
capture_path = Path(state.capture_path)
if capture_path.exists():
# Load episode from capture
episode = capture_to_episode(capture_path)
# Generate comparison data with null predictions (shows "— No prediction")
comparison_data = []
for i, step in enumerate(episode.steps):
# Extract normalized coordinates if available
action_x, action_y = None, None
if step.action.normalized_coordinates:
action_x, action_y = step.action.normalized_coordinates
step_data = {
"index": i,
"time": step.step_index,
"image_path": step.observation.screenshot_path,
"human_action": {
"type": step.action.type.value
if isinstance(step.action.type, ActionType)
else step.action.type,
"x": action_x,
"y": action_y,
"text": step.action.text,
},
"predicted_action": None, # Shows "— No prediction" in viewer
"match": None,
}
comparison_data.append(step_data)
# Generate comparison HTML
output_dir = (
Path(config.output_dir)
if hasattr(config, "output_dir")
else Path("training_output")
)
output_dir.mkdir(parents=True, exist_ok=True)
comparison_output = output_dir / "comparison_preview.html"
generate_comparison_html(
capture_path, episode, comparison_data, comparison_output
)
str(comparison_output.name) # Relative path
except Exception:
pass # Fail silently if comparison viewer can't be generated
html = f"""<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Training Dashboard</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<style>
:root {{
--bg-primary: #0a0a0f;
--bg-secondary: #12121a;
--bg-tertiary: #1a1a24;
--border-color: rgba(255, 255, 255, 0.06);
--text-primary: #f0f0f0;
--text-secondary: #888;
--accent: #00d4aa;
--accent-secondary: #a78bfa;
}}
* {{ box-sizing: border-box; margin: 0; padding: 0; }}
body {{
font-family: -apple-system, BlinkMacSystemFont, "Inter", sans-serif;
background: var(--bg-primary);
color: var(--text-primary);
min-height: 100vh;
}}
.container {{ max-width: 1400px; margin: 0 auto; padding: 24px; }}
header {{
display: flex;
justify-content: space-between;
align-items: center;
padding: 20px 24px;
background: var(--bg-secondary);
border: 1px solid var(--border-color);
border-radius: 12px;
margin-bottom: 24px;
}}
header h1 {{ font-size: 1.3rem; font-weight: 600; }}
.job-info {{
display: flex;
gap: 16px;
margin-top: 4px;
font-size: 0.75rem;
color: var(--text-secondary);
}}
.job-id {{
font-family: "SF Mono", Monaco, monospace;
color: var(--accent);
}}
.job-host {{
font-family: "SF Mono", Monaco, monospace;
}}
.job-config {{
font-family: "SF Mono", Monaco, monospace;
opacity: 0.7;
}}
.cloud-link {{
display: inline-flex;
align-items: center;
gap: 6px;
padding: 6px 12px;
background: var(--bg-tertiary);
border: 1px solid var(--border-color);
border-radius: 6px;
font-size: 0.75rem;
color: var(--text-primary);
text-decoration: none;
transition: all 0.2s;
}}
.cloud-link:hover {{
border-color: var(--accent);
background: rgba(0, 212, 170, 0.1);
}}
.cloud-link svg {{
width: 14px;
height: 14px;
}}
.cloud-badge {{
background: linear-gradient(135deg, rgba(167, 139, 250, 0.2), rgba(0, 212, 170, 0.1));
border-color: rgba(167, 139, 250, 0.3);
margin-left: 12px;
}}
.setup-panel {{
background: var(--bg-secondary);
border: 1px solid var(--border-color);
border-radius: 12px;
padding: 20px;
margin-bottom: 24px;
}}
.setup-panel.hidden {{
display: none;
}}
.setup-header {{
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 12px;
}}
.setup-header h2 {{
font-size: 0.9rem;
}}
.setup-status-badge {{
display: inline-flex;
align-items: center;
gap: 6px;
padding: 4px 10px;
border-radius: 12px;
font-size: 0.7rem;
text-transform: uppercase;
letter-spacing: 0.05em;
font-weight: 600;
}}
.setup-status-badge.booting {{
background: rgba(255, 149, 0, 0.2);
color: #ff9500;
}}
.setup-status-badge.installing {{
background: rgba(167, 139, 250, 0.2);
color: #a78bfa;
}}
.setup-status-badge.training {{
background: rgba(0, 212, 170, 0.2);
color: #00d4aa;
}}
.setup-status-badge.complete {{
background: rgba(52, 211, 153, 0.2);
color: #34d399;
}}
.setup-logs {{
background: var(--bg-tertiary);
border-radius: 8px;
padding: 12px;
max-height: 200px;
overflow-y: auto;
font-family: "SF Mono", Monaco, monospace;
font-size: 0.7rem;
line-height: 1.6;
}}
.setup-log-line {{
color: var(--text-secondary);
padding: 2px 0;
}}
.setup-log-line.current {{
color: var(--accent);
}}
.config-panel {{
background: var(--bg-secondary);
border: 1px solid var(--border-color);
border-radius: 12px;
padding: 16px 20px;
margin-bottom: 24px;
}}
.config-grid {{
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 16px;
}}
.config-item {{
display: flex;
flex-direction: column;
gap: 4px;
}}
.config-label {{
font-size: 0.7rem;
color: var(--text-secondary);
text-transform: uppercase;
letter-spacing: 0.5px;
}}
.config-value {{
font-family: "SF Mono", Monaco, monospace;
font-size: 0.85rem;
color: var(--text-primary);
}}
.config-value.model {{
color: var(--accent);
}}
.config-value.goal {{
font-family: -apple-system, BlinkMacSystemFont, "Inter", sans-serif;
font-size: 0.8rem;
opacity: 0.9;
}}
.status {{
display: flex;
align-items: center;
gap: 8px;
color: var(--accent);
}}
.status-dot {{
width: 10px;
height: 10px;
background: var(--accent);
border-radius: 50%;
animation: pulse 2s infinite;
}}
.status.complete .status-dot {{
animation: none;
background: #34d399;
}}
.status.stale {{
color: #ff9500;
}}
.status.stale .status-dot {{
animation: none;
background: #ff9500;
}}
.stale-warning {{
font-size: 0.7rem;
color: #ff9500;
margin-top: 2px;
}}
@keyframes pulse {{
0%, 100% {{ opacity: 1; }}
50% {{ opacity: 0.4; }}
}}
.stats-grid {{
display: grid;
grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
gap: 16px;
margin-bottom: 24px;
}}
.stat-card {{
background: var(--bg-secondary);
border: 1px solid var(--border-color);
border-radius: 12px;
padding: 20px;
transition: all 0.3s ease;
}}
.stat-card.updating {{
border-color: var(--accent);
box-shadow: 0 0 20px rgba(0, 212, 170, 0.1);
}}
.stat-label {{
font-size: 0.75rem;
color: var(--text-secondary);
text-transform: uppercase;
letter-spacing: 0.05em;
margin-bottom: 8px;
}}
.stat-detail {{
font-size: 0.65rem;
color: var(--text-secondary);
margin-top: 4px;
}}
.eta-card {{
background: linear-gradient(135deg, rgba(167, 139, 250, 0.1), rgba(0, 212, 170, 0.05));
border-color: rgba(167, 139, 250, 0.3);
}}
.stat-value {{
font-size: 1.6rem;
font-weight: 600;
font-family: "SF Mono", Monaco, monospace;
transition: all 0.3s ease;
}}
.stat-value.accent {{ color: var(--accent); }}
.stat-delta {{
font-size: 0.75rem;
margin-top: 4px;
font-family: "SF Mono", Monaco, monospace;
}}
.stat-delta.positive {{ color: #34d399; }}
.stat-delta.negative {{ color: #ff5f5f; }}
.charts-grid {{
display: grid;
grid-template-columns: 2fr 1fr;
gap: 16px;
margin-bottom: 24px;
}}
@media (max-width: 900px) {{
.charts-grid {{ grid-template-columns: 1fr; }}
}}
.chart-container {{
background: var(--bg-secondary);
border: 1px solid var(--border-color);
border-radius: 12px;
padding: 24px;
}}
.chart-title {{
font-size: 0.9rem;
font-weight: 600;
margin-bottom: 16px;
display: flex;
justify-content: space-between;
align-items: center;
}}
.chart-subtitle {{
font-size: 0.75rem;
color: var(--text-secondary);
font-weight: normal;
}}
.chart-wrapper {{
height: 300px;
position: relative;
}}
.config-panel {{
background: var(--bg-secondary);
border: 1px solid var(--border-color);
border-radius: 12px;
padding: 20px;
}}
.config-panel h2 {{
font-size: 0.9rem;
margin-bottom: 16px;
}}
.config-grid {{
display: grid;
grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
gap: 12px;
}}
.config-item {{
font-size: 0.8rem;
}}
.config-item .key {{
color: var(--text-secondary);
}}
.config-item .value {{
font-family: "SF Mono", Monaco, monospace;
color: var(--accent);
}}
.progress-bar {{
height: 4px;
background: var(--bg-tertiary);
border-radius: 2px;
margin-top: 8px;
overflow: hidden;
}}
.progress-fill {{
height: 100%;
background: linear-gradient(90deg, var(--accent), var(--accent-secondary));
border-radius: 2px;
transition: width 0.5s ease;
}}
.update-indicator {{
font-size: 0.7rem;
color: var(--text-secondary);
text-align: right;
margin-top: 16px;
}}
/* Shared header styles (injected from _get_shared_header_css) */
{_get_shared_header_css()}
/* Azure ML Jobs panel styles (only when using Azure) */
{_get_azure_jobs_panel_css() if state.cloud_provider in ("azure", "") else ""}
.eval-panel {{
background: var(--bg-secondary);
border: 1px solid var(--border-color);
border-radius: 12px;
padding: 20px;
margin-top: 16px;
}}
.eval-panel h2 {{
font-size: 0.9rem;
margin-bottom: 16px;
}}
.eval-metrics {{
display: flex;
gap: 24px;
margin-bottom: 16px;
font-size: 0.85rem;
}}
.eval-metrics .metric {{
display: flex;
flex-direction: column;
}}
.eval-metrics .metric-value {{
font-size: 1.2rem;
font-weight: 600;
color: var(--accent);
}}
.eval-filters {{
display: flex;
gap: 16px;
margin-bottom: 16px;
align-items: center;
flex-wrap: wrap;
}}
.eval-filters .filter-group {{
display: flex;
align-items: center;
gap: 8px;
}}
.eval-filters label {{
font-size: 0.75rem;
color: var(--text-secondary);
text-transform: uppercase;
letter-spacing: 0.05em;
}}
.eval-filters select {{
padding: 8px 32px 8px 12px;
border-radius: 8px;
font-size: 0.85rem;
background: rgba(0,0,0,0.4);
color: var(--text-primary);
border: 1px solid rgba(255,255,255,0.1);
cursor: pointer;
appearance: none;
background-image: url('data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 width=%2712%27 height=%278%27%3E%3Cpath fill=%27%23888%27 d=%27M0 0l6 8 6-8z%27/%3E%3C/svg%3E');
background-repeat: no-repeat;
background-position: right 10px center;
transition: all 0.2s;
}}
.eval-filters select:hover {{
border-color: var(--accent);
background-color: rgba(0,212,170,0.1);
}}
.eval-filters select:focus {{
outline: none;
border-color: var(--accent);
box-shadow: 0 0 0 2px rgba(0,212,170,0.2);
}}
.eval-gallery {{
display: grid;
grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
gap: 20px;
}}
.eval-sample {{
background: var(--bg-tertiary);
border-radius: 8px;
padding: 0;
position: relative;
overflow: hidden;
border: 1px solid var(--border-color);
}}
.eval-sample.hidden {{