mattbitzesty commited on
Commit
2ffbcaf
·
unverified ·
1 Parent(s): db8ffc0

fix(hf_job): writable registry + output dirs for read-only source mounts

Browse files

- AromaRegistry now respects PINO_REGISTRY_PATH env var.
- hf_train_job.py copies the mounted registry to a writable workspace
location before training, and writes models/runs to /workspace instead
of inside the read-only source mount.

Files changed (2) hide show
  1. scripts/hf_train_job.py +28 -2
  2. src/pino/registry.py +2 -1
scripts/hf_train_job.py CHANGED
@@ -16,6 +16,25 @@ sys.path.insert(0, str(SRC_DIR))
16
  import torch
17
  from pino.train import main as train_main
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
  def hf_train_5epoch() -> None:
21
  """Run a controlled 5-epoch training pass and push artifacts to the Hub."""
@@ -62,6 +81,13 @@ def hf_train_5epoch() -> None:
62
  # Use the local registry file if it was cloned with the repo.
63
  registry_path = Path("/workspace/pino/src/pino/registry.db")
64
 
 
 
 
 
 
 
 
65
  sys.argv = [
66
  "pino.train",
67
  "--data", str(data_path),
@@ -70,8 +96,8 @@ def hf_train_5epoch() -> None:
70
  "--train-ratio", "0.8",
71
  "--seed", "42",
72
  "--workers", "0",
73
- "--output-dir", str(REPO_ROOT / "models"),
74
- "--log-dir", str(REPO_ROOT / "runs" / "hf_job_5epoch"),
75
  ]
76
 
77
  print("🚀 HF Job: starting PINO 5-epoch convergence pass")
 
16
  import torch
17
  from pino.train import main as train_main
18
 
19
+ # Writable workspace outside the read-only source mount.
20
+ WORKSPACE = Path("/workspace")
21
+ OUTPUT_DIR = WORKSPACE / "models"
22
+ LOG_DIR = WORKSPACE / "runs" / "hf_job_5epoch"
23
+
24
+
25
+ def _copy_registry_to_writable(registry_path: Path) -> Path:
26
+ """Copy a mounted read-only registry to a writable workspace location."""
27
+ if not registry_path.exists():
28
+ return registry_path
29
+ writable_registry = WORKSPACE / "registry.db"
30
+ if writable_registry.exists():
31
+ return writable_registry
32
+ import shutil
33
+
34
+ print(f"📦 Copying registry from {registry_path} to writable {writable_registry}")
35
+ shutil.copy2(registry_path, writable_registry)
36
+ return writable_registry
37
+
38
 
39
  def hf_train_5epoch() -> None:
40
  """Run a controlled 5-epoch training pass and push artifacts to the Hub."""
 
81
  # Use the local registry file if it was cloned with the repo.
82
  registry_path = Path("/workspace/pino/src/pino/registry.db")
83
 
84
+ # Registry must be writable for embedding caching. Copy if it's mounted read-only.
85
+ registry_path = _copy_registry_to_writable(registry_path)
86
+ os.environ["PINO_REGISTRY_PATH"] = str(registry_path)
87
+
88
+ OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
89
+ LOG_DIR.mkdir(parents=True, exist_ok=True)
90
+
91
  sys.argv = [
92
  "pino.train",
93
  "--data", str(data_path),
 
96
  "--train-ratio", "0.8",
97
  "--seed", "42",
98
  "--workers", "0",
99
+ "--output-dir", str(OUTPUT_DIR),
100
+ "--log-dir", str(LOG_DIR),
101
  ]
102
 
103
  print("🚀 HF Job: starting PINO 5-epoch convergence pass")
src/pino/registry.py CHANGED
@@ -2,6 +2,7 @@ from __future__ import annotations
2
 
3
  import json
4
  import logging
 
5
  import sqlite3
6
  from pathlib import Path
7
  from typing import Any
@@ -36,7 +37,7 @@ class AromaRegistry:
36
  DEFAULT_PATH = Path(__file__).with_suffix(".db")
37
 
38
  def __init__(self, path: Path | str | None = None) -> None:
39
- self.path = Path(path) if path else self.DEFAULT_PATH
40
  self.path.parent.mkdir(parents=True, exist_ok=True)
41
  self._conn = sqlite3.connect(self.path)
42
  self._conn.row_factory = sqlite3.Row
 
2
 
3
  import json
4
  import logging
5
+ import os
6
  import sqlite3
7
  from pathlib import Path
8
  from typing import Any
 
37
  DEFAULT_PATH = Path(__file__).with_suffix(".db")
38
 
39
  def __init__(self, path: Path | str | None = None) -> None:
40
+ self.path = Path(path) if path else Path(os.environ.get("PINO_REGISTRY_PATH", self.DEFAULT_PATH))
41
  self.path.parent.mkdir(parents=True, exist_ok=True)
42
  self._conn = sqlite3.connect(self.path)
43
  self._conn.row_factory = sqlite3.Row