Handoff completed training into closed loop
This commit is contained in:
@@ -46,6 +46,7 @@ def main() -> int:
|
||||
parser.add_argument("--yolo", default="/opt/geointel/venv/bin/yolo")
|
||||
parser.add_argument("--poll-seconds", type=int, default=30)
|
||||
parser.add_argument("--max-resumes", type=int, default=20)
|
||||
parser.add_argument("--completion-command-json", type=Path)
|
||||
parser.add_argument("--once", action="store_true")
|
||||
args = parser.parse_args()
|
||||
if args.poll_seconds < 1 or args.max_resumes < 1:
|
||||
@@ -58,7 +59,27 @@ def main() -> int:
|
||||
|
||||
while True:
|
||||
if (args.host_run_dir / "results.png").is_file():
|
||||
state["status"] = "training_finished"
|
||||
if state.get("completion_handoff_started"):
|
||||
state["status"] = "training_finished_handoff_already_started"
|
||||
write_state(state_path, state)
|
||||
return 0
|
||||
if args.completion_command_json:
|
||||
command = json.loads(args.completion_command_json.read_text(encoding="utf-8"))
|
||||
if not isinstance(command, list) or not command or not all(isinstance(x, str) and x for x in command):
|
||||
state["status"] = "invalid_completion_command"
|
||||
write_state(state_path, state)
|
||||
return 4
|
||||
result = subprocess.run(command, check=False)
|
||||
if result.returncode != 0:
|
||||
state["status"] = "completion_handoff_failed"
|
||||
state["completion_handoff_returncode"] = result.returncode
|
||||
write_state(state_path, state)
|
||||
return 5
|
||||
state["completion_handoff_started"] = True
|
||||
state["completion_command"] = command
|
||||
state["status"] = "training_finished_handoff_started"
|
||||
else:
|
||||
state["status"] = "training_finished"
|
||||
write_state(state_path, state)
|
||||
return 0
|
||||
checkpoint = args.host_run_dir / "weights" / "last.pt"
|
||||
|
||||
Reference in New Issue
Block a user