From 583ac0c5b4470102b54c975d857bc1a88302a0f3 Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar (UMass)" Date: Tue, 21 Jan 2025 11:41:59 -0800 Subject: [PATCH] add update script and README --- Dockerfile | 1 + README.md | 80 +++++++++++++++++++++++++++++++++ scripts/create-predevals-data.R | 26 +++++------ scripts/update.R | 5 +++ 4 files changed, 99 insertions(+), 13 deletions(-) create mode 100644 README.md create mode 100755 scripts/update.R diff --git a/Dockerfile b/Dockerfile index 0ddb6f6..c2404fd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,3 +19,4 @@ RUN curl -ssL -o - https://github.com/mikefarah/yq/releases/download/${YQ_VERSIO tar xz && mv yq_linux_amd64 /usr/bin/yq COPY scripts/create-predevals-data.R /usr/local/bin +RUN chmod u+x /usr/local/bin/create-predevals-data.R diff --git a/README.md b/README.md new file mode 100644 index 0000000..e0c5074 --- /dev/null +++ b/README.md @@ -0,0 +1,80 @@ +# Docker container for hubPredEvalsData generation + +This docker container is a wrapper around +`hubPredEvalsData::generate_evals_data()` and hosts the in-development code +from +[hubverse-org/hubPredEvalsData](https://github.com/hubverse-org/hubPredEvalsData), +which is used to generate tables of evaluation data from a hub's [oracle +output](https://hubverse.io/en/latest/user-guide/target-data.html#oracle-output). + +The image is built and deployed to the GitHub Container Registry (https://ghcr.io). +You can find the [latest version of the +image](https://github.com/hubverse-org/hubPredEvalsData-docker/pkgs/container/hubpredevalsdata-docker/340871974?tag=main) +by using the `main` tag: + +From the command line: + +```sh +docker pull ghcr.io/hubverse-org/hubpredevalsdata-docker:main +``` + +## Usage + +The main usage for this image is a step in [the hub dashboard control +room](https://github.com/hubverse-org/hub-dashboard-control-room) that builds +evals data if it exists. + +The container packages the `create-predevals-data.R` script, which will display +help documentation if you pass `--help` to it. + +```sh +docker run --rm -it \ +-v "$(pwd)":/project \ +ghcr.io/hubverse-org/hubpredevalsdata-docker:main +create-predevals-data.R --help +``` + +```` +Calculate eval scores data and a predevals-config.json file + +USAGE + + create-predevals-data.R [--help] -h -c -d [-o ] + +ARGUMENTS + + --help print help and exit + -h path to a local copy of the hub + -c path or URL of predevals config file + -d path or URL to oracle output data + -o output directory + +EXAMPLE + +```bash +prefix="https://raw.githubusercontent.com/elray1/flusight-dashboard/refs/heads" +cfg="${prefix}/main/predevals-config.yml" +oracle="${prefix}/oracle-data/oracle-output.csv" + +tmp=$(mktemp -d) +git clone https://github.com/cdcepi/FluSight-forecast-hub.git $tmp + +create-predevals-data.R -h $tmp -c $cfg -d $oracle +``` +```` + +## Updating + +Because hubPredEvalsData is constantly improving, this container needs to be +rebuilt with the updated version. This can be achieved by running the update +script: + +``` +./scripts/update.R +``` + +When the update is complete, if there are updates, then the lockfile will change +and you will need to commit it. Once you commit and push, the docker image will +be rebuilt. + + diff --git a/scripts/create-predevals-data.R b/scripts/create-predevals-data.R index dcf6e99..202062f 100755 --- a/scripts/create-predevals-data.R +++ b/scripts/create-predevals-data.R @@ -5,28 +5,28 @@ # # USAGE # -# validate.R [--help] -h [/path/to/hub] -c [cfg] -d [oracle] -o [dir] +# create-predevals-data.R [--help] -h -c -d [-o ] # # ARGUMENTS # # --help print help and exit -# -h [/path/to/hub] path to a local copy of the hub -# -c [cfg] path or URL of predevals config file -# -d [oracle] path or URL to oracle output data -# -o [dir] output directory +# -h path to a local copy of the hub +# -c path or URL of predevals config file +# -d path or URL to oracle output data +# -o output directory # # EXAMPLE # -# ``` -# prefix="https://raw.githubusercontent.com/elray1/flusight-dashboard/refs/heads" -# cfg="${prefix}/main/predevals-config.yml" -# oracle="${prefix}/oracle-data/oracle-output.csv" +# ``` +# prefix="https://raw.githubusercontent.com/elray1/flusight-dashboard/refs/heads" +# cfg="${prefix}/main/predevals-config.yml" +# oracle="${prefix}/oracle-data/oracle-output.csv" # -# tmp=$(mktemp -d) -# git clone https://github.com/cdcepi/FluSight-forecast-hub.git $tmp +# tmp=$(mktemp -d) +# git clone https://github.com/cdcepi/FluSight-forecast-hub.git $tmp # -# create-predevals-data.R -h $tmp -c $cfg -d $oracle -# ``` +# create-predevals-data.R -h $tmp -c $cfg -d $oracle +# ``` # DOC args <- commandArgs() diff --git a/scripts/update.R b/scripts/update.R new file mode 100755 index 0000000..2c5ae08 --- /dev/null +++ b/scripts/update.R @@ -0,0 +1,5 @@ +#!/usr/bin/env Rscript + +renv::restore() +renv::update(packages = c("hubPredEvalsData", "scoringutils")) +renv::snapshot()