diff --git a/.github/workflows/after-validate-submission.yaml b/.github/workflows/after-validate-submission.yaml index 94775b30..244e3d5a 100644 --- a/.github/workflows/after-validate-submission.yaml +++ b/.github/workflows/after-validate-submission.yaml @@ -80,8 +80,8 @@ jobs: - name: Check if RETRO files are present id: check_files run: | - echo 'retro='$(echo '${{ steps.changed-files.outputs.added_files }} ${{ steps.changed-files.outputs.modified_files }}' | grep 'model-output' | grep -c '.*-RETRO.*\.\(csv\|parquet\)') >> $GITHUB_ENV - echo 'conventional='$(echo '${{ steps.changed-files.outputs.added_files }} ${{ steps.changed-files.outputs.modified_files }}' | grep -c -v '.*-RETRO.*\.\(csv\|parquet\)') >> $GITHUB_ENV + echo 'retro='$(echo '${{ steps.changed-files.outputs.added_files }} ${{ steps.changed-files.outputs.modified_files }}' | tr ' ' '\n' | grep 'model-output' | grep '.*-RETRO.*\.\(csv\|parquet\)'| grep -v '\.github/') >> $GITHUB_ENV + echo 'conventional='$(echo '${{ steps.changed-files.outputs.added_files }} ${{ steps.changed-files.outputs.modified_files }}' | tr ' ' '\n' | grep -v '\.github/' | grep -c -v '.*-RETRO.*\.\(csv\|parquet\)') >> $GITHUB_ENV - name: Run R script run: | cd ./scripts @@ -90,7 +90,8 @@ jobs: - name: Run retro_ensemble.R run: | cd ./scripts - for file in $(echo '${{ steps.changed-files.outputs.added_files }} ${{ steps.changed-files.outputs.modified_files }}' | grep 'model-output' | grep '.*-RETRO.*\.\(csv\|parquet\)'); do + for file in $(echo '${{ steps.changed-files.outputs.added_files }} ${{ steps.changed-files.outputs.modified_files }}' | tr ' ' '\n' | grep 'model-output' | grep '.*-RETRO.*\.\(csv\|parquet\)'| grep -v '\.github/'); do + echo "Processing file: $file" Rscript retro_ensemble.R $file done if: ${{ env.retro != '0' }} diff --git a/scripts/retro_ensemble.R b/scripts/retro_ensemble.R index 251fc21d..99786668 100644 --- a/scripts/retro_ensemble.R +++ b/scripts/retro_ensemble.R @@ -57,6 +57,13 @@ projection_data_all <- file_paths %>% }) head(projection_data_all) +# Check the format of 'origin_date' column +print(unique(projection_data_all$origin_date)) + +# Ensure 'origin_date' is in a standard date format +projection_data_all <- projection_data_all %>% + mutate(origin_date = as.Date(origin_date, format = "%Y-%m-%d")) + # Prepare data projection_data_all <- dplyr::mutate(projection_data_all, target_date = as.Date(origin_date) + (horizon * 7) - 1)