Skip to content

auto-generate deflator files from inflation_default.csv #186

auto-generate deflator files from inflation_default.csv

auto-generate deflator files from inflation_default.csv #186

Workflow file for this run

# This workflow will install and set up conda and gams, run ReEDS, and run tests
name: CI
on:
pull_request:
branches:
- main
paths-ignore:
- 'docs/**'
- '*.md'
- 'LICENSE'
- '.gitignore'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
defaults:
run:
shell: bash -le {0}
env:
JULIA_VERSION: '1.12.1'
jobs:
reeds-env:
name: ReEDS Python and Julia env
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
actions: write # Required to save/update micromamba cache.
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Setup ReEDS environments
uses: ./.github/actions/setup-reeds-env
with:
julia-version: ${{ env.JULIA_VERSION }}
zenodo-setup:
name: "Get Zenodo files"
needs:
- reeds-env
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
actions: write # Required to save/update Zenodo data cache.
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 1
lfs: false
persist-credentials: false
- name: Create directories for zenodo files
run: mkdir -p inputs/remote inputs/profiles_cf inputs/profiles_demand inputs/profiles_dr inputs/profiles_temperature
- name: Identify Zenodo files for cache key
id: zenodo-files
run: |
echo "files-hash=$(md5sum inputs/remote_files.csv | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
- name: Restore Zenodo files from cache
id: cache-zenodo
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v4
with:
path: |
inputs/remote/
inputs/profiles_cf/
inputs/profiles_demand/
inputs/profiles_dr/
inputs/profiles_temperature/
key: zenodo-files-${{ steps.zenodo-files.outputs.files-hash }}-v1
restore-keys: |
zenodo-files-${{ steps.zenodo-files.outputs.files-hash }}-
zenodo-files-
- name: Setup Python environment
uses: ./.github/actions/setup-reeds-env
with:
setup-julia: false
- name: Download Zenodo files if not cached
if: steps.cache-zenodo.outputs.cache-hit != 'true'
run: python .github/scripts/download_test_zenodo_files.py
run-ReEDS:
if: ${{ github.actor != 'dependabot[bot]' }}
name: run ReEDS model matrix
runs-on: ubuntu-latest
timeout-minutes: 60
needs:
- reeds-env
- zenodo-setup
permissions:
contents: read
actions: write # Required to save/update LFS and Zenodo caches.
strategy:
fail-fast: false
max-parallel: 4
matrix:
include:
- scenario: github_Pacific
solve-year: 2029
- scenario: github_Everything
solve-year: 2060
- scenario: github_MA_county_CC
solve-year: 2026
env:
batch: test
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 1
lfs: false
persist-credentials: false
- name: Build LFS manifest
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
- name: Restore LFS cache
id: lfs-restore
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v4
with:
path: .git/lfs
key: lfs-${{ runner.os }}-${{ hashFiles('.lfs-assets-id') }}-v1
restore-keys: lfs-${{ runner.os }}-
- name: Pull missing LFS blobs
run: git lfs pull
- name: Save the updated LFS cache
if: steps.lfs-restore.outputs.cache-hit != 'true'
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v4
with:
path: .git/lfs
key: ${{ steps.lfs-restore.outputs.cache-primary-key }}
- name: Identify Zenodo files for cache key
id: zenodo-files
run: |
echo "files-hash=$(md5sum inputs/remote_files.csv | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
- name: Restore Zenodo files from cache
id: cache-zenodo
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v4
with:
path: |
inputs/remote/
inputs/profiles_cf/
inputs/profiles_demand/
inputs/profiles_dr/
inputs/profiles_temperature/
key: zenodo-files-${{ steps.zenodo-files.outputs.files-hash }}-v1
restore-keys: |
zenodo-files-${{ steps.zenodo-files.outputs.files-hash }}-
zenodo-files-
- name: Setup Python and Julia environments
id: setup-env
uses: ./.github/actions/setup-reeds-env
with:
julia-version: ${{ env.JULIA_VERSION }}
- name: Prepend Julia install to PATH
env:
JULIA_BINDIR: ${{ steps.setup-env.outputs.julia-bindir }}
run: printf '%s\n' "$JULIA_BINDIR" >> "$GITHUB_PATH"
- name: Setup environment variables
run: |
GAMSDIR="$(python -c 'from gamspy_base import directory;print(directory)')"
echo "GAMSDIR=$GAMSDIR" >> "$GITHUB_ENV"
echo "$GAMSDIR" >> "$GITHUB_PATH"
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GAMSDIR" >> "$GITHUB_ENV"
- name: Setup licence
env:
GAMSLICE_CONTENT: ${{ secrets.GAMSLICE }}
MAMBA_ENV_PATH: ${{ steps.setup-env.outputs.mamba-env-path }}
run: |
echo "$GAMSLICE_CONTENT" > "${MAMBA_ENV_PATH}/lib/python3.11/site-packages/gamspy_base/gamslice.txt"
- name: Set run folder
env:
SCENARIO: ${{ matrix.scenario }}
run: echo "RUN_FOLDER=$GITHUB_WORKSPACE/runs/${batch}_${SCENARIO}" >> "$GITHUB_ENV"
- name: Run ReEDS model
env:
SCENARIO: ${{ matrix.scenario }}
run: python runbatch.py -b "$batch" -c test -s "$SCENARIO"
- name: Print GAMS log
if: runner.debug == '1'
run: cat "$RUN_FOLDER/gamslog.txt"
- name: Check ReEDS outputs
if: ${{ hashFiles(format('{0}/outputs/cap_ivrt.csv', env.RUN_FOLDER)) == '' }}
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7
with:
script: |
core.setFailed('ReEDS run failed. Check log to diagnose.')
- name: Run output validation tests
env:
SCENARIO: ${{ matrix.scenario }}
run: python -m pytest tests/test_outputs.py --casepath "$GITHUB_WORKSPACE/runs/${batch}_${SCENARIO}"
- name: Upload ReEDS failure diagnostics
if: ${{ failure() }}
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
with:
name: ${{ format('{0}-failure-diagnostics', matrix.scenario) }}
compression-level: 9
retention-days: 7
if-no-files-found: ignore
path: |
${{ env.RUN_FOLDER }}/gamslog.txt
${{ env.RUN_FOLDER }}/meta.csv
${{ env.RUN_FOLDER }}/lstfiles/1_Inputs.lst
${{ env.RUN_FOLDER }}/lstfiles/${{ matrix.scenario }}_*i*.lst
${{ env.RUN_FOLDER }}/lstfiles/report_${{ matrix.scenario }}.lst
${{ env.RUN_FOLDER }}/ReEDS_Augur/PRAS/PRAS_*i*.log
- name: Save ReEDS run
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
with:
name: ${{ matrix.scenario }}
compression-level: 9
retention-days: 1
path: |
${{ env.RUN_FOLDER }}/inputs_case/**/*.csv
${{ env.RUN_FOLDER }}/meta.csv
${{ env.RUN_FOLDER }}/inputs_case/**/*.h5
${{ env.RUN_FOLDER }}/outputs/**/*.csv
${{ env.RUN_FOLDER }}/outputs/**/*.h5
run-R2X:
if: ${{ github.actor != 'dependabot[bot]' }}
name: run R2X compatibility matrix
runs-on: ubuntu-latest
timeout-minutes: 30
needs:
- run-ReEDS
permissions:
contents: read
actions: write # required for setup-uv cache save in run-R2X
continue-on-error: true
strategy:
matrix:
include:
- scenario: github_Pacific
solve-year: 2029
- scenario: github_Everything
solve-year: 2060
- scenario: github_MA_county_CC
solve-year: 2026
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Retrieve ReEDS runs for ${{ matrix.scenario }}
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7
with:
name: ${{ matrix.scenario }}
path: ${{ format('{0}-{1}', matrix.scenario, matrix.solve-year) }}
- name: Install uv and set Python version
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7
with:
python-version: "3.11"
enable-cache: true
restore-cache: true
save-cache: true
ignore-nothing-to-cache: true
- name: Run R2X compatibility
env:
R2X_REEDS_RUN_PATH: ${{ format('{0}-{1}', matrix.scenario, matrix.solve-year) }}
R2X_SCENARIO: ${{ matrix.scenario }}
R2X_SOLVE_YEAR: ${{ matrix.solve-year }}
R2X_WEATHER_YEAR: "2012"
R2X_SYSTEM_JSON: ${{ format('{0}_system.json', matrix.scenario) }}
run: |
uvx --from "r2x-reeds>=0.3.5" python scripts/run_r2x.py \
--reeds-run-path "$R2X_REEDS_RUN_PATH" \
--scenario "$R2X_SCENARIO" \
--solve-year "$R2X_SOLVE_YEAR" \
--weather-year "$R2X_WEATHER_YEAR" \
--system-json "$R2X_SYSTEM_JSON"
- name: Save R2X system
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: r2x-${{ matrix.scenario }}
compression-level: 9
retention-days: 1
path: ${{ format('{0}_system.json', matrix.scenario) }}