From e672266c445d1ca9daf892ea65e08f200123afc2 Mon Sep 17 00:00:00 2001
From: Tammo Jan Dijkema <dijkema@astron.nl>
Date: Fri, 25 Oct 2019 16:07:09 +0200
Subject: [PATCH] Add H5ParmCollector

Former-commit-id: 1d7f61a028b74f5cf250fff31cfc28e11f04c255
---
 .gitlab-ci.yml                      | 12 ++++++++++
 Docker/Dockerfile                   |  3 +++
 steps/H5ParmCollector.cwl           | 36 +++++++++++++++++++++++++++++
 test_data/example.h5.REMOVED.git-id |  1 +
 test_jobs/h5parm_collector.json     |  8 +++++++
 5 files changed, 60 insertions(+)
 create mode 100755 steps/H5ParmCollector.cwl
 create mode 100644 test_data/example.h5.REMOVED.git-id
 create mode 100644 test_jobs/h5parm_collector.json

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ab043a38..b7b08443 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -64,6 +64,12 @@ NDPPP:
   script:
     - cwltool --no-container --preserve-environment LD_LIBRARY_PATH --preserve-environment PATH steps/DPPP.cwl test_jobs/NDPPP.json
 
+h5parm_collector:
+  stage: test_steps
+  allow_failure: true
+  script:
+    - cwltool --no-container --preserve-environment LD_LIBRARY_PATH --preserve-environment PATH --preserve-environment PYTHONPATH steps/H5ParmCollector.cwl test_jobs/h5parm_collector.json
+
 aoflagger:
   stage: test_steps
   allow_failure: true
@@ -82,6 +88,12 @@ interpolate_visibilities:
   script:
     - cwltool --no-container --preserve-environment LD_LIBRARY_PATH --preserve-environment PATH --preserve-environment PYTHONPATH steps/interpolate_visibilities.cwl test_jobs/interpolate_visibilities.json
 
+h5parm_collector:
+  stage: test_steps
+  allow_failure: true
+  script:
+    - cwltool --no-container --preserve-environment LD_LIBRARY_PATH --preserve-environment PATH --preserve-environment PYTHONPATH steps/H5ParmCollector.cwl test_jobs/h5parm_collector.json
+ 
 blsmooth:
   stage: test_steps
   allow_failure: true
diff --git a/Docker/Dockerfile b/Docker/Dockerfile
index cf33dffa..516becf3 100644
--- a/Docker/Dockerfile
+++ b/Docker/Dockerfile
@@ -93,8 +93,11 @@ ARG LSMTool_TAG=master
 RUN apt-get update && apt-get install -y nodejs python3-pip git wsclean
 RUN python3 -m pip install cwltool cwl-runner -e "git://github.com/darafferty/LSMTool.git@${LSMTool_TAG}#egg=LSMTool"
 
+RUN python3 -m pip install git+https://github.com/revoltek/losoto.git
+
 ADD L570745_uv_first10.MS.tar.xz /data
 ADD skymodels.tar.gz /data/skymodels
+ADD example.h5 /data
 ADD .entrypoint /home/lofaruser/.entrypoint
 RUN chown lofaruser:lofaruser /home/lofaruser/.entrypoint && \ 
     chmod +rx /home/lofaruser/.entrypoint
diff --git a/steps/H5ParmCollector.cwl b/steps/H5ParmCollector.cwl
new file mode 100755
index 00000000..46442b33
--- /dev/null
+++ b/steps/H5ParmCollector.cwl
@@ -0,0 +1,36 @@
+#!/usr/bin/env cwl-runner
+
+class: CommandLineTool
+cwlVersion: v1.0
+id: h5parm_collector
+
+hints:
+  DockerRequirement:
+    dockerPull: tammojan/lofar-pipeline
+
+baseCommand:
+  - H5parm_collector.py
+inputs:
+  - id: h5parmFiles
+    type: File[]
+    doc: List of h5parm files
+    inputBinding:
+      position: 0
+  - id: insolset
+    type: string?
+    default: sol000
+    doc: Input solset name
+    inputBinding:
+      prefix: --insolset
+  - id: outh5parmname
+    type: string
+    doc: Output h5parm name
+    default: output.h5
+
+outputs:
+  - id: outh5parm
+    doc: Output h5parm
+    type: File
+    outputBinding:
+      glob: $(inputs.outh5parmname)
+label: H5parm_collector
diff --git a/test_data/example.h5.REMOVED.git-id b/test_data/example.h5.REMOVED.git-id
new file mode 100644
index 00000000..ee55446f
--- /dev/null
+++ b/test_data/example.h5.REMOVED.git-id
@@ -0,0 +1 @@
+554933b577a0dcf1b2aa3fa91c7de5b2477fd724
\ No newline at end of file
diff --git a/test_jobs/h5parm_collector.json b/test_jobs/h5parm_collector.json
new file mode 100644
index 00000000..958493f2
--- /dev/null
+++ b/test_jobs/h5parm_collector.json
@@ -0,0 +1,8 @@
+{
+   "h5parmFiles": [
+   {
+            "class": "File",
+            "path": "/data/example.h5"
+   }
+   ]
+}
-- 
GitLab