about summary refs log tree commit diff
diff options
context:
space:
mode:
authorArun Isaac2026-07-01 14:38:00 +0100
committerArun Isaac2026-07-01 23:14:41 +0100
commit1578e7df972b61e8ece643dc9109492436e711f8 (patch)
treea98a71fc70708738406955d04ed43c99e47f2f62
parent3e7eb08448ab76cfee6b7f561a3837631a386d6a (diff)
downloadccwl-1578e7df972b61e8ece643dc9109492436e711f8.tar.gz
ccwl-1578e7df972b61e8ece643dc9109492436e711f8.tar.lz
ccwl-1578e7df972b61e8ece643dc9109492436e711f8.zip
ccwl: Resolve cwl-workflow paths relative to source file path.
-rw-r--r--ccwl/ccwl.scm80
-rw-r--r--tests/ccwl.scm2
2 files changed, 42 insertions, 40 deletions
diff --git a/ccwl/ccwl.scm b/ccwl/ccwl.scm
index 8714e81..f15392b 100644
--- a/ccwl/ccwl.scm
+++ b/ccwl/ccwl.scm
@@ -645,45 +645,47 @@ identifiers defined in the commands."
   (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-continuable
-            (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 #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 '()))))
-                           (parameters->id+type (assoc-ref yaml "outputs")))))))))))
+       (let* ((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))))
+              (file (syntax->datum #'file-syntax))
+              (path (resolve-file-syntax file #'file-syntax))
+              (yaml
+               (if (file-exists? path)
+                   (read-yaml-file path)
+                   (raise-continuable
+                    (condition (ccwl-violation #'file-syntax)
+                               (formatted-message "CWL workflow file ~a does not exist"
+                                                  file))))))
+         ;; Build a <cwl-workflow> object from read CWL workflow YAML.
+         #`(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 #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 '()))))
+                          (parameters->id+type (assoc-ref yaml "outputs"))))))))))
 
 (define (function-inputs function)
   "Return the list of inputs accepted by @var{function}---a
diff --git a/tests/ccwl.scm b/tests/ccwl.scm
index d6703c7..38a8302 100644
--- a/tests/ccwl.scm
+++ b/tests/ccwl.scm
@@ -67,7 +67,7 @@
   '(((spam string))
     ((ham stdout)
      (eggs stdout)))
-  (let ((cwl-workflow (cwl-workflow "tests/input-output-parameters.cwl")))
+  (let ((cwl-workflow (cwl-workflow "input-output-parameters.cwl")))
     (list (map (lambda (input)
                  (list (input-id input)
                        (input-type input)))