Scoring #20
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Scoring | |
on: | |
workflow_dispatch: | |
# scheduled submission every Thursday at 01.15 CET | |
schedule: | |
- cron: "15 00 * * 4" | |
jobs: | |
scoring_job: | |
if: ${{ github.repository_owner == 'european-modelling-hubs' }} | |
runs-on: ubuntu-latest | |
outputs: | |
changed_files: ${{ steps.format_scoring_output.outputs.scoring_file_latest }} ${{ steps.format_scoring_output.outputs.scoring_file_snapshot }} | |
env: | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
# Checkout the tools repo | |
# ------------------------------------------- | |
- name: checkout tools repo | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
repository: 'european-modelling-hubs/hub-tools' | |
ref: 'main' | |
path: './tools/' | |
# Checkout the data repository | |
# ------------------------------------------- | |
- name: checkout data repo | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
repository: 'european-modelling-hubs/flu-forecast-hub' | |
ref: 'main' | |
path: './repo/' | |
# Setup R env | |
# ------------------------- | |
- uses: r-lib/actions/setup-r@v2 | |
with: | |
install-r: false | |
use-public-rspm: true | |
# Eventually install R dependencies | |
- name: Installing dependencies | |
run: | | |
install.packages("remotes") | |
install.packages("arrow", repos = c("https://apache.r-universe.dev", "https://cran.r-project.org")) | |
remotes::install_github("Infectious-Disease-Modeling-Hubs/hubData") | |
install.packages("dplyr") | |
install.packages('jsonlite') | |
install.packages("optparse") | |
install.packages("scoringutils") | |
shell: Rscript {0} | |
# Setup Python | |
# ------------------------- | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
# eventually install additional packages | |
- name: Installing python additional packages | |
run: pip install pandas==1.2.5 numpy==1.22.4 | |
# Run R code to compute scoring and produce an output file (scoring_outfile) | |
# ---------------------------------------------------------------------------- | |
- name: Generate Scoring | |
id: generate_scoring | |
run: | | |
# call R script from tools | |
Rscript ./tools/R-code/forecast_evaluation.R --hub_path "./repo" --truth_file_name "latest-ILI_incidence.csv" --subfolders "ERVISS,FluID" | |
# Do the python manipulations and produce an output file (scoring_file) | |
# ------------------------------------------------------------------------ | |
- name: format scoreing output | |
id: format_scoring_output | |
run: | | |
python ./tools/code/format_evaluation_file.py --hub_path "./repo" | |
# Commit the changes | |
# ------------------------- | |
- name: Commit changes | |
uses: EndBug/add-and-commit@v7 | |
with: | |
cwd: './repo' | |
add: ${{ steps.format_scoring_output.outputs.scoring_file_latest }} ${{ steps.format_scoring_output.outputs.scoring_file_snapshot }} # put here file changes | |
message: "Update forecast scoring" | |
default_author: github_actions | |
push: true | |
# Save data to json db | |
call-persisting-wf: | |
needs: scoring_job | |
uses: european-modelling-hubs/flu-forecast-hub/.github/workflows/persist_changes.yml@main | |
with: | |
changes-list: ${{ needs.scoring_job.outputs.changed_files }} | |
secrets: | |
envPAT: ${{ secrets.GITHUB_TOKEN }} | |
# Save changes to artifact for later persisting | |
# - name: Save changes to artifact | |
# env: | |
# changed_files: ${{ steps.format_scoring_output.outputs.scoring_file_latest }} ${{ steps.format_scoring_output.outputs.scoring_file_snapshot }} | |
# run: | | |
# echo "{ \"pr-changes\" : \"$changed_files\" }" > pr_changes.json | |
# - name: Upload changes | |
# uses: actions/upload-artifact@v2 | |
# with: | |
# name: pr_changes | |
# path: ./pr_changes.json | |