From 593cf34a8d9c198e06e5ba49d6773ffe027a109c Mon Sep 17 00:00:00 2001
From: Jonathan Ott <jonathan.ott1994@gmail.com>
Date: Thu, 3 Aug 2023 14:29:10 +0200
Subject: [PATCH] add cwl, change script.fsx to accept args

---
 runs/FSharpArcCapsule.yml             |  7 ++++++
 workflows/FSharpArcCapsule.cwl        | 31 +++++++++++++++++++++++++++
 workflows/FSharpArcCapsule/script.fsx |  8 +++++--
 3 files changed, 44 insertions(+), 2 deletions(-)
 create mode 100644 runs/FSharpArcCapsule.yml
 create mode 100644 workflows/FSharpArcCapsule.cwl

diff --git a/runs/FSharpArcCapsule.yml b/runs/FSharpArcCapsule.yml
new file mode 100644
index 0000000..5da154d
--- /dev/null
+++ b/runs/FSharpArcCapsule.yml
@@ -0,0 +1,7 @@
+scriptFile:
+  class: File
+  path: ../workflows/FSharpArcCapsule/script.fsx
+firstArg:
+  class: File
+  path: ../assays/measurement1/dataset/table.csv
+secondArg: ./result.csv
diff --git a/workflows/FSharpArcCapsule.cwl b/workflows/FSharpArcCapsule.cwl
new file mode 100644
index 0000000..9e14f74
--- /dev/null
+++ b/workflows/FSharpArcCapsule.cwl
@@ -0,0 +1,31 @@
+cwlVersion: v1.2
+class: CommandLineTool
+hints:
+  DockerRequirement:
+    dockerPull: mcr.microsoft.com/dotnet/sdk:6.0
+requirements:
+  EnvVarRequirement:
+    envDef:
+      - envName: DOTNET_NOLOGO
+        envValue: "true"
+  NetworkAccess:
+    networkAccess: true
+baseCommand: [dotnet, fsi]
+inputs:
+  scriptFile:
+    type: File
+    inputBinding:
+      position: 1
+  firstArg:
+    type: File
+    inputBinding:
+      position: 2
+  secondArg:
+    type: string
+    inputBinding:
+      position: 3
+outputs:
+  output:
+    type: File
+    outputBinding:
+      glob: "*.csv"
\ No newline at end of file
diff --git a/workflows/FSharpArcCapsule/script.fsx b/workflows/FSharpArcCapsule/script.fsx
index 6248b03..f4deb90 100644
--- a/workflows/FSharpArcCapsule/script.fsx
+++ b/workflows/FSharpArcCapsule/script.fsx
@@ -3,9 +3,13 @@
 open FSharp.Data
 
 
+let args : string array = fsi.CommandLineArgs |> Array.tail
+let first = args.[0]
+let second = args.[1]
+
 let data =
     CsvFile
-        .Load("/arc/assays/measurement1/dataset/table.csv")
+        .Load(first)
         .Cache()
 
 let r =
@@ -15,4 +19,4 @@ let r =
             yield sprintf "%f"  ((row.["value_1"].AsFloat()) + (row.["value_2"].AsFloat()))
     ]
 
-System.IO.File.WriteAllLines("/arc/runs/fsResult1/result.csv",r)
\ No newline at end of file
+System.IO.File.WriteAllLines(second,r)
\ No newline at end of file
-- 
GitLab