Dev-the-dev91 commited on
Commit
2fdd1d4
·
verified ·
1 Parent(s): 45f868c

Update HF Jobs training script

Browse files
Files changed (1) hide show
  1. scripts/hf_jobs_train_syllabus.py +8 -6
scripts/hf_jobs_train_syllabus.py CHANGED
@@ -22,7 +22,6 @@ from __future__ import annotations
22
 
23
  import os
24
  import subprocess
25
- import sys
26
  from pathlib import Path
27
 
28
  from huggingface_hub import HfApi, hf_hub_download
@@ -44,6 +43,11 @@ def run(cmd: list[str], *, cwd: Path | None = None) -> None:
44
  subprocess.run(cmd, check=True, cwd=cwd)
45
 
46
 
 
 
 
 
 
47
  def _require_hub_token() -> str:
48
  token = os.environ.get("HF_TOKEN", "").strip()
49
  if not token or token in ("$HF_TOKEN", "${HF_TOKEN}"):
@@ -67,7 +71,7 @@ def main() -> None:
67
  if WORK.exists():
68
  run(["rm", "-rf", str(WORK)])
69
  run(["git", "clone", "--depth", "1", PIPELINE_GIT, str(WORK)])
70
- run([sys.executable, "-m", "pip", "install", "-q", "-e", ".[train]"], cwd=WORK)
71
 
72
  data_dir = WORK / "data" / "finetune"
73
  data_dir.mkdir(parents=True, exist_ok=True)
@@ -83,9 +87,8 @@ def main() -> None:
83
  train_path = data_dir / "train.jsonl"
84
  valid_path = data_dir / "valid.jsonl"
85
 
86
- run(
87
  [
88
- sys.executable,
89
  "validate_training_readiness.py",
90
  "--train-jsonl",
91
  str(train_path),
@@ -97,9 +100,8 @@ def main() -> None:
97
  )
98
 
99
  out_dir = WORK / "artifacts" / "hf_syllabus_extractor"
100
- run(
101
  [
102
- sys.executable,
103
  "train_hf_structured_extractor.py",
104
  "--train-jsonl",
105
  str(train_path),
 
22
 
23
  import os
24
  import subprocess
 
25
  from pathlib import Path
26
 
27
  from huggingface_hub import HfApi, hf_hub_download
 
43
  subprocess.run(cmd, check=True, cwd=cwd)
44
 
45
 
46
+ def uv_run(script_args: list[str], *, cwd: Path) -> None:
47
+ """Run a repo script with project deps (HF Jobs UV image has no pip module)."""
48
+ run(["uv", "run", *script_args], cwd=cwd)
49
+
50
+
51
  def _require_hub_token() -> str:
52
  token = os.environ.get("HF_TOKEN", "").strip()
53
  if not token or token in ("$HF_TOKEN", "${HF_TOKEN}"):
 
71
  if WORK.exists():
72
  run(["rm", "-rf", str(WORK)])
73
  run(["git", "clone", "--depth", "1", PIPELINE_GIT, str(WORK)])
74
+ run(["uv", "pip", "install", "-e", ".[train]"], cwd=WORK)
75
 
76
  data_dir = WORK / "data" / "finetune"
77
  data_dir.mkdir(parents=True, exist_ok=True)
 
87
  train_path = data_dir / "train.jsonl"
88
  valid_path = data_dir / "valid.jsonl"
89
 
90
+ uv_run(
91
  [
 
92
  "validate_training_readiness.py",
93
  "--train-jsonl",
94
  str(train_path),
 
100
  )
101
 
102
  out_dir = WORK / "artifacts" / "hf_syllabus_extractor"
103
+ uv_run(
104
  [
 
105
  "train_hf_structured_extractor.py",
106
  "--train-jsonl",
107
  str(train_path),