ericchang00 commited on
Commit
117d2d7
·
verified ·
1 Parent(s): 0f28efb

auto-discover harbor binary via PATH, friendlier error

Browse files
Files changed (1) hide show
  1. push_trajectories.py +26 -3
push_trajectories.py CHANGED
@@ -47,8 +47,8 @@ def parse_args() -> argparse.Namespace:
47
  p.add_argument("--date", required=True,
48
  help="Run date as YYYYMMDD (used in the config_name suffix)")
49
  p.add_argument("--repo", required=True, help="HF dataset repo id (org/name)")
50
- p.add_argument("--harbor-bin", default=os.path.expanduser("~/Local/harbor-spike/.venv/bin/harbor"),
51
- help="Path to the harbor CLI")
52
  p.add_argument("--dry-run", action="store_true",
53
  help="Export and tag but do not push")
54
  return p.parse_args()
@@ -131,6 +131,25 @@ def tag_and_push(parquet: Path, args: argparse.Namespace, config_name: str) -> N
131
  print(f"pushed {ds.num_rows} rows to {args.repo} :: config={config_name}")
132
 
133
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  def main() -> None:
135
  args = parse_args()
136
  config_name = f"{args.person}__{args.job_name}__{args.date}"
@@ -140,9 +159,13 @@ def main() -> None:
140
  if not args.jobs_dir.exists():
141
  raise SystemExit(f"jobs-dir does not exist: {args.jobs_dir}")
142
 
 
 
 
143
  with tempfile.TemporaryDirectory(prefix="push_traj_") as tmp:
144
  out_dir = Path(tmp)
145
- parquet = export_with_harbor(args.harbor_bin, args.jobs_dir, out_dir)
 
146
  tag_and_push(parquet, args, config_name)
147
 
148
 
 
47
  p.add_argument("--date", required=True,
48
  help="Run date as YYYYMMDD (used in the config_name suffix)")
49
  p.add_argument("--repo", required=True, help="HF dataset repo id (org/name)")
50
+ p.add_argument("--harbor-bin", default=None,
51
+ help="Path to the harbor CLI. Defaults to `which harbor`; falls back to ~/Local/harbor-spike/.venv/bin/harbor.")
52
  p.add_argument("--dry-run", action="store_true",
53
  help="Export and tag but do not push")
54
  return p.parse_args()
 
131
  print(f"pushed {ds.num_rows} rows to {args.repo} :: config={config_name}")
132
 
133
 
134
+ def resolve_harbor_bin(explicit: str | None) -> str:
135
+ if explicit:
136
+ if not Path(explicit).exists():
137
+ raise SystemExit(f"--harbor-bin path does not exist: {explicit}")
138
+ return explicit
139
+ found = shutil.which("harbor")
140
+ if found:
141
+ return found
142
+ fallback = os.path.expanduser("~/Local/harbor-spike/.venv/bin/harbor")
143
+ if Path(fallback).exists():
144
+ return fallback
145
+ raise SystemExit(
146
+ "Could not find a `harbor` binary. Either:\n"
147
+ " - install harbor and ensure it's on PATH, or\n"
148
+ " - pass --harbor-bin /path/to/harbor explicitly.\n"
149
+ "See https://github.com/laude-institute/harbor for install instructions."
150
+ )
151
+
152
+
153
  def main() -> None:
154
  args = parse_args()
155
  config_name = f"{args.person}__{args.job_name}__{args.date}"
 
159
  if not args.jobs_dir.exists():
160
  raise SystemExit(f"jobs-dir does not exist: {args.jobs_dir}")
161
 
162
+ harbor_bin = resolve_harbor_bin(args.harbor_bin)
163
+ print(f"using harbor: {harbor_bin}")
164
+
165
  with tempfile.TemporaryDirectory(prefix="push_traj_") as tmp:
166
  out_dir = Path(tmp)
167
+ parquet = export_with_harbor(harbor_bin, args.jobs_dir, out_dir)
168
+ args.harbor_bin = harbor_bin # for downstream
169
  tag_and_push(parquet, args, config_name)
170
 
171