aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2025-01-23 00:27:27 +0000
committerArun Isaac2025-01-23 00:27:27 +0000
commitb0c1c76152430950a704c5bc3d42dcfe11dfffa2 (patch)
treea67aed887710b11ec487f00498e20eb28fe3950f
parent3a7abb9f295409c93db8ee12909c69dee9730e71 (diff)
downloadravanan-b0c1c76152430950a704c5bc3d42dcfe11dfffa2.tar.gz
ravanan-b0c1c76152430950a704c5bc3d42dcfe11dfffa2.tar.lz
ravanan-b0c1c76152430950a704c5bc3d42dcfe11dfffa2.zip
slurm-api: Bind return value of slurm-http-get in the state monad.
* ravanan/slurm-api.scm (job-state): Bind return value of slurm-http-get in the state monad.
-rw-r--r--ravanan/slurm-api.scm53
1 files changed, 27 insertions, 26 deletions
diff --git a/ravanan/slurm-api.scm b/ravanan/slurm-api.scm
index 7c479ee..32dc3c7 100644
--- a/ravanan/slurm-api.scm
+++ b/ravanan/slurm-api.scm
@@ -118,35 +118,36 @@ monad."
jwt
(string-append "/slurm/v0.0.41/job/"
(number->string job-id)))))
- (state-return
- (match (json-ref response "errors")
- (#()
+ (match (json-ref response "errors")
+ (#()
+ (state-return
(match (json-ref (find (lambda (job)
(= (json-ref job "job_id")
job-id))
(vector->list (json-ref response "jobs")))
"job_state")
(#(job-state)
- (string->symbol (string-downcase job-state)))))
- (#(errors ...)
- ;; Check in slurmdbd if job has been completed and purged from
- ;; slurmctld's active memory.
- (match (find (lambda (error)
- (= (json-ref error "error_number")
- ;; Error number 2017 (Invalid job id specified) may
- ;; have occurred because the job has completed, has
- ;; exceeded MinJobAge (as set in slurm.conf) and has
- ;; therefore been purged from slurmctld's active
- ;; memory.
- 2017))
- errors)
- (error-2017
- (let ((response
- (check-api-error
- (slurm-http-get api-endpoint
- jwt
- (string-append "/slurmdb/v0.0.41/job/"
- (number->string job-id))))))
+ (string->symbol (string-downcase job-state))))))
+ (#(errors ...)
+ ;; Check in slurmdbd if job has been completed and purged from
+ ;; slurmctld's active memory.
+ (match (find (lambda (error)
+ (= (json-ref error "error_number")
+ ;; Error number 2017 (Invalid job id specified) may
+ ;; have occurred because the job has completed, has
+ ;; exceeded MinJobAge (as set in slurm.conf) and has
+ ;; therefore been purged from slurmctld's active
+ ;; memory.
+ 2017))
+ errors)
+ (error-2017
+ (state-let* ((response
+ (slurm-http-get api-endpoint
+ jwt
+ (string-append "/slurmdb/v0.0.41/job/"
+ (number->string job-id)))))
+ (check-api-error response)
+ (state-return
(match (json-ref (find (lambda (job)
(= (json-ref job "job_id")
job-id))
@@ -157,6 +158,6 @@ monad."
(if (eq? (string->symbol (string-downcase job-state))
'success)
'success
- 'failed)))))
- (#f
- (check-api-error response))))))))
+ 'failed))))))
+ (#f
+ (state-return (check-api-error response))))))))