MikeGreen2710 commited on
Commit
7ae5b2d
·
verified ·
1 Parent(s): e4007e5

trainer: converge to VM2 patches + re-apply _portable export (recovered from transcript)

Browse files
Files changed (1) hide show
  1. scripts/meta_learner_trainer.py +15 -2
scripts/meta_learner_trainer.py CHANGED
@@ -1552,10 +1552,23 @@ def _export_deployment(export_row, results_df, out_dir, ce_configs, kl_configs,
1552
  clean_name(model_name), e))
1553
  return declared_cols
1554
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1555
  model_entries = []
1556
  for cname in exp_ce:
1557
  c = _model_info(cname, "CE")
1558
- ce_art = str(Path(args.ce_artifacts_dir).resolve()) if args.ce_artifacts_dir else None
1559
  verified_cols = _verify_other_cols(
1560
  c.get("model_name", cname), ce_art,
1561
  c.get("other_cols", []), c.get("split_unknown_stage", False))
@@ -1574,7 +1587,7 @@ def _export_deployment(export_row, results_df, out_dir, ce_configs, kl_configs,
1574
  })
1575
  for cname in exp_kl:
1576
  c = _model_info(cname, "KL")
1577
- kl_art = str(Path(args.kl_artifacts_dir).resolve()) if args.kl_artifacts_dir else None
1578
  verified_cols = _verify_other_cols(
1579
  c.get("model_name", cname), kl_art,
1580
  c.get("other_cols", []), c.get("split_unknown_stage", False))
 
1552
  clean_name(model_name), e))
1553
  return declared_cols
1554
 
1555
+ def _portable(path):
1556
+ """Deployment configs must survive machine moves (VM1 <-> VM2 <-> HF).
1557
+ Store artifact dirs relative to the project root (cwd at export time);
1558
+ the inference script's resolver finds them via its cwd rule on any
1559
+ machine. Absolute paths are kept only if outside the project tree."""
1560
+ if not path:
1561
+ return None
1562
+ rp = Path(path).resolve()
1563
+ try:
1564
+ return str(rp.relative_to(Path.cwd()))
1565
+ except ValueError:
1566
+ return str(rp)
1567
+
1568
  model_entries = []
1569
  for cname in exp_ce:
1570
  c = _model_info(cname, "CE")
1571
+ ce_art = _portable(args.ce_artifacts_dir)
1572
  verified_cols = _verify_other_cols(
1573
  c.get("model_name", cname), ce_art,
1574
  c.get("other_cols", []), c.get("split_unknown_stage", False))
 
1587
  })
1588
  for cname in exp_kl:
1589
  c = _model_info(cname, "KL")
1590
+ kl_art = _portable(args.kl_artifacts_dir)
1591
  verified_cols = _verify_other_cols(
1592
  c.get("model_name", cname), kl_art,
1593
  c.get("other_cols", []), c.get("split_unknown_stage", False))