-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Dockerfile and
build-and-run-model
workflow for CI model runs (#9)
* Simplify Pipenv dependencies * Add Dockerfile * Add build-and-run-model workflow * Temporarily pin build-and-run-model to development version of build-and-run-batch-job * Temporarily restrict dvc repro to the train step, for testing * Revert "Temporarily restrict dvc repro to the train step, for testing" This reverts commit 299b40b. * Unfreeze train step in dvc.yaml * Fix typo in loc_cook_municipality_name feature in params.yaml * Update README to reflect change in municipality name feature * Lint README.Rmd * Add print statements to finalize step to debug S3 failures * Add aws.ec2metadata packaage so that ECS can authenticate with S3 * Revert "Add print statements to finalize step to debug S3 failures" This reverts commit a5a64f5. * Pin build-and-run-model to main branch of ccao-data/actions * Rename loc_cook_municipality_name back to loc_tax_municipality_name * Revert "Pin build-and-run-model to main branch of ccao-data/actions" This reverts commit 82c3081. * Add ingest dependencies to renv.lock * Revert "Add ingest dependencies to renv.lock" This reverts commit 33f83a5. * Revert "Rename loc_cook_municipality_name back to loc_tax_municipality_name" This reverts commit 82d6155. * Revert "Revert "Pin build-and-run-model to main branch of ccao-data/actions"" This reverts commit e801405. * Revert "Revert "Revert "Pin build-and-run-model to main branch of ccao-data/actions""" This reverts commit a852f22. * Revert "Revert "Revert "Revert "Pin build-and-run-model to main branch of ccao-data/actions"""" This reverts commit 3f2114e.
- Loading branch information
1 parent
fc33def
commit 6cdc38f
Showing
13 changed files
with
1,242 additions
and
979 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Workflow that builds a Docker image containing the model code, | ||
# pushes it to the GitHub Container Registry, and then optionally uses | ||
# that container image to run the model using an AWS Batch job. | ||
# | ||
# Images are built on every commit to a PR or main branch in order to ensure | ||
# that the build continues to work properly, but Batch jobs are gated behind | ||
# a `deploy` environment that requires manual approval from a | ||
# @ccao-data/core-team member. | ||
|
||
name: build-and-run-model | ||
|
||
on: | ||
pull_request: | ||
types: [opened, reopened, synchronize, closed] | ||
workflow_dispatch: | ||
push: | ||
branches: [master] | ||
|
||
jobs: | ||
build-and-run-model: | ||
permissions: | ||
# contents:read and id-token:write permissions are needed to interact | ||
# with GitHub's OIDC Token endpoint so that we can authenticate with AWS | ||
contents: read | ||
id-token: write | ||
# While packages:write is usually not required for workflows, it is | ||
# required in order to allow the reusable called workflow to push to | ||
# GitHub Container Registry | ||
packages: write | ||
uses: ccao-data/actions/.github/workflows/build-and-run-batch-job.yaml | ||
with: | ||
vcpu: "16.0" | ||
memory: "65536" | ||
role-duration-seconds: 14400 # Worst-case time for a full model run | ||
secrets: | ||
AWS_IAM_ROLE_TO_ASSUME_ARN: ${{ secrets.AWS_IAM_ROLE_TO_ASSUME_ARN }} | ||
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
FROM rocker/r-ver:4.3.1 | ||
|
||
# Use PPM for binary installs | ||
ENV RENV_CONFIG_REPOS_OVERRIDE "https://packagemanager.posit.co/cran/__linux__/jammy/latest" | ||
ENV RENV_PATHS_LIBRARY renv/library | ||
|
||
# Install system dependencies | ||
RUN apt-get update && apt-get install --no-install-recommends -y \ | ||
libcurl4-openssl-dev libssl-dev libxml2-dev libgit2-dev git \ | ||
libudunits2-dev python3-dev python3-pip libgdal-dev libgeos-dev \ | ||
libproj-dev libfontconfig1-dev libharfbuzz-dev libfribidi-dev pandoc | ||
|
||
# Install pipenv for Python dependencies | ||
RUN pip install pipenv | ||
|
||
# Copy pipenv files into the image. The reason this is a separate step from | ||
# the later step that adds files from the working directory is because we want | ||
# to avoid having to reinstall dependencies every time a file in the directory | ||
# changes, as Docker will bust the cache of every layer following a layer that | ||
# needs to change | ||
COPY Pipfile . | ||
COPY Pipfile.lock . | ||
|
||
# Install Python dependencies | ||
RUN pipenv install --system --deploy | ||
|
||
# Copy R bootstrap files into the image | ||
COPY renv.lock . | ||
COPY .Rprofile . | ||
COPY renv/ renv/ | ||
|
||
# Install R dependencies | ||
RUN Rscript -e 'renv::restore()' | ||
|
||
# Copy the directory into the container | ||
ADD ./ model-condo-avm/ | ||
|
||
# Copy R dependencies into the app directory | ||
RUN rm -Rf model-condo-avm/renv | ||
RUN mv renv model-condo-avm/ | ||
|
||
# Set the working directory to the app dir | ||
WORKDIR model-condo-avm/ | ||
|
||
CMD dvc pull && dvc repro |
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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
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
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
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
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