From 0f7ee5a04bbc83adf4b2aa8f6d1bdade74a2bbb6 Mon Sep 17 00:00:00 2001
From: Caroline Ott <caroline.ott1994@gmail.com>
Date: Fri, 2 Feb 2024 18:59:29 +0100
Subject: [PATCH] add different cwl use cases

---
 workflows/ARCMount/FSharpArcCapsule.cwl       | 26 +++++++++++++++
 workflows/ARCMount/script.fsx                 | 20 +++++++++++
 workflows/Devcontainer/.gitkeep               |  0
 workflows/Devcontainer/FSharpArcCapsule.cwl   | 27 +++++++++++++++
 .../.config/dotnet-tools.json                 |  5 +++
 .../.devcontainer/devcontainer.json           | 15 +++++++++
 .../.devcontainer/settings.vscode.json        |  3 ++
 .../Devcontainer/FSharpArcCapsule/Dockerfile  | 10 ++++++
 .../Devcontainer/FSharpArcCapsule/script.fsx  | 20 +++++++++++
 workflows/FixedScript/FSharpArcCapsule.cwl    | 33 +++++++++++++++++++
 workflows/FixedScript/script.fsx              | 22 +++++++++++++
 11 files changed, 181 insertions(+)
 create mode 100644 workflows/ARCMount/FSharpArcCapsule.cwl
 create mode 100644 workflows/ARCMount/script.fsx
 create mode 100644 workflows/Devcontainer/.gitkeep
 create mode 100644 workflows/Devcontainer/FSharpArcCapsule.cwl
 create mode 100644 workflows/Devcontainer/FSharpArcCapsule/.config/dotnet-tools.json
 create mode 100644 workflows/Devcontainer/FSharpArcCapsule/.devcontainer/devcontainer.json
 create mode 100644 workflows/Devcontainer/FSharpArcCapsule/.devcontainer/settings.vscode.json
 create mode 100644 workflows/Devcontainer/FSharpArcCapsule/Dockerfile
 create mode 100644 workflows/Devcontainer/FSharpArcCapsule/script.fsx
 create mode 100644 workflows/FixedScript/FSharpArcCapsule.cwl
 create mode 100644 workflows/FixedScript/script.fsx

