-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlaunch.py
More file actions
67 lines (54 loc) · 2.07 KB
/
launch.py
File metadata and controls
67 lines (54 loc) · 2.07 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
#!/usr/bin/env python3
"""Root task launcher for training, dataset generation, and inference workflows."""
from __future__ import annotations
import argparse
import shlex
import subprocess
import sys
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent
TASKS: dict[str, list[str]] = {
# Training
"train-embeddings": [sys.executable, "-m", "kurome.cli.train_embeddings"],
"train-tensors": [sys.executable, "-m", "kurome.cli.train_embeddings"],
"train-features": [sys.executable, "-m", "kurome.cli.train_features"],
# Dataset / feature generation
"build-embeddings": [sys.executable, "-m", "kurome.cli.generate_embeddings"],
"build-features": [sys.executable, "-m", "kurome.cli.generate_feature_sequences"],
"build-manifest": [sys.executable, "-m", "kurome.cli.build_image_manifest"],
"build-forensic-tensors": [sys.executable, "-m", "kurome.cli.build_forensic_tensors"],
"prepare-data": [sys.executable, "-m", "kurome.cli.prepare_data"],
# Inference (folder pipeline)
"infer-folder": [sys.executable, "-m", "kurome.cli.infer_folder"],
}
def _parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(
description=(
"Launch kurome workflows from a single root entrypoint. "
"Use '--' to forward task-specific arguments."
)
)
parser.add_argument(
"task",
choices=sorted(TASKS),
help="Task name to run.",
)
parser.add_argument(
"task_args",
nargs=argparse.REMAINDER,
help="Arguments forwarded to the selected task.",
)
return parser.parse_args()
def main() -> int:
args = _parse_args()
forwarded = list(args.task_args)
if forwarded and forwarded[0] == "--":
forwarded = forwarded[1:]
cmd = TASKS[args.task] + forwarded
rendered = " ".join(shlex.quote(part) for part in cmd)
print(f"[launch] cwd={REPO_ROOT}")
print(f"[launch] exec: {rendered}")
completed = subprocess.run(cmd, cwd=REPO_ROOT)
return completed.returncode
if __name__ == "__main__":
raise SystemExit(main())