From 0fc3e173fbc098065576daf332921132e2a78afd Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Thu, 18 Apr 2024 16:59:13 -0400 Subject: [PATCH 01/47] Update validation.yml --- .github/workflows/validation.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 955a41e..f198be8 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -1,9 +1,6 @@ name: Validate Submission(s) on: pull_request_target: - branches: - - main - - equity paths: - data-processed/** jobs: From c2f17758b8568859f79a59198bb30e9b9ad973c2 Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Thu, 18 Apr 2024 17:01:46 -0400 Subject: [PATCH 02/47] Update validation.yml --- .github/workflows/validation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index f198be8..4a8089f 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -2,7 +2,7 @@ name: Validate Submission(s) on: pull_request_target: paths: - - data-processed/** + - 'data-processed/**' jobs: validates-files: runs-on: ubuntu-20.04 From da2b921b9952113d6e1c21df2913a94c563a6ec3 Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Fri, 19 Apr 2024 10:52:21 -0400 Subject: [PATCH 03/47] Update validation.yml --- .github/workflows/validation.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 4a8089f..69d797e 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -1,8 +1,10 @@ name: Validate Submission(s) on: pull_request_target: + branches: + - main paths: - - 'data-processed/**' + - 'data-processed/**.parquet' jobs: validates-files: runs-on: ubuntu-20.04 From 65b2910a88e23fd6ec3dece9fc3e45ab0862295c Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Fri, 19 Apr 2024 14:06:19 -0400 Subject: [PATCH 04/47] Update validation.yml --- .github/workflows/validation.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 69d797e..19e3ff5 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -3,13 +3,20 @@ on: pull_request_target: branches: - main - paths: - - 'data-processed/**.parquet' + jobs: validates-files: runs-on: ubuntu-20.04 steps: + - name: verify change in data-processed folder + run: | + if [ -n "$( git show --pretty="" --name-only -- data-processed/)" ]; then + echo "Commit includes change in the data-processed folder"; + else + ${{ cancelled() }} + fi + - name: Checkout repository uses: actions/checkout@v3 with: From 5bfaa4f94081ba99ccd01198b343069f05c292e5 Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Fri, 19 Apr 2024 14:17:05 -0400 Subject: [PATCH 05/47] Update validation.yml --- .github/workflows/validation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 19e3ff5..3457f8a 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -14,7 +14,7 @@ jobs: if [ -n "$( git show --pretty="" --name-only -- data-processed/)" ]; then echo "Commit includes change in the data-processed folder"; else - ${{ cancelled() }} + exit 1 fi - name: Checkout repository From 774f954141c3e5f77d7db530124fcab674ab4fe6 Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Fri, 19 Apr 2024 14:18:43 -0400 Subject: [PATCH 06/47] Update validation.yml --- .github/workflows/validation.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 3457f8a..842cfcc 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -9,6 +9,12 @@ jobs: runs-on: ubuntu-20.04 steps: + + - name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 1 + - name: verify change in data-processed folder run: | if [ -n "$( git show --pretty="" --name-only -- data-processed/)" ]; then @@ -16,11 +22,6 @@ jobs: else exit 1 fi - - - name: Checkout repository - uses: actions/checkout@v3 - with: - fetch-depth: 1 - name: Setup R uses: r-lib/actions/setup-r@v2 From 40d51025510d2f29f3efac23c67a2fd53bd74157 Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Fri, 19 Apr 2024 14:21:39 -0400 Subject: [PATCH 07/47] Update validation.yml --- .github/workflows/validation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 842cfcc..4b32445 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -17,7 +17,7 @@ jobs: - name: verify change in data-processed folder run: | - if [ -n "$( git show --pretty="" --name-only -- data-processed/)" ]; then + if [ -n "$( git show --pretty="" --name-only -- data-processed/ ${{GITHUB_SHA::6}})" ]; then echo "Commit includes change in the data-processed folder"; else exit 1 From 2583bb16eded6df5fd4f77fe7c29e917bfbec3d2 Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Fri, 19 Apr 2024 14:24:38 -0400 Subject: [PATCH 08/47] Update validation.yml --- .github/workflows/validation.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 4b32445..5232e24 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -17,7 +17,10 @@ jobs: - name: verify change in data-processed folder run: | - if [ -n "$( git show --pretty="" --name-only -- data-processed/ ${{GITHUB_SHA::6}})" ]; then + echo "${{ env.branch }}" + echo "git_hash=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_HASH + echo "${{ env.hash }}" + if [ -n "$( git show --pretty="" --name-only -- data-processed/" ]; then echo "Commit includes change in the data-processed folder"; else exit 1 From 9642a9f344cef428eb52b66b281d17c4a4cb6efa Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Fri, 19 Apr 2024 14:27:12 -0400 Subject: [PATCH 09/47] Update validation.yml --- .github/workflows/validation.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 5232e24..5cb2bed 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -18,7 +18,6 @@ jobs: - name: verify change in data-processed folder run: | echo "${{ env.branch }}" - echo "git_hash=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_HASH echo "${{ env.hash }}" if [ -n "$( git show --pretty="" --name-only -- data-processed/" ]; then echo "Commit includes change in the data-processed folder"; From e223afeead269d9cfbdbe80f85f2944bb72a2a6d Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Fri, 19 Apr 2024 14:33:36 -0400 Subject: [PATCH 10/47] Update validation.yml --- .github/workflows/validation.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 5cb2bed..64df374 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -15,12 +15,18 @@ jobs: with: fetch-depth: 1 + - name: Show GitHub context + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + run: echo "$GITHUB_CONTEXT" + - name: verify change in data-processed folder run: | echo "${{ env.branch }}" echo "${{ env.hash }}" if [ -n "$( git show --pretty="" --name-only -- data-processed/" ]; then echo "Commit includes change in the data-processed folder"; + exit 1 else exit 1 fi From 1fe0fe8f997be3c8e6af7f6b8036479d0530a3cb Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Fri, 19 Apr 2024 14:51:29 -0400 Subject: [PATCH 11/47] Update validation.yml --- .github/workflows/validation.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 64df374..661469c 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -15,16 +15,9 @@ jobs: with: fetch-depth: 1 - - name: Show GitHub context - env: - GITHUB_CONTEXT: ${{ toJson(github) }} - run: echo "$GITHUB_CONTEXT" - - name: verify change in data-processed folder run: | - echo "${{ env.branch }}" - echo "${{ env.hash }}" - if [ -n "$( git show --pretty="" --name-only -- data-processed/" ]; then + if [ -n "$( git show --pretty="" --name-only -- data-processed/" ${{ github.sha }}]; then echo "Commit includes change in the data-processed folder"; exit 1 else From 8e456e550cfe70be5452175c25a88df2aefd769f Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Fri, 19 Apr 2024 14:55:35 -0400 Subject: [PATCH 12/47] Update validation.yml --- .github/workflows/validation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 661469c..cb57021 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -19,8 +19,8 @@ jobs: run: | if [ -n "$( git show --pretty="" --name-only -- data-processed/" ${{ github.sha }}]; then echo "Commit includes change in the data-processed folder"; - exit 1 else + echo "No change in the data-processed folder" exit 1 fi From 7f1c728b319ddf0fe11c41828d3a4a912e51f2fa Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Fri, 19 Apr 2024 14:58:14 -0400 Subject: [PATCH 13/47] Update validation.yml --- .github/workflows/validation.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index cb57021..862236f 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -20,8 +20,7 @@ jobs: if [ -n "$( git show --pretty="" --name-only -- data-processed/" ${{ github.sha }}]; then echo "Commit includes change in the data-processed folder"; else - echo "No change in the data-processed folder" - exit 1 + echo "No change in the data-processed folder"; fi - name: Setup R From e9598efc69443c2bc26b9058c9f9b0e6c445de92 Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Fri, 19 Apr 2024 15:00:50 -0400 Subject: [PATCH 14/47] Update validation.yml --- .github/workflows/validation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 862236f..5e6b925 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -17,7 +17,7 @@ jobs: - name: verify change in data-processed folder run: | - if [ -n "$( git show --pretty="" --name-only -- data-processed/" ${{ github.sha }}]; then + if [ -n "$( git show --pretty="" --name-only -- data-processed/ ${{ github.sha }}"]; then echo "Commit includes change in the data-processed folder"; else echo "No change in the data-processed folder"; From 56cdcbb3b8048f4a3fe1b6aff8d518821242776e Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Fri, 19 Apr 2024 15:01:58 -0400 Subject: [PATCH 15/47] Update validation.yml --- .github/workflows/validation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 5e6b925..964f4ad 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -17,7 +17,7 @@ jobs: - name: verify change in data-processed folder run: | - if [ -n "$( git show --pretty="" --name-only -- data-processed/ ${{ github.sha }}"]; then + if [ -n "$( git show --pretty="" --name-only -- data-processed/ ${{ github.sha }})"]; then echo "Commit includes change in the data-processed folder"; else echo "No change in the data-processed folder"; From aaaa6a5945ea1f66e575bea30c58807ae48d3e08 Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Fri, 19 Apr 2024 15:07:59 -0400 Subject: [PATCH 16/47] Update validation.yml --- .github/workflows/validation.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 964f4ad..275faf0 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -21,6 +21,7 @@ jobs: echo "Commit includes change in the data-processed folder"; else echo "No change in the data-processed folder"; + exit 1 fi - name: Setup R From 0e68979dbdf411fb0ef676c64b6d45aad93bb9c1 Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Fri, 19 Apr 2024 15:10:50 -0400 Subject: [PATCH 17/47] Update validation.yml --- .github/workflows/validation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 275faf0..efcf80a 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -21,7 +21,7 @@ jobs: echo "Commit includes change in the data-processed folder"; else echo "No change in the data-processed folder"; - exit 1 + exit 0 fi - name: Setup R From 2bf8f8fd79948ae1270f2666e3be3d4d4b1ced66 Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Fri, 19 Apr 2024 15:25:26 -0400 Subject: [PATCH 18/47] Update validation.yml --- .github/workflows/validation.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index efcf80a..21eb26f 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -16,31 +16,35 @@ jobs: fetch-depth: 1 - name: verify change in data-processed folder + id: change-check run: | if [ -n "$( git show --pretty="" --name-only -- data-processed/ ${{ github.sha }})"]; then echo "Commit includes change in the data-processed folder"; else echo "No change in the data-processed folder"; - exit 0 + echo "skipnext=true" >> $GITHUB_OUTPUT fi - name: Setup R + if: ( steps.change-check.outputs.skipnext != 'true' ) uses: r-lib/actions/setup-r@v2 - name: Install system dependencies + if: ( steps.change-check.outputs.skipnext != 'true' ) run: sudo apt-get install libcurl4-openssl-dev libudunits2-dev libgdal-dev - name: Cache R packages id: cache - if: runner.os != 'Windows' + if: ( steps.change-check.outputs.skipnext != 'true' ) uses: actions/cache@v2 with: path: ${{ env.R_LIBS_USER }} key: ${{ runner.os }}-${{ hashFiles('.github/requirements.txt') }}-1 - name: Install dependencies - if: steps.cache.outputs.cache-hit != 'true' + if: | + steps.cache.outputs.cache-hit != 'true' && steps.change-check.outputs.skipnext != 'true' run: | R -e 'Sys.setenv("NOT_CRAN" = TRUE) install.packages(c("arrow", "gh", "remotes")) @@ -51,6 +55,7 @@ jobs: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - name: Run Validation + if : ( steps.change-check.outputs.skipnext != 'true' ) run: | Rscript code/validation.R env: From 78d92ad95ebba8d9d01cf5d70faaa1a84c989fcd Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Fri, 19 Apr 2024 15:31:02 -0400 Subject: [PATCH 19/47] Update validation.yml --- .github/workflows/validation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 21eb26f..d05821e 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -18,7 +18,7 @@ jobs: - name: verify change in data-processed folder id: change-check run: | - if [ -n "$( git show --pretty="" --name-only -- data-processed/ ${{ github.sha }})"]; then + if [ -n "$( git show --pretty="" --name-only -- data-processed/ ${{ github.sha }})" ]; then echo "Commit includes change in the data-processed folder"; else echo "No change in the data-processed folder"; From 064066f2165dc442defa13fcf9b489e745965b47 Mon Sep 17 00:00:00 2001 From: LucieContamin Date: Fri, 19 Apr 2024 15:45:49 -0400 Subject: [PATCH 20/47] add validation on open PR --- .github/workflows/validation_open.yml | 54 +++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/validation_open.yml diff --git a/.github/workflows/validation_open.yml b/.github/workflows/validation_open.yml new file mode 100644 index 0000000..3526fff --- /dev/null +++ b/.github/workflows/validation_open.yml @@ -0,0 +1,54 @@ +name: Validate Submission - Open PR +on: + pull_request_target: + types: [opened, reopened] + branches: + - main + +jobs: + validates-files: + runs-on: ubuntu-20.04 + + steps: + + - name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 1 + + - name: Setup R + if: ( steps.change-check.outputs.skipnext != 'true' ) + uses: r-lib/actions/setup-r@v2 + + - name: Install system dependencies + if: ( steps.change-check.outputs.skipnext != 'true' ) + run: sudo apt-get install libcurl4-openssl-dev libudunits2-dev libgdal-dev + + + - name: Cache R packages + id: cache + if: ( steps.change-check.outputs.skipnext != 'true' ) + uses: actions/cache@v2 + with: + path: ${{ env.R_LIBS_USER }} + key: ${{ runner.os }}-${{ hashFiles('.github/requirements.txt') }}-1 + + - name: Install dependencies + if: | + steps.cache.outputs.cache-hit != 'true' && steps.change-check.outputs.skipnext != 'true' + run: | + R -e 'Sys.setenv("NOT_CRAN" = TRUE) + install.packages(c("arrow", "gh", "remotes")) + Sys.unsetenv("NOT_CRAN") + remotes::install_url("https://github.com/midas-network/SMHvalidation/archive/refs/heads/version.zip") + remotes::install_url("https://github.com/Infectious-Disease-Modeling-Hubs/hubUtils/archive/refs/heads/main.zip")' + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + - name: Run Validation + if : ( steps.change-check.outputs.skipnext != 'true' ) + run: | + Rscript code/validation.R + env: + GH_PR_NUMBER: ${{ github.event.pull_request.number }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 55ed0aa6d3af04d332f63ee1f4601e291f93dafa Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Fri, 19 Apr 2024 15:47:56 -0400 Subject: [PATCH 21/47] Update validation.yml --- .github/workflows/validation.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index d05821e..fae3548 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -1,6 +1,7 @@ name: Validate Submission(s) on: pull_request_target: + types: [edited, synchronized] branches: - main From 71d803f2c58ca8021fce69516f3baaaabb19a1cb Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Fri, 19 Apr 2024 15:50:08 -0400 Subject: [PATCH 22/47] Update validation.yml --- .github/workflows/validation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index fae3548..782df10 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -1,7 +1,7 @@ name: Validate Submission(s) on: pull_request_target: - types: [edited, synchronized] + types: [edited, synchronize] branches: - main From 75ae44ed773c0fb314bfc28a4c43a802c8d1e393 Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Fri, 19 Apr 2024 15:50:26 -0400 Subject: [PATCH 23/47] Update validation.yml --- .github/workflows/validation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 782df10..c516dae 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -1,7 +1,7 @@ name: Validate Submission(s) on: pull_request_target: - types: [edited, synchronize] + types: [synchronize] branches: - main From 1dd42ebb15635b76977bbe860308fbdf774368a7 Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Fri, 19 Apr 2024 15:51:29 -0400 Subject: [PATCH 24/47] Update validation_open.yml --- .github/workflows/validation_open.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/validation_open.yml b/.github/workflows/validation_open.yml index 3526fff..32e2c7a 100644 --- a/.github/workflows/validation_open.yml +++ b/.github/workflows/validation_open.yml @@ -17,25 +17,21 @@ jobs: fetch-depth: 1 - name: Setup R - if: ( steps.change-check.outputs.skipnext != 'true' ) uses: r-lib/actions/setup-r@v2 - name: Install system dependencies - if: ( steps.change-check.outputs.skipnext != 'true' ) run: sudo apt-get install libcurl4-openssl-dev libudunits2-dev libgdal-dev - name: Cache R packages id: cache - if: ( steps.change-check.outputs.skipnext != 'true' ) uses: actions/cache@v2 with: path: ${{ env.R_LIBS_USER }} key: ${{ runner.os }}-${{ hashFiles('.github/requirements.txt') }}-1 - name: Install dependencies - if: | - steps.cache.outputs.cache-hit != 'true' && steps.change-check.outputs.skipnext != 'true' + if: ( steps.cache.outputs.cache-hit != 'true' ) run: | R -e 'Sys.setenv("NOT_CRAN" = TRUE) install.packages(c("arrow", "gh", "remotes")) @@ -46,7 +42,6 @@ jobs: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - name: Run Validation - if : ( steps.change-check.outputs.skipnext != 'true' ) run: | Rscript code/validation.R env: From 32be2ff9951e31c9e57b18e2227d71a71db7df16 Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Fri, 19 Apr 2024 16:07:50 -0400 Subject: [PATCH 25/47] Update validation.yml --- .github/workflows/validation.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index c516dae..304a927 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -19,7 +19,9 @@ jobs: - name: verify change in data-processed folder id: change-check run: | - if [ -n "$( git show --pretty="" --name-only -- data-processed/ ${{ github.sha }})" ]; then + check=${git show --pretty="" --name-only -- data-processed/ ${{ github.sha }}} + echo $check + if [ $check -ge 1 ]; then echo "Commit includes change in the data-processed folder"; else echo "No change in the data-processed folder"; From 078def6f54dcd9cad06aa7256837b7a1f9774f18 Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Fri, 19 Apr 2024 16:15:56 -0400 Subject: [PATCH 26/47] Update validation.yml --- .github/workflows/validation.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 304a927..6a9fb31 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -19,9 +19,9 @@ jobs: - name: verify change in data-processed folder id: change-check run: | - check=${git show --pretty="" --name-only -- data-processed/ ${{ github.sha }}} + check=$(git show --pretty="" --name-only -- data-processed/ ${{ github.sha }}) echo $check - if [ $check -ge 1 ]; then + if [[ ${#check} -ge 1 ]]; then echo "Commit includes change in the data-processed folder"; else echo "No change in the data-processed folder"; From 0bec0fa63c1346d83c25d9aaeef66fed2a0021ce Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Fri, 19 Apr 2024 16:32:07 -0400 Subject: [PATCH 27/47] Update validation.yml --- .github/workflows/validation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 6a9fb31..bbc4eff 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -19,7 +19,7 @@ jobs: - name: verify change in data-processed folder id: change-check run: | - check=$(git show --pretty="" --name-only -- data-processed/ ${{ github.sha }}) + check=$(git show --pretty="" --name-only -- data-processed/ ${{ github.event.pull_request.head.sha }}) echo $check if [[ ${#check} -ge 1 ]]; then echo "Commit includes change in the data-processed folder"; From 16d06caf657c2b1c1cd9d43263c992ce0a80d794 Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Fri, 19 Apr 2024 16:39:10 -0400 Subject: [PATCH 28/47] Update validation.yml --- .github/workflows/validation.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index bbc4eff..a60caa0 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -4,6 +4,8 @@ on: types: [synchronize] branches: - main + paths: + - 'data-processed/**.parquet' jobs: validates-files: From d55031a3cab0fb57ae5e2905335743137b579797 Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Fri, 19 Apr 2024 16:49:37 -0400 Subject: [PATCH 29/47] Update validation.yml --- .github/workflows/validation.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index a60caa0..e8314b9 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -66,3 +66,4 @@ jobs: env: GH_PR_NUMBER: ${{ github.event.pull_request.number }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_COMMIT_SHA: ${{ github.event.pull_request.head.sha }} From 4b8b1fab26d8acfba15967546bc35aee822acf1e Mon Sep 17 00:00:00 2001 From: LucieContamin Date: Fri, 19 Apr 2024 16:50:55 -0400 Subject: [PATCH 30/47] update validation --- code/validation.R | 215 ++++++++++++++++++++++++---------------------- 1 file changed, 114 insertions(+), 101 deletions(-) diff --git a/code/validation.R b/code/validation.R index baf18e0..a2e4b64 100644 --- a/code/validation.R +++ b/code/validation.R @@ -2,117 +2,130 @@ library(SMHvalidation) library(gh) library(dplyr) -# check if submissions file -pr_files <- gh::gh(paste0("GET /repos/", - "midas-network/example_round-scenariohub/pulls/", - Sys.getenv("GH_PR_NUMBER"), "/files")) - -pr_files_name <- purrr::map(pr_files, "filename") -pr_files_name <- pr_files_name[!"removed" == purrr::map(pr_files, "status")] -pr_sub_files <- - stringr::str_extract(pr_files_name, - "data-processed/.+/\\d{4}-\\d{2}-\\d{2}(-.*)?") -pr_sub_files <- unique(na.omit(pr_sub_files)) -pr_sub_files <- grep("(A|a)bstract", pr_sub_files, value = TRUE, invert = TRUE) -if (any(grepl(".pqt$|.parquet$", pr_sub_files))) { - partition = NULL +# Check if validation need to run +test <- gh::gh(paste0("GET /repos/", + "midas-network/example_round-scenariohub/commits/", + Sys.getenv("GH_COMMIT_SHA"))) +print(unique(unlist(purrr::map(test$files, "filename")))) +check <- grepl("data-processed/", unique(unlist(purrr::map(test$files, + "filename")))) +if (isFALSE(check)) { + test_tot <- + list(list(valid = paste0("No projection submission file in the standard ", + "SMH file format found in the Pull-Request. No ", + "validation was run."))) } else { - partition = c("origin_date", "target") -} -pop_path <- "data-locations/locations.csv" -js_def_file <- "hub-config/tasks.json" -lst_gs <- NULL + # check if submissions file + pr_files <- gh::gh(paste0("GET /repos/", + "midas-network/example_round-scenariohub/pulls/", + Sys.getenv("GH_PR_NUMBER"), "/files")) -# Run validation on file corresponding to the submission file format -if (length(pr_sub_files) > 0) { - team_name <- unique(basename(dirname(pr_sub_files))) - sub_file_date <- unique(stringr::str_extract(basename(pr_sub_files), - "\\d{4}-\\d{2}-\\d{2}")) - if (!(dir.exists(paste0(getwd(), "/proj_plot")))) - dir.create(paste0(getwd(), "/proj_plot")) - if (is.null(partition)) { - group_files <- paste0(sub_file_date, "-", team_name) + pr_files_name <- purrr::map(pr_files, "filename") + pr_files_name <- pr_files_name[!"removed" == purrr::map(pr_files, "status")] + pr_sub_files <- + stringr::str_extract(pr_files_name, + "data-processed/.+/\\d{4}-\\d{2}-\\d{2}(-.*)?") + pr_sub_files <- unique(na.omit(pr_sub_files)) + pr_sub_files <- grep("(A|a)bstract", pr_sub_files, value = TRUE, invert = TRUE) + if (all(grepl(".pqt$|.parquet$", pr_sub_files))) { + partition = NULL } else { - group_files <- sub_file_date + partition = c("origin_date", "target") } - test_tot <- lapply(group_files, function(y) { - # select submission files - pr_sub_files_group <- grep(y, pr_sub_files, value = TRUE) + pop_path <- "data-locations/locations.csv" + js_def_file <- "hub-config/tasks.json" + lst_gs <- NULL - pr_sub_files_lst <- pr_files[grepl(pr_sub_files_group, - purrr::map(pr_files, "filename"))] - pr_sub_files_lst <- - pr_sub_files_lst[!grepl("(A|a)bstract", - purrr::map(pr_sub_files_lst, "filename"))] - # run validation on all files - test_tot <- lapply(seq_len(length(pr_sub_files_lst)), function(x) { - # submission file download - if (is.null(partition)) { - url_link <- URLdecode(pr_sub_files_lst[[x]]$raw_url) - download.file(url_link, basename(url_link)) - } else { - file_part <- paste0(getwd(), "/part_sub/", - pr_sub_files_lst[[x]]$filename) - if (!(dir.exists(dirname(file_part)))) - dir.create(dirname(file_part), recursive = TRUE) - url_link <- pr_sub_files_lst[[x]]$raw_url - download.file(url_link, file_part) - } - }) - gc() - # run validation - if (sub_file_date > "2024-01-01") { - merge_col <- TRUE - } else { - merge_col <- FALSE - } + # Run validation on file corresponding to the submission file format + if (length(pr_sub_files) > 0) { + team_name <- unique(basename(dirname(pr_sub_files))) + sub_file_date <- unique(stringr::str_extract(basename(pr_sub_files), + "\\d{4}-\\d{2}-\\d{2}")) + if (!(dir.exists(paste0(getwd(), "/proj_plot")))) + dir.create(paste0(getwd(), "/proj_plot")) if (is.null(partition)) { - val_path <- basename(pr_sub_files_group) - round_id <- NULL + group_files <- paste0(sub_file_date, "-", team_name) } else { - val_path <- paste0(getwd(), "/part_sub/", dirname(pr_sub_files_group)) - round_id <- sub_file_date + group_files <- sub_file_date } - arg_list <- list(path = val_path, js_def = js_def_file, lst_gs = lst_gs, - pop_path = pop_path, merge_sample_col = merge_col, - partition = partition, round_id = round_id) - test <- capture.output(try(do.call(SMHvalidation::validate_submission, - arg_list))) - gc() - if (length(grep("Run validation on fil", test, invert = TRUE)) == 0) { - test <- try(do.call(SMHvalidation::validate_submission, arg_list)) - test <- test[1] + test_tot <- lapply(group_files, function(y) { + # select submission files + pr_sub_files_group <- grep(y, pr_sub_files, value = TRUE) + pr_sub_files_lst <- pr_files[grepl(pr_sub_files_group, + purrr::map(pr_files, "filename"))] + pr_sub_files_lst <- + pr_sub_files_lst[!grepl("(A|a)bstract", + purrr::map(pr_sub_files_lst, "filename"))] + # run validation on all files + test_tot <- lapply(seq_len(length(pr_sub_files_lst)), function(x) { + # submission file download + if (is.null(partition)) { + url_link <- URLdecode(pr_sub_files_lst[[x]]$raw_url) + download.file(url_link, basename(url_link)) + } else { + file_part <- paste0(getwd(), "/part_sub/", + pr_sub_files_lst[[x]]$filename) + if (!(dir.exists(dirname(file_part)))) + dir.create(dirname(file_part), recursive = TRUE) + url_link <- pr_sub_files_lst[[x]]$raw_url + download.file(url_link, file_part) + } + }) gc() - } - # Visualization - df <- try({ - arrow::open_dataset(val_path, partitioning = partition) %>% - dplyr::filter(output_type == "quantile") %>% - dplyr::collect() + # run validation + if (sub_file_date > "2024-01-01") { + merge_col <- TRUE + } else { + merge_col <- FALSE + } + if (is.null(partition)) { + val_path <- basename(pr_sub_files_group) + round_id <- NULL + } else { + val_path <- paste0(getwd(), "/part_sub/", dirname(pr_sub_files_group)) + round_id <- sub_file_date + } + arg_list <- list(path = val_path, js_def = js_def_file, lst_gs = lst_gs, + pop_path = pop_path, merge_sample_col = merge_col, + partition = partition, round_id = round_id) + test <- capture.output(try(do.call(SMHvalidation::validate_submission, + arg_list))) + gc() + if (length(grep("Run validation on fil", test, invert = TRUE)) == 0) { + test <- try(do.call(SMHvalidation::validate_submission, arg_list)) + test <- test[1] + gc() + } + # Visualization + df <- try({ + arrow::open_dataset(val_path, partitioning = partition) %>% + dplyr::filter(output_type == "quantile") %>% + dplyr::collect() + }) + gc() + # print(head(df)) + if (all(class(df) != "try-error") && nrow(df) > 0) { + test_viz <- try(generate_validation_plots( + path_proj = val_path, lst_gs = NULL, + save_path = paste0(getwd(), "/proj_plot"), y_sqrt = FALSE, + plot_quantiles = c(0.025, 0.975), partition = partition)) + } else { + test_viz <- NA + } + gc() + if (class(test_viz) == "try-error") + file.remove(dir(paste0(getwd(), "/proj_plot"), full.names = TRUE)) + # list of the viz and validation results + test_tot <- list(valid = test, viz = test_viz) + # returns all output + return(test_tot) }) - gc() - # print(head(df)) - if (all(class(df) != "try-error") && nrow(df) > 0) { - test_viz <- try(generate_validation_plots( - path_proj = val_path, lst_gs = NULL, - save_path = paste0(getwd(), "/proj_plot"), y_sqrt = FALSE, - plot_quantiles = c(0.025, 0.975), partition = partition)) - } else { - test_viz <- NA - } - gc() - if (class(test_viz) == "try-error") - file.remove(dir(paste0(getwd(), "/proj_plot"), full.names = TRUE)) - # list of the viz and validation results - test_tot <- list(valid = test, viz = test_viz) - # returns all output - return(test_tot) - }) -} else { - test_tot <- - list(list(valid = paste0("No projection submission file in the standard ", - "SMH file format found in the Pull-Request. No ", - "validation was run."))) + } else { + test_tot <- + list(list(valid = paste0("No projection submission file in the standard ", + "SMH file format found in the Pull-Request. No ", + "validation was run."))) + } } # Post validation results as comment on the open PR From 7af752660d11dba462d5f67867460d275b33c0c3 Mon Sep 17 00:00:00 2001 From: LucieContamin Date: Fri, 19 Apr 2024 16:57:22 -0400 Subject: [PATCH 31/47] fix validation check --- code/validation.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/validation.R b/code/validation.R index a2e4b64..0a0e005 100644 --- a/code/validation.R +++ b/code/validation.R @@ -9,7 +9,7 @@ test <- gh::gh(paste0("GET /repos/", print(unique(unlist(purrr::map(test$files, "filename")))) check <- grepl("data-processed/", unique(unlist(purrr::map(test$files, "filename")))) -if (isFALSE(check)) { +if (isFALSE(all(check))) { test_tot <- list(list(valid = paste0("No projection submission file in the standard ", "SMH file format found in the Pull-Request. No ", From 9372f61e6cfc1643b096d846f40903a8a09542b7 Mon Sep 17 00:00:00 2001 From: LucieContamin Date: Fri, 19 Apr 2024 17:01:12 -0400 Subject: [PATCH 32/47] make validation less verbose --- code/validation.R | 79 +++++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 40 deletions(-) diff --git a/code/validation.R b/code/validation.R index 0a0e005..c9f4f91 100644 --- a/code/validation.R +++ b/code/validation.R @@ -10,10 +10,7 @@ print(unique(unlist(purrr::map(test$files, "filename")))) check <- grepl("data-processed/", unique(unlist(purrr::map(test$files, "filename")))) if (isFALSE(all(check))) { - test_tot <- - list(list(valid = paste0("No projection submission file in the standard ", - "SMH file format found in the Pull-Request. No ", - "validation was run."))) + test_tot <- NA } else { # check if submissions file pr_files <- gh::gh(paste0("GET /repos/", @@ -128,46 +125,48 @@ if (isFALSE(all(check))) { } } -# Post validation results as comment on the open PR -test_valid <- purrr::map(test_tot, "valid") -message <- purrr::map(test_valid, paste, collapse = "\n") +if (!all(is.na(test_tot))) { + # Post validation results as comment on the open PR + test_valid <- purrr::map(test_tot, "valid") + message <- purrr::map(test_valid, paste, collapse = "\n") -lapply(seq_len(length(message)), function(x) { - gh::gh(paste0("POST /repos/", "midas-network/megaround-scenariohub/", - "issues/", Sys.getenv("GH_PR_NUMBER"), "/comments"), - body = message[[x]], - .token = Sys.getenv("GH_TOKEN")) -}) + lapply(seq_len(length(message)), function(x) { + gh::gh(paste0("POST /repos/", "midas-network/megaround-scenariohub/", + "issues/", Sys.getenv("GH_PR_NUMBER"), "/comments"), + body = message[[x]], + .token = Sys.getenv("GH_TOKEN")) + }) -# Post visualization results as comment on the open PR -test_viz <- purrr::map(test_tot, "viz") -if (any(!is.na(test_viz))) { - message_plot <- paste0( - "If the submission contains projection file(s) with quantile projection, ", - "a pdf containing visualization plots of the submission is available and ", - "downloadable in the GitHub actions. Please click on 'details' on the ", - "right of the 'Validate submission' checks. The pdf is available in a ZIP ", - "file as an artifact of the GH Actions. For more information, please see ", - "[here](https://docs.github.com/en/actions/managing-workflow-runs/downloading-workflow-artifacts)") + # Post visualization results as comment on the open PR + test_viz <- purrr::map(test_tot, "viz") + if (any(!is.na(test_viz))) { + message_plot <- paste0( + "If the submission contains projection file(s) with quantile projection, ", + "a pdf containing visualization plots of the submission is available and ", + "downloadable in the GitHub actions. Please click on 'details' on the ", + "right of the 'Validate submission' checks. The pdf is available in a ZIP ", + "file as an artifact of the GH Actions. For more information, please see ", + "[here](https://docs.github.com/en/actions/managing-workflow-runs/downloading-workflow-artifacts)") - if (any(unlist(purrr::map(test_viz, class)) == "try-error")) { - message_plot <- capture.output( - cat(message_plot, "\n\n\U000274c Error: ", - "The visualization encounters an issue and might not be available,", - " if the validation does not return any error, please feel free to ", - "tag `@LucieContamin` for any question.")) - } + if (any(unlist(purrr::map(test_viz, class)) == "try-error")) { + message_plot <- capture.output( + cat(message_plot, "\n\n\U000274c Error: ", + "The visualization encounters an issue and might not be available,", + " if the validation does not return any error, please feel free to ", + "tag `@LucieContamin` for any question.")) + } - gh::gh(paste0("POST /repos/", "midas-network/example_round-scenariohub/", - "issues/", Sys.getenv("GH_PR_NUMBER"),"/comments"), - body = message_plot, - .token = Sys.getenv("GH_TOKEN")) -} + gh::gh(paste0("POST /repos/", "midas-network/example_round-scenariohub/", + "issues/", Sys.getenv("GH_PR_NUMBER"),"/comments"), + body = message_plot, + .token = Sys.getenv("GH_TOKEN")) + } -# Validate or stop the github actions -if (any(grepl("(\U000274c )?Error", test_valid))) { - stop("The submission contains one or multiple issues") -} else if (any(grepl("Warning", test_valid))) { - warning(" The submission is accepted but contains some warnings") + # Validate or stop the github actions + if (any(grepl("(\U000274c )?Error", test_valid))) { + stop("The submission contains one or multiple issues") + } else if (any(grepl("Warning", test_valid))) { + warning(" The submission is accepted but contains some warnings") + } } From b1eaca13d52799f57d410f2e7f0d643c08ac572c Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Fri, 19 Apr 2024 17:08:48 -0400 Subject: [PATCH 33/47] Update validation.yml --- .github/workflows/validation.yml | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index e8314b9..4952c3e 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -12,44 +12,28 @@ jobs: runs-on: ubuntu-20.04 steps: - - name: Checkout repository uses: actions/checkout@v3 with: fetch-depth: 1 - - name: verify change in data-processed folder - id: change-check - run: | - check=$(git show --pretty="" --name-only -- data-processed/ ${{ github.event.pull_request.head.sha }}) - echo $check - if [[ ${#check} -ge 1 ]]; then - echo "Commit includes change in the data-processed folder"; - else - echo "No change in the data-processed folder"; - echo "skipnext=true" >> $GITHUB_OUTPUT - fi - - name: Setup R if: ( steps.change-check.outputs.skipnext != 'true' ) uses: r-lib/actions/setup-r@v2 - name: Install system dependencies - if: ( steps.change-check.outputs.skipnext != 'true' ) run: sudo apt-get install libcurl4-openssl-dev libudunits2-dev libgdal-dev - name: Cache R packages id: cache - if: ( steps.change-check.outputs.skipnext != 'true' ) uses: actions/cache@v2 with: path: ${{ env.R_LIBS_USER }} key: ${{ runner.os }}-${{ hashFiles('.github/requirements.txt') }}-1 - name: Install dependencies - if: | - steps.cache.outputs.cache-hit != 'true' && steps.change-check.outputs.skipnext != 'true' + if: ( steps.change-check.outputs.skipnext != 'true' ) run: | R -e 'Sys.setenv("NOT_CRAN" = TRUE) install.packages(c("arrow", "gh", "remotes")) @@ -60,7 +44,6 @@ jobs: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - name: Run Validation - if : ( steps.change-check.outputs.skipnext != 'true' ) run: | Rscript code/validation.R env: From 7c4bff67760ee4edf1db5da66bbc0b5f7ef380bf Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Fri, 19 Apr 2024 17:15:56 -0400 Subject: [PATCH 34/47] Update validation.yml --- .github/workflows/validation.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 4952c3e..54b0183 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -45,6 +45,8 @@ jobs: - name: Run Validation run: | + check=$( ${{ github.event.pull_request.event.action }}) + echo $check Rscript code/validation.R env: GH_PR_NUMBER: ${{ github.event.pull_request.number }} From 117648ff618c286e05907df79eff4ff5c3c6d1e0 Mon Sep 17 00:00:00 2001 From: LucieContamin Date: Fri, 19 Apr 2024 17:16:08 -0400 Subject: [PATCH 35/47] update validation for open PR --- code/validation.R | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/code/validation.R b/code/validation.R index c9f4f91..f5ea039 100644 --- a/code/validation.R +++ b/code/validation.R @@ -3,14 +3,19 @@ library(gh) library(dplyr) # Check if validation need to run -test <- gh::gh(paste0("GET /repos/", - "midas-network/example_round-scenariohub/commits/", - Sys.getenv("GH_COMMIT_SHA"))) -print(unique(unlist(purrr::map(test$files, "filename")))) -check <- grepl("data-processed/", unique(unlist(purrr::map(test$files, - "filename")))) +if (length(Sys.getenv("GH_COMMIT_SHA")) > 1) { + test <- gh::gh(paste0("GET /repos/", + "midas-network/example_round-scenariohub/commits/", + Sys.getenv("GH_COMMIT_SHA"))) + check <- grepl("data-processed/", unique(unlist(purrr::map(test$files, + "filename")))) +} else { + check <- TRUE +} + if (isFALSE(all(check))) { test_tot <- NA + print("no update in data-processed folder") } else { # check if submissions file pr_files <- gh::gh(paste0("GET /repos/", From 4121effe974103cb2d4dbf33adfdc440cc41a639 Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Fri, 19 Apr 2024 17:19:41 -0400 Subject: [PATCH 36/47] fix cache --- .github/workflows/validation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 54b0183..b7634af 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -33,7 +33,7 @@ jobs: key: ${{ runner.os }}-${{ hashFiles('.github/requirements.txt') }}-1 - name: Install dependencies - if: ( steps.change-check.outputs.skipnext != 'true' ) + if: ( steps.cache.outputs.cache-hit != 'true' ) run: | R -e 'Sys.setenv("NOT_CRAN" = TRUE) install.packages(c("arrow", "gh", "remotes")) From 6e73728cec21d90e96156e7af3b172b8866ce7be Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Fri, 19 Apr 2024 17:28:07 -0400 Subject: [PATCH 37/47] Update validation.yml --- .github/workflows/validation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index b7634af..89c5e1c 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -45,7 +45,7 @@ jobs: - name: Run Validation run: | - check=$( ${{ github.event.pull_request.event.action }}) + check=${{ github.event.pull_request.event.action }} echo $check Rscript code/validation.R env: From 654158591c1a1fe51bef88f7ca037db0d90a4df3 Mon Sep 17 00:00:00 2001 From: LucieContamin Date: Fri, 19 Apr 2024 17:34:53 -0400 Subject: [PATCH 38/47] update --- .github/workflows/validation.yml | 7 +++++-- code/validation.R | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 89c5e1c..6626c15 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -43,10 +43,13 @@ jobs: env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - - name: Run Validation + - name: test run: | - check=${{ github.event.pull_request.event.action }} + check=${{ github.event.action }} echo $check + + - name: Run Validation + run: | Rscript code/validation.R env: GH_PR_NUMBER: ${{ github.event.pull_request.number }} diff --git a/code/validation.R b/code/validation.R index f5ea039..7d3f582 100644 --- a/code/validation.R +++ b/code/validation.R @@ -3,6 +3,8 @@ library(gh) library(dplyr) # Check if validation need to run +print(length(Sys.getenv("GH_COMMIT_SHA"))) + if (length(Sys.getenv("GH_COMMIT_SHA")) > 1) { test <- gh::gh(paste0("GET /repos/", "midas-network/example_round-scenariohub/commits/", From b135a0c3ddd68b745772313dfae8bae24a7e3791 Mon Sep 17 00:00:00 2001 From: LucieContamin Date: Fri, 19 Apr 2024 17:39:36 -0400 Subject: [PATCH 39/47] one workflow --- .github/workflows/validation.yml | 16 +++++---- .github/workflows/validation_open.yml | 49 --------------------------- code/validation.R | 2 +- 3 files changed, 11 insertions(+), 56 deletions(-) delete mode 100644 .github/workflows/validation_open.yml diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 6626c15..985fb62 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -1,7 +1,7 @@ -name: Validate Submission(s) +name: Validate Submission on: pull_request_target: - types: [synchronize] + types: [synchronize, opened, reopened] branches: - main paths: @@ -43,15 +43,19 @@ jobs: env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - - name: test + - name: Run Validation + if: ( github.event.action == 'synchronize' ) run: | - check=${{ github.event.action }} - echo $check + Rscript code/validation.R + env: + GH_PR_NUMBER: ${{ github.event.pull_request.number }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_COMMIT_SHA: ${{ github.event.pull_request.head.sha }} - name: Run Validation + if: ( github.event.action != 'synchronize' ) run: | Rscript code/validation.R env: GH_PR_NUMBER: ${{ github.event.pull_request.number }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GH_COMMIT_SHA: ${{ github.event.pull_request.head.sha }} diff --git a/.github/workflows/validation_open.yml b/.github/workflows/validation_open.yml deleted file mode 100644 index 32e2c7a..0000000 --- a/.github/workflows/validation_open.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Validate Submission - Open PR -on: - pull_request_target: - types: [opened, reopened] - branches: - - main - -jobs: - validates-files: - runs-on: ubuntu-20.04 - - steps: - - - name: Checkout repository - uses: actions/checkout@v3 - with: - fetch-depth: 1 - - - name: Setup R - uses: r-lib/actions/setup-r@v2 - - - name: Install system dependencies - run: sudo apt-get install libcurl4-openssl-dev libudunits2-dev libgdal-dev - - - - name: Cache R packages - id: cache - uses: actions/cache@v2 - with: - path: ${{ env.R_LIBS_USER }} - key: ${{ runner.os }}-${{ hashFiles('.github/requirements.txt') }}-1 - - - name: Install dependencies - if: ( steps.cache.outputs.cache-hit != 'true' ) - run: | - R -e 'Sys.setenv("NOT_CRAN" = TRUE) - install.packages(c("arrow", "gh", "remotes")) - Sys.unsetenv("NOT_CRAN") - remotes::install_url("https://github.com/midas-network/SMHvalidation/archive/refs/heads/version.zip") - remotes::install_url("https://github.com/Infectious-Disease-Modeling-Hubs/hubUtils/archive/refs/heads/main.zip")' - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - - - name: Run Validation - run: | - Rscript code/validation.R - env: - GH_PR_NUMBER: ${{ github.event.pull_request.number }} - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/code/validation.R b/code/validation.R index 7d3f582..b2a12ec 100644 --- a/code/validation.R +++ b/code/validation.R @@ -5,7 +5,7 @@ library(dplyr) # Check if validation need to run print(length(Sys.getenv("GH_COMMIT_SHA"))) -if (length(Sys.getenv("GH_COMMIT_SHA")) > 1) { +if (length(Sys.getenv("GH_COMMIT_SHA")) > 0) { test <- gh::gh(paste0("GET /repos/", "midas-network/example_round-scenariohub/commits/", Sys.getenv("GH_COMMIT_SHA"))) From e2c079c34e8821105999b5c56fde3756f99e8ba8 Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Mon, 22 Apr 2024 13:09:19 -0400 Subject: [PATCH 40/47] Update ubuntu version --- .github/workflows/install_cache_dependencies.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/install_cache_dependencies.yml b/.github/workflows/install_cache_dependencies.yml index b8d034d..2d80820 100644 --- a/.github/workflows/install_cache_dependencies.yml +++ b/.github/workflows/install_cache_dependencies.yml @@ -8,7 +8,7 @@ on: jobs: cache-R-library: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - name: Checkout repository From 1272e050ad9e1a40ccd936278f67d97bfdd2edff Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Mon, 22 Apr 2024 13:10:55 -0400 Subject: [PATCH 41/47] Update validation.yml --- .github/workflows/validation.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 985fb62..7f08313 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -9,7 +9,7 @@ on: jobs: validates-files: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - name: Checkout repository @@ -43,19 +43,20 @@ jobs: env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - - name: Run Validation - if: ( github.event.action == 'synchronize' ) + - name: Run Validation - Open/reopen + if: ( github.event.action != 'synchronize' ) run: | Rscript code/validation.R env: GH_PR_NUMBER: ${{ github.event.pull_request.number }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GH_COMMIT_SHA: ${{ github.event.pull_request.head.sha }} - - name: Run Validation - if: ( github.event.action != 'synchronize' ) + - name: Run Validation - Synchronize + if: ( github.event.action == 'synchronize' ) run: | Rscript code/validation.R env: GH_PR_NUMBER: ${{ github.event.pull_request.number }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_COMMIT_SHA: ${{ github.event.pull_request.head.sha }} + From f8402c6050d7c06fc6f9f7905ca489163be61f87 Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Mon, 22 Apr 2024 13:49:34 -0400 Subject: [PATCH 42/47] Update validation.yml --- .github/workflows/validation.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 7f08313..92c6fe1 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -50,6 +50,7 @@ jobs: env: GH_PR_NUMBER: ${{ github.event.pull_request.number }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_COMMIT_SHA: "" - name: Run Validation - Synchronize if: ( github.event.action == 'synchronize' ) From 6dca2dc55b279db4e3b9def4ad3459fa009a5eda Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Mon, 22 Apr 2024 14:00:04 -0400 Subject: [PATCH 43/47] Update validation.yml --- .github/workflows/validation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 92c6fe1..95b01a8 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -50,7 +50,7 @@ jobs: env: GH_PR_NUMBER: ${{ github.event.pull_request.number }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GH_COMMIT_SHA: "" + GH_COMMIT_SHA: "none" - name: Run Validation - Synchronize if: ( github.event.action == 'synchronize' ) From bd8de72abaa4fba0a40e141c00129a2e3e7bd416 Mon Sep 17 00:00:00 2001 From: LucieContamin Date: Mon, 22 Apr 2024 14:12:45 -0400 Subject: [PATCH 44/47] update validation - run check --- code/validation.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/validation.R b/code/validation.R index b2a12ec..27d27ee 100644 --- a/code/validation.R +++ b/code/validation.R @@ -5,13 +5,14 @@ library(dplyr) # Check if validation need to run print(length(Sys.getenv("GH_COMMIT_SHA"))) -if (length(Sys.getenv("GH_COMMIT_SHA")) > 0) { +if (length(Sys.getenv("GH_COMMIT_SHA")) > 1) { test <- gh::gh(paste0("GET /repos/", "midas-network/example_round-scenariohub/commits/", Sys.getenv("GH_COMMIT_SHA"))) check <- grepl("data-processed/", unique(unlist(purrr::map(test$files, "filename")))) } else { + print(Sys.getenv("GH_COMMIT_SHA")) check <- TRUE } From 16372e0e9116023b88f072946759e5d94ff45135 Mon Sep 17 00:00:00 2001 From: LucieContamin Date: Mon, 22 Apr 2024 14:16:05 -0400 Subject: [PATCH 45/47] fix check run --- code/validation.R | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/code/validation.R b/code/validation.R index 27d27ee..f0e6a1e 100644 --- a/code/validation.R +++ b/code/validation.R @@ -3,16 +3,15 @@ library(gh) library(dplyr) # Check if validation need to run -print(length(Sys.getenv("GH_COMMIT_SHA"))) +print(nchar(Sys.getenv("GH_COMMIT_SHA"))) -if (length(Sys.getenv("GH_COMMIT_SHA")) > 1) { +if (nchar(Sys.getenv("GH_COMMIT_SHA")) > 1) { test <- gh::gh(paste0("GET /repos/", "midas-network/example_round-scenariohub/commits/", Sys.getenv("GH_COMMIT_SHA"))) check <- grepl("data-processed/", unique(unlist(purrr::map(test$files, "filename")))) } else { - print(Sys.getenv("GH_COMMIT_SHA")) check <- TRUE } From 08d872f4320c425dd280321f34d507906872f9da Mon Sep 17 00:00:00 2001 From: Lucie Contamin Date: Mon, 22 Apr 2024 14:16:36 -0400 Subject: [PATCH 46/47] Update validation.yml --- .github/workflows/validation.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 95b01a8..7f08313 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -50,7 +50,6 @@ jobs: env: GH_PR_NUMBER: ${{ github.event.pull_request.number }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GH_COMMIT_SHA: "none" - name: Run Validation - Synchronize if: ( github.event.action == 'synchronize' ) From e4e4fba87c8fe697032ecf1dc7e9bd9012fe3a59 Mon Sep 17 00:00:00 2001 From: LucieContamin Date: Mon, 22 Apr 2024 16:43:33 -0400 Subject: [PATCH 47/47] update validation --- code/validation.R | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/code/validation.R b/code/validation.R index f0e6a1e..fc0ca1f 100644 --- a/code/validation.R +++ b/code/validation.R @@ -19,6 +19,11 @@ if (isFALSE(all(check))) { test_tot <- NA print("no update in data-processed folder") } else { + # Prerequisite + pop_path <- "data-locations/locations.csv" + js_def_file <- "hub-config/tasks.json" + lst_gs <- NULL + # check if submissions file pr_files <- gh::gh(paste0("GET /repos/", "midas-network/example_round-scenariohub/pulls/", @@ -30,32 +35,42 @@ if (isFALSE(all(check))) { stringr::str_extract(pr_files_name, "data-processed/.+/\\d{4}-\\d{2}-\\d{2}(-.*)?") pr_sub_files <- unique(na.omit(pr_sub_files)) - pr_sub_files <- grep("(A|a)bstract", pr_sub_files, value = TRUE, invert = TRUE) - if (all(grepl(".pqt$|.parquet$", pr_sub_files))) { + pr_sub_files <- grep("(A|a)bstract", pr_sub_files, value = TRUE, + invert = TRUE) + round_id <- unique(stringr::str_extract(pr_sub_files, + "\\d{4}-\\d{2}-\\d{2}")) + config_json <- jsonlite::read_json(js_def_file) + rounds_ids <- unique(hubUtils::get_round_ids(config_json)) + sel_round <- grepl(paste(round_id, collapse = "|"), rounds_ids) + if (all(isFALSE(sel_round))) { + stop("The round id in the submission file was not recognized, please ", + "verify") + } + if (is.null(unlist(purrr::map(config_json$rounds[sel_round], "partition")))) { partition = NULL } else { - partition = c("origin_date", "target") - } - pop_path <- "data-locations/locations.csv" - js_def_file <- "hub-config/tasks.json" - lst_gs <- NULL + partition = unlist(purrr::map(config_json$rounds[sel_round], "partition")) + } # Run validation on file corresponding to the submission file format if (length(pr_sub_files) > 0) { - team_name <- unique(basename(dirname(pr_sub_files))) - sub_file_date <- unique(stringr::str_extract(basename(pr_sub_files), - "\\d{4}-\\d{2}-\\d{2}")) if (!(dir.exists(paste0(getwd(), "/proj_plot")))) dir.create(paste0(getwd(), "/proj_plot")) + sub_file_date <- unique(stringr::str_extract(basename(pr_sub_files), + "\\d{4}-\\d{2}-\\d{2}")) if (is.null(partition)) { + team_name <- unique(basename(dirname(pr_sub_files))) group_files <- paste0(sub_file_date, "-", team_name) } else { group_files <- sub_file_date + file_paths <- stringr::str_extract(pr_sub_files, + "(?<=data-processed/)(.+\\/)?") + team_name <- unique(unlist(purrr::map(strsplit(file_paths, "/"),1))) } test_tot <- lapply(group_files, function(y) { # select submission files pr_sub_files_group <- grep(y, pr_sub_files, value = TRUE) - pr_sub_files_lst <- pr_files[grepl(pr_sub_files_group, + pr_sub_files_lst <- pr_files[grepl(paste(pr_sub_files_group, collapse = "|"), purrr::map(pr_files, "filename"))] pr_sub_files_lst <- pr_sub_files_lst[!grepl("(A|a)bstract", @@ -86,7 +101,7 @@ if (isFALSE(all(check))) { val_path <- basename(pr_sub_files_group) round_id <- NULL } else { - val_path <- paste0(getwd(), "/part_sub/", dirname(pr_sub_files_group)) + val_path <- paste0(getwd(), "/part_sub/data-processed/", team_name, "/") round_id <- sub_file_date } arg_list <- list(path = val_path, js_def = js_def_file, lst_gs = lst_gs,