diff --git a/workflows/ARCMount/FSharpArcCapsule.cwl b/workflows/ARCMount/FSharpArcCapsule.cwl
new file mode 100644
index 0000000..2602936
--- /dev/null
+++ b/workflows/ARCMount/FSharpArcCapsule.cwl
@@ -0,0 +1,26 @@
+cwlVersion: v1.2
+class: CommandLineTool
+hints:
+  DockerRequirement:
+    dockerPull: mcr.microsoft.com/dotnet/sdk:6.0
+requirements:
+  - class: InitialWorkDirRequirement
+    listing:
+      - entryname: arc
+        entry: $(inputs.arcDirectory)
+        writable: true
+  - class: EnvVarRequirement
+    envDef:
+      - envName: DOTNET_NOLOGO
+        envValue: "true"
+  - class: NetworkAccess
+    networkAccess: true
+baseCommand: [dotnet, fsi, "./arc/workflows/FSharpArcCapsule/script.fsx"]
+inputs:
+  arcDirectory:
+    type: Directory
+outputs:
+  output:
+    type: File
+    outputBinding:
+      glob: "./arc/runs/fsResult1/result.csv"
\ No newline at end of file
diff --git a/workflows/ARCMount/script.fsx b/workflows/ARCMount/script.fsx
new file mode 100644
index 0000000..155693f
--- /dev/null
+++ b/workflows/ARCMount/script.fsx
@@ -0,0 +1,20 @@
+#r "nuget: FSharp.Data, 5.0.2"
+
+open FSharp.Data
+open System.IO
+
+printfn "%A" (System.IO.Directory.GetCurrentDirectory())
+
+let data =
+    CsvFile
+        .Load(Path.Combine(System.IO.Directory.GetCurrentDirectory(),"./arc/assays/measurement1/dataset/table.csv"))
+        .Cache()
+        
+let r =
+    [
+        yield "Sum_1-2"
+        for row in data.Rows do
+            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
diff --git a/workflows/Devcontainer/.gitkeep b/workflows/Devcontainer/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/workflows/Devcontainer/FSharpArcCapsule.cwl b/workflows/Devcontainer/FSharpArcCapsule.cwl
new file mode 100644
index 0000000..c8c166c
--- /dev/null
+++ b/workflows/Devcontainer/FSharpArcCapsule.cwl
@@ -0,0 +1,27 @@
+cwlVersion: v1.2
+class: CommandLineTool
+hints:
+  DockerRequirement:
+    dockerImageId: "devcontainer"
+    dockerFile: {$include: "FSharpArcCapsule/Dockerfile"}
+requirements:
+  - class: InitialWorkDirRequirement
+    listing:
+      - entryname: arc
+        entry: $(inputs.arcDirectory)
+        writable: true
+  - class: EnvVarRequirement
+    envDef:
+      - envName: DOTNET_NOLOGO
+        envValue: "true"
+  - class: NetworkAccess
+    networkAccess: true
+baseCommand: [dotnet, fsi, "./arc/workflows/Devcontainer/FSharpArcCapsule/script.fsx"]
+inputs:
+  arcDirectory:
+    type: Directory
+outputs:
+  output:
+    type: File
+    outputBinding:
+      glob: "./arc/runs/fsResult1/result.csv"
\ No newline at end of file
diff --git a/workflows/Devcontainer/FSharpArcCapsule/.config/dotnet-tools.json b/workflows/Devcontainer/FSharpArcCapsule/.config/dotnet-tools.json
new file mode 100644
index 0000000..b0e38ab
--- /dev/null
+++ b/workflows/Devcontainer/FSharpArcCapsule/.config/dotnet-tools.json
@@ -0,0 +1,5 @@
+{
+  "version": 1,
+  "isRoot": true,
+  "tools": {}
+}
\ No newline at end of file
diff --git a/workflows/Devcontainer/FSharpArcCapsule/.devcontainer/devcontainer.json b/workflows/Devcontainer/FSharpArcCapsule/.devcontainer/devcontainer.json
new file mode 100644
index 0000000..71ac9e7
--- /dev/null
+++ b/workflows/Devcontainer/FSharpArcCapsule/.devcontainer/devcontainer.json
@@ -0,0 +1,15 @@
+{
+    "name": "F#ARC-Capsule",
+    "dockerFile": "../Dockerfile",
+    "appPort": [8080],
+    "extensions": [
+        "ionide.ionide-fsharp",
+        "ms-vscode.csharp",
+        "editorconfig.editorconfig",        
+        "ionide.ionide-paket",
+        "ionide.ionide-fake"
+    ],
+    "mounts": [
+        "source=${localWorkspaceFolder}/../../,target=/arc,type=bind,consistency=cached"
+      ]
+} 
\ No newline at end of file
diff --git a/workflows/Devcontainer/FSharpArcCapsule/.devcontainer/settings.vscode.json b/workflows/Devcontainer/FSharpArcCapsule/.devcontainer/settings.vscode.json
new file mode 100644
index 0000000..5b238fa
--- /dev/null
+++ b/workflows/Devcontainer/FSharpArcCapsule/.devcontainer/settings.vscode.json
@@ -0,0 +1,3 @@
+{
+    "FSharp.fsacRuntime":"netcore"
+}
\ No newline at end of file
diff --git a/workflows/Devcontainer/FSharpArcCapsule/Dockerfile b/workflows/Devcontainer/FSharpArcCapsule/Dockerfile
new file mode 100644
index 0000000..982b4cd
--- /dev/null
+++ b/workflows/Devcontainer/FSharpArcCapsule/Dockerfile
@@ -0,0 +1,10 @@
+#FROM rocker/r-ver:3.4.4
+FROM mcr.microsoft.com/dotnet/sdk:6.0
+#FROM r-base
+# Copy endpoint specific user settings into container to specify
+# .NET Core should be used as the runtime.
+COPY *.devcontainer/settings.vscode.json /root/.vscode-remote/data/Machine/settings.json
+
+# Install git, process tools
+RUN apt-get update && apt-get -y install git procps
+
diff --git a/workflows/Devcontainer/FSharpArcCapsule/script.fsx b/workflows/Devcontainer/FSharpArcCapsule/script.fsx
new file mode 100644
index 0000000..155693f
--- /dev/null
+++ b/workflows/Devcontainer/FSharpArcCapsule/script.fsx
@@ -0,0 +1,20 @@
+#r "nuget: FSharp.Data, 5.0.2"
+
+open FSharp.Data
+open System.IO
+
+printfn "%A" (System.IO.Directory.GetCurrentDirectory())
+
+let data =
+    CsvFile
+        .Load(Path.Combine(System.IO.Directory.GetCurrentDirectory(),"./arc/assays/measurement1/dataset/table.csv"))
+        .Cache()
+        
+let r =
+    [
+        yield "Sum_1-2"
+        for row in data.Rows do
+            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
diff --git a/workflows/FixedScript/FSharpArcCapsule.cwl b/workflows/FixedScript/FSharpArcCapsule.cwl
new file mode 100644
index 0000000..e70401e
--- /dev/null
+++ b/workflows/FixedScript/FSharpArcCapsule.cwl
@@ -0,0 +1,33 @@
+cwlVersion: v1.2
+class: CommandLineTool
+hints:
+  DockerRequirement:
+    dockerPull: mcr.microsoft.com/dotnet/sdk:6.0
+requirements:
+  - class: InitialWorkDirRequirement
+    listing:
+      - entryname: script.fsx
+        entry:
+          $include: script.fsx
+  - class: EnvVarRequirement
+    envDef:
+      - envName: DOTNET_NOLOGO
+        envValue: "true"
+  - class: NetworkAccess
+    networkAccess: true
+baseCommand: [dotnet, fsi, script.fsx]
+inputs:
+  firstArg:
+    type: File
+    inputBinding:
+      position: 1
+  secondArg:
+    type: string
+    inputBinding:
+      position: 2
+
+outputs:
+  output:
+    type: File
+    outputBinding:
+      glob: "*.csv"
\ No newline at end of file
diff --git a/workflows/FixedScript/script.fsx b/workflows/FixedScript/script.fsx
new file mode 100644
index 0000000..581145d
--- /dev/null
+++ b/workflows/FixedScript/script.fsx
@@ -0,0 +1,22 @@
+#r "nuget: FSharp.Data, 5.0.2"
+
+open FSharp.Data
+open System.IO
+
+let args : string array = fsi.CommandLineArgs |> Array.tail
+let first = args.[0]
+let second = args.[1]
+
+let data =
+    CsvFile
+        .Load(first)
+        .Cache()
+        
+let r =
+    [
+        yield "Sum_1-2"
+        for row in data.Rows do
+            yield sprintf "%f"  ((row.["value_1"].AsFloat()) + (row.["value_2"].AsFloat()))
+    ]
+
+System.IO.File.WriteAllLines(second,r)
\ No newline at end of file
-- 
GitLab