aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2025-01-19 23:49:46 +0000
committerArun Isaac2025-01-21 00:16:16 +0000
commit96140e46e18c72ad57bc2e2cca1d9933a8fd4966 (patch)
tree450db13806610f463996d7cfa5b564ecf1a02d2d
parent231c3532bc6b6325cebf2d0d28d41f7ea4c2ace1 (diff)
downloadravanan-96140e46e18c72ad57bc2e2cca1d9933a8fd4966.tar.gz
ravanan-96140e46e18c72ad57bc2e2cca1d9933a8fd4966.tar.lz
ravanan-96140e46e18c72ad57bc2e2cca1d9933a8fd4966.zip
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 (<command-line-tool-state>)[job-state]: Remove setter.
-rw-r--r--ravanan/job-state.scm45
-rw-r--r--ravanan/workflow.scm21
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>
(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 <workflow-state>
@@ -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)