From 9ae12151814297dd9249f4589b36a2d4a94d9c72 Mon Sep 17 00:00:00 2001 From: "Robert P. Goldman" Date: Wed, 22 Nov 2023 16:19:42 -0600 Subject: [PATCH] Fix issues handling timeouts. --- panda-planner.asd | 2 +- planners/panda.lisp | 29 +++++++++++++++++++---------- version.lisp-expr | 2 +- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/panda-planner.asd b/panda-planner.asd index 70c4ac6..4072587 100644 --- a/panda-planner.asd +++ b/panda-planner.asd @@ -10,7 +10,7 @@ (in-package :panda-planner-asd) (defsystem panda-planner - :depends-on (pddl-planners) + :depends-on (pddl-planners hddl-utils) :version (:read-file-form "version.lisp-expr") :pathname "planners/" :components ((:file "panda"))) diff --git a/planners/panda.lisp b/planners/panda.lisp index 07f673d..45de980 100644 --- a/planners/panda.lisp +++ b/planners/panda.lisp @@ -38,7 +38,7 @@ (multiple-value-bind (output error-output success) (uiop:run-program (list "timeout" - "--signal=KILL" + ;; "--signal=KILL" (format nil "~ds" remaining-time) panda-pi-parser (namestring domain-file) @@ -48,15 +48,18 @@ :error-output :output :output :string) (declare (ignore error-output)) - (unless (zerop success) - (error "Failed to parse the domain and/or problem with exit code ~d.~%Output:~%~a" success output))) + (cond ((= success 124) + (error "Timed out while parsing the domain and/or problem")) + ((zerop success)) + (t + (error "Failed to parse the domain and/or problem with exit code ~d.~%Output:~%~a" success output)))) (decf remaining-time (elapsed-seconds start-time (get-internal-run-time))) (when (< remaining-time 0) (error "Timeout during parsing.")) (when verbose (format t "~&Done parsing HDDL inputs.~%")) (setf start-time (get-internal-run-time)) (multiple-value-bind (output error-output success) (uiop:run-program (list "timeout" - "--signal=KILL" + ;; "--signal=KILL" (format nil "~ds" remaining-time) panda-pi-grounder parsed-file @@ -66,14 +69,16 @@ :output :string) (declare (ignore error-output)) (decf remaining-time (elapsed-seconds start-time (get-internal-run-time))) - (unless (zerop success) - (error "Failed to ground the problem with exit code ~d.~%Output:~%~a" success output)) + (cond ((= success 124) + (error "Timed out while grounding the domain and problem")) + ((zerop success)) + (t + (error "Failed to ground the domain and problem with exit code ~d.~%Output:~%~a" success output))) (when (search "unreachable" output) (error "Panda grounder proved the problem unsolveable.~%Output:~%~a" output))) (when (< remaining-time 0) (error "Timeout during grounding.")) (when verbose (format t "~&Done grounding Panda problem.~%")) - (delete-file raw-plan) (setf start-time (get-internal-run-time)) (multiple-value-bind (output error-output success) (uiop:run-program (list panda-pi-engine @@ -81,12 +86,16 @@ grounded-file) :ignore-error-status t :error-output :output + :if-output-exists :supersede :output raw-plan) (declare (ignore output error-output)) (decf remaining-time (elapsed-seconds start-time (get-internal-run-time))) - (when (< remaining-time 0) (error "Timeout during grounding.")) - (unless (zerop success) - (error "Failed to solve the problem with exit code ~d.~%Output:~%~a" success (alexandria:read-file-into-string raw-plan)))) + (when (< remaining-time 0) (error "Timeout during planning.")) + (cond ((or (= success 124) (= success 137)) + (error "Timed out while finding a solution for the problem (pandaPIengine)")) + ((zerop success)) + (t + (error "Failed to solve the problem with exit code ~d.~%Output:~%~a" success (alexandria:read-file-into-string raw-plan))))) (when verbose (format t "~&Done solving Panda problem.~%")) (multiple-value-bind (output error-output success) (uiop:run-program (list panda-pi-parser "-c" raw-plan hddl-plan) diff --git a/version.lisp-expr b/version.lisp-expr index 65640cc..038707f 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -1 +1 @@ -"3.2.0" +"3.2.1"