From 96140e46e18c72ad57bc2e2cca1d9933a8fd4966 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Sun, 19 Jan 2025 23:49:46 +0000 Subject: job-state: Do not allow updating of low-level job-state objects. Low-level job-state objects tied to the batch system (such as those that represent single-machine and slurm-api jobs) never get updated. So, there is no point permitting it. * ravanan/job-state.scm (job-state-status): Return only the job status, not the updated job state. * ravanan/workflow.scm (workflow-scheduler)[poll]: Accept only the job status, not the updated job state, from job-state-status. * ravanan/workflow.scm ()[job-state]: Remove setter. --- ravanan/job-state.scm | 45 ++++++++++++++++++++++----------------------- ravanan/workflow.scm | 21 +++++++++------------ 2 files changed, 31 insertions(+), 35 deletions(-) diff --git a/ravanan/job-state.scm b/ravanan/job-state.scm index 3d620f2..34bba81 100644 --- a/ravanan/job-state.scm +++ b/ravanan/job-state.scm @@ -60,26 +60,25 @@ "Return current status and updated state of job with @var{state} on @var{batch-system}. The status is one of the symbols @code{completed}, @code{failed} or @code{pending}." - (values (cond - ;; Single machine jobs are run synchronously. So, they return success - ;; or failure immediately. - ((single-machine-job-state? state) - (if (single-machine-job-state-success? state) - 'completed - 'failed)) - ;; Poll slurm for job state. - ((slurm-job-state? state) - (run-with-state - (job-state (slurm-job-state-job-id state) - #:api-endpoint (slurm-api-batch-system-endpoint batch-system) - #:jwt (slurm-api-batch-system-jwt batch-system)))) - ;; For vector states, poll each state element and return 'completed - ;; only if all state elements have completed. - ((vector? state) - (or (vector-every (lambda (state-element) - (case (job-state-status state-element batch-system) - ((completed) => identity) - (else #f))) - state) - 'pending))) - state)) + (cond + ;; Single machine jobs are run synchronously. So, they return success or + ;; failure immediately. + ((single-machine-job-state? state) + (if (single-machine-job-state-success? state) + 'completed + 'failed)) + ;; Poll slurm for job state. + ((slurm-job-state? state) + (run-with-state + (job-state (slurm-job-state-job-id state) + #:api-endpoint (slurm-api-batch-system-endpoint batch-system) + #:jwt (slurm-api-batch-system-jwt batch-system)))) + ;; For vector states, poll each state element and return 'completed only if + ;; all state elements have completed. + ((vector? state) + (or (vector-every (lambda (state-element) + (case (job-state-status state-element batch-system) + ((completed) => identity) + (else #f))) + state) + 'pending)))) diff --git a/ravanan/workflow.scm b/ravanan/workflow.scm index 1ef9284..13deb6f 100644 --- a/ravanan/workflow.scm +++ b/ravanan/workflow.scm @@ -71,8 +71,7 @@ (define-immutable-record-type (command-line-tool-state job-state formal-outputs) command-line-tool-state? - (job-state command-line-tool-state-job-state - set-command-line-tool-state-job-state) + (job-state command-line-tool-state-job-state) (formal-outputs command-line-tool-state-formal-outputs)) (define-immutable-record-type @@ -334,16 +333,14 @@ exit if job has failed." state))) ;; Poll job state. Raise an exception if the job has failed. ((command-line-tool-state? state) - (let ((status updated-job-state - (job-state-status (command-line-tool-state-job-state state) - batch-system))) - (values (case status - ((failed) - (raise-exception (job-failure - (job-state-script - (command-line-tool-state-job-state state))))) - (else => identity)) - (set-command-line-tool-state-job-state state updated-job-state)))) + (values (case (job-state-status (command-line-tool-state-job-state state) + batch-system) + ((failed) + (raise-exception (job-failure + (job-state-script + (command-line-tool-state-job-state state))))) + (else => identity)) + state)) ;; Poll sub-workflow state. We do not need to check the status here since ;; job failures only occur at the level of a CommandLineTool. ((workflow-state? state) -- cgit v1.2.3