Delete model-api/src/model-builder/code-blocks/prior/variances/1.txt #123
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
# Model workflow code | |
name: Model CI # ============================================================== | |
on: # controls when the workflow will run | |
push: # trigger workflow on push events, but only for the main branch | |
branches: [ main ] | |
paths: | |
- "model-api/**" | |
- ".github/actions/build-model/**" | |
- ".github/workflows/main.yml" | |
- "st-kit/**" | |
- "!README.md" # don't rebuild on documentation changes | |
pull_request: # triggers workflow on pull request events (main branch only) | |
branches: [ main ] # ensures changes are "mergeable" | |
workflow_dispatch: # permits manual triggers from the Actions tab | |
# inputs: | |
# debug_enabled: | |
# description: 'Run the build with tmate debugging enabled' | |
# required: false | |
# default: false | |
# workflow_run: | |
# workflows: [ "Docker" ] | |
# branches: [ main ] | |
# types: [ completed ] | |
jobs: # ======================================================================= | |
# --------------------------------------------------------------------------- | |
count-vars: # creates template models for count data | |
# --------------------------------------------------------------------------- | |
strategy: | |
matrix: | |
likelihood: [ poisson, | |
negative-binomial-simple, negative-binomial, | |
gen-pois, | |
zero-inflated-poisson, zero-inflated-negative-binomial ] | |
link: [ linear, exponential ] | |
gle: [ b0, b0-b1 ] | |
include: | |
# Includes a new variable demo with a value of true for the matrix leg | |
# matching the following likelihood, link, and gle. | |
- likelihood: poisson | |
link: exponential | |
gle: b0-b1 | |
demo: true | |
exclude: | |
# excludes parameterizations | |
- likelihood: gen-pois | |
link: linear | |
runs-on: ubuntu-latest | |
# if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Pull model API from GitLab | |
run: | | |
git submodule update --init --remote model-api | |
# Build the JAGS model and save it in tmp | |
- name: Build model | |
uses: ./.github/actions/build-model # composite action to create model | |
with: | |
data-type: ${{ github.job }} | |
likelihood: ${{ matrix.likelihood }} | |
link: ${{ matrix.link }} | |
gle: ${{ matrix.gle }} | |
demo: ${{ matrix.demo }} | |
# Each artifact behaves as a file share. Uploading to the same artifact | |
# multiple times in the same workflow can overwrite and append to already | |
# uploaded files. | |
- name: Upload tmp directory as an artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: artifact-${{ github.sha }} | |
path: tmp | |
retention-days: 1 | |
# --------------------------------------------------------------------------- | |
binomial-vars: # creates template models for successes / trials data | |
# --------------------------------------------------------------------------- | |
strategy: | |
matrix: | |
likelihood: [ binomial, beta-binomial ] # zero-inflated-binomial, zero-inflated-beta-binomial | |
link: [ inverse-logit ] | |
gle: [ b0, b0-b1 ] | |
include: | |
- likelihood: binomial | |
link: inverse-logit | |
gle: b0 | |
demo: true | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Pull model API from GitLab | |
run: | | |
git submodule update --init --remote model-api | |
- name: Build model | |
uses: ./.github/actions/build-model # composite action to create model | |
with: | |
data-type: ${{ github.job }} | |
likelihood: ${{ matrix.likelihood }} | |
link: ${{ matrix.link }} | |
gle: ${{ matrix.gle }} | |
demo: ${{ matrix.demo }} | |
- name: Upload tmp directory as an artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: artifact-${{ github.sha }} | |
path: tmp | |
retention-days: 1 | |
# --------------------------------------------------------------------------- | |
nonnegative-continuous-vars: # template models for non-zero continuous data | |
# --------------------------------------------------------------------------- | |
strategy: | |
matrix: | |
likelihood: [ lognormal, gamma ] #, beta-binomial | |
link: [ linear ] # TODO: is exponential here even an option? | |
gle: [ b0, b0-b1 ] | |
include: | |
- likelihood: gamma | |
link: linear | |
gle: b0-b1 | |
demo: true | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
# with: | |
# submodules: true # fetch model and data API submodules | |
# fetch-depth: 0 # fetch all history for .GitInfo and .Lastmod | |
- name: Pull model API from GitLab | |
run: | | |
git submodule update --init --remote model-api | |
- name: Build model | |
uses: ./.github/actions/build-model # composite action to create model | |
with: | |
data-type: ${{ github.job }} | |
likelihood: ${{ matrix.likelihood }} | |
link: ${{ matrix.link }} | |
gle: ${{ matrix.gle }} | |
demo: ${{ matrix.demo }} | |
- name: Upload tmp directory as an artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: artifact-${{ github.sha }} | |
path: tmp | |
retention-days: 1 | |
# --------------------------------------------------------------------------- | |
define-jags-model-matrix: | |
# --------------------------------------------------------------------------- | |
needs: [ count-vars, binomial-vars, nonnegative-continuous-vars ] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Download file share | |
uses: actions/download-artifact@v2 | |
with: | |
name: artifact-${{ github.sha }} | |
path: tmp | |
- name: Create JAGS model file list as a JSON array | |
id: set-matrix # we need an "id" so we can use it in "outputs" below | |
run: | | |
echo "::set-output name=matrix::$(find tmp -name "model.jags" | \ | |
perl -e 'use JSON; @in=grep(s/\n$//, <>); print encode_json(\@in)."\n";')" | |
- name: Copy model files into model zoo in assets | |
run: | | |
find tmp -type f -name '*.jags' | |
find tmp -type f -name '*.jags' \ | |
-exec bash -c ' | |
ZOO=$(sed "s/tmp/assets\/model-zoo/g" <<< $(dirname $0)) | |
mkdir -p $(dirname $ZOO) && cp $0 $ZOO-model.jags' {} \; | |
# Push changes made to the repo during a workflow run | |
- name: Commit changes | |
uses: EndBug/add-and-commit@v7 | |
with: | |
default_author: github_actions | |
branch: main | |
add: "assets/**/*-model.jags" # --force | |
message: Automatic update of model files in model zoo | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
# --------------------------------------------------------------------------- | |
use-jags-models-to-sim-data: # create dynamic matrix from json, simulate data | |
# --------------------------------------------------------------------------- | |
needs: [ define-jags-model-matrix ] | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
jags-model: ${{ fromJson(needs.define-jags-model-matrix.outputs.matrix) }} | |
options: [ --seed=123 ] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Pull model API from GitLab | |
run: | | |
git submodule update --init --remote model-api | |
- name: Download file share | |
uses: actions/download-artifact@v2 | |
with: | |
name: artifact-${{ github.sha }} | |
path: tmp | |
- name: Use cached results (simulate data and fit model) | |
id: verify | |
uses: ./.github/actions/call-r | |
with: | |
rfile: model-api/demo/sim.R | |
args: ${{ matrix.jags-model }} | |
opts: ${{ matrix.options }} | |
- name: Check status of model verification | |
run: echo "The exit status was ${{ steps.verify.outputs.code }}" | |
- name: Upload tmp directory as an artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: artifact-${{ github.sha }} | |
path: tmp | |
retention-days: 1 | |
# --------------------------------------------------------------------------- | |
cleanup: # summarize sim fits, and write demo data to assets/_data | |
# --------------------------------------------------------------------------- | |
needs: [ use-jags-models-to-sim-data ] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Pull model API from GitLab | |
run: | | |
git submodule update --init --remote model-api | |
- name: Download file share | |
uses: actions/download-artifact@v2 | |
with: | |
name: artifact-${{ github.sha }} | |
path: tmp | |
- name: Move datasets flagged for demo to assets/_data | |
run: | | |
mkdir -p assets/_data | |
HINT_FILE=assets/_data/.generating-models.csv | |
rm -f $HINT_FILE && touch $HINT_FILE | |
echo file, generating_model >> $HINT_FILE | |
find tmp -type f -name 'demo' \ | |
-exec bash -c ' | |
DD_DIR=$(dirname $0) | |
DD_LAB=$(echo $0 | grep -oP "(?<=tmp/).*(?=-vars)") | |
DD_CSV=assets/_data/$DD_LAB-data.csv | |
echo $DD_CSV, $(basename $DD_DIR) >> assets/_data/.generating-models.csv | |
cp $DD_DIR/samples.csv $DD_CSV | |
cp $DD_DIR/sample-*.csv assets/_data' {} \; | |
ls assets/_data | |
# Push changes made to the repo during a workflow run | |
- name: Commit changes | |
uses: EndBug/add-and-commit@v7 | |
with: | |
default_author: github_actions | |
branch: main | |
add: "assets/_data/**" | |
message: Automatic update of demo data | |
- name: Create model config file list as a JSON array | |
id: config-file-list # we need an "id" so we can use it in "outputs" below | |
run: | | |
echo "::set-output name=matrix::$(find assets -name "[a-z]*.yml" | \ | |
perl -e 'use JSON; @in=grep(s/\n$//, <>); print encode_json(\@in)."\n";')" | |
outputs: | |
configs: ${{ steps.config-file-list.outputs.matrix }} | |
# --------------------------------------------------------------------------- | |
test: # use simulated data in the analysis pipeline | |
# --------------------------------------------------------------------------- | |
needs: [ cleanup ] | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
config-file: ${{ fromJson(needs.cleanup.outputs.configs) }} | |
# options: [ --n-adapt=1000 --n-update=5000 --n-iter=2500 --n-cores=1 --rm-dqs ] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Pull model API from GitLab | |
run: | | |
git submodule update --init --remote model-api | |
- name: Download file share | |
uses: actions/download-artifact@v2 | |
with: | |
name: artifact-${{ github.sha }} | |
path: tmp | |
- name: Test model API using data simulated in prior job | |
uses: ./.github/actions/call-r | |
with: | |
rfile: model-api/analysis-pipeline.R | |
args: ${{ matrix.config-file }} | |
opts: '--n-adapt=2000 --n-update=6000 --n-iter=3000 --n-cores=1 --rm-dqs' # ${{ matrix.options }} | |
# # Enable tmate debugging of manually-triggered workflows if the input | |
# # option was provided (i.e., debug_enabled=true) | |
# - name: Setup tmate session | |
# uses: mxschmitt/action-tmate@v3 | |
# # if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }} | |
- run: sudo mv assets/_output tmp/test-fits | |
- name: Upload tmp directory as an artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: artifact-${{ github.sha }} | |
path: tmp | |
retention-days: 1 |