summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2023-11-18 22:35:31 +0000
committerArun Isaac2023-11-18 22:35:31 +0000
commit7622601e5f99ca98933ffc52908c5749d333dec2 (patch)
treea62e686f9f532f28efc17c5e07dc0c95b2fda189
parent299a60b666e64df20f1c7065b58aa43e163caae9 (diff)
downloadccwl-7622601e5f99ca98933ffc52908c5749d333dec2.tar.gz
ccwl-7622601e5f99ca98933ffc52908c5749d333dec2.tar.lz
ccwl-7622601e5f99ca98933ffc52908c5749d333dec2.zip
ccwl: Report non-existent external CWL workflow files.
cwl-workflow needs to be a macro so we have access to syntax objects necessary to raise a &cwl-violation condition. * ccwl/ccwl.scm (cwl-workflow): Rewrite as macro. Report error if CWL file does not exist.
-rw-r--r--ccwl/ccwl.scm75
1 files changed, 43 insertions, 32 deletions
diff --git a/ccwl/ccwl.scm b/ccwl/ccwl.scm
index 0b8f701..429bbed 100644
--- a/ccwl/ccwl.scm
+++ b/ccwl/ccwl.scm
@@ -463,38 +463,49 @@ identifiers defined in the commands."
'#,other))
#'(args ...)))))))
-(define (cwl-workflow file)
- (define (parameters->id+type parameters)
- (if (vector? parameters)
- ;; Vector of dictionaries
- (map (lambda (alist)
- (cons (string->symbol (assoc-ref alist "id"))
- (string->symbol (assoc-ref alist "type"))))
- (vector->list parameters))
- ;; One dictionary
- (map (match-lambda
- ((id . (? string? type))
- (cons (string->symbol id)
- (string->symbol type)))
- ((id . alist)
- (cons (string->symbol id)
- (string->symbol (assoc-ref alist "type")))))
- parameters)))
-
- (unless (file-exists? file)
- (error "CWL workflow file does not exist" file))
- ;; Read inputs/outputs from CWL workflow YAML file and build a
- ;; <cwl-workflow> object.
- (let ((yaml (read-yaml-file file)))
- (make-cwl-workflow file
- (map (match-lambda
- ((id . type)
- (make-input id type #f #f #f #f #f #f)))
- (parameters->id+type (assoc-ref yaml "inputs")))
- (map (match-lambda
- ((id . type)
- (make-output id type #f #f #f)))
- (parameters->id+type (assoc-ref yaml "outputs"))))))
+(define-syntax cwl-workflow
+ (lambda (x)
+ (syntax-case x ()
+ ((_ file-syntax)
+ (let ((file (syntax->datum #'file-syntax))
+ (parameters->id+type
+ (lambda (parameters)
+ (if (vector? parameters)
+ ;; Vector of dictionaries
+ (map (lambda (alist)
+ (cons (string->symbol (assoc-ref alist "id"))
+ (string->symbol (assoc-ref alist "type"))))
+ (vector->list parameters))
+ ;; One dictionary
+ (map (match-lambda
+ ((id . (? string? type))
+ (cons (string->symbol id)
+ (string->symbol type)))
+ ((id . alist)
+ (cons (string->symbol id)
+ (string->symbol (assoc-ref alist "type")))))
+ parameters)))))
+ (unless (file-exists? file)
+ (raise-exception
+ (condition (ccwl-violation #'file-syntax)
+ (formatted-message "CWL workflow file ~a does not exist" file))))
+ ;; Read inputs/outputs from CWL workflow YAML file and build
+ ;; a <cwl-workflow> object.
+ (let ((yaml (read-yaml-file file)))
+ #`(make-cwl-workflow
+ file-syntax
+ (list #,@(map (match-lambda
+ ((id . type)
+ (with-syntax ((id (datum->syntax #f id))
+ (type (datum->syntax #f type)))
+ #`(make-input 'id 'type #f #f #f #f #f #f))))
+ (parameters->id+type (assoc-ref yaml "inputs"))))
+ (list #,@(map (match-lambda
+ ((id . type)
+ (with-syntax ((id (datum->syntax #f id))
+ (type (datum->syntax #f type)))
+ #`(make-output 'id 'type #f #f #f))))
+ (parameters->id+type (assoc-ref yaml "outputs")))))))))))
(define (function-inputs function)
"Return the list of inputs accepted by @var{function}---a