Skip to content

Daily PowerGenome outputs test #60

Daily PowerGenome outputs test

Daily PowerGenome outputs test #60

name: Daily PowerGenome outputs test
on:
push:
branches:
- main
schedule:
# Runs at 00:00 UTC every day
- cron: '0 0 * * *'
jobs:
run-pg-example:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
strategy:
max-parallel: 5
matrix:
branch: [master, develop]
permissions: # Need this to make the Julia cache work
actions: write
contents: read
steps:
- uses: julia-actions/setup-julia@v2 # Install latest version of Julia. Can use the matrix to run multiple versions
- uses: julia-actions/cache@v2 # Cache compiled packages. Saves 3-4 min each time.
- name: Checkout GenX.jl repository
uses: actions/checkout@v4
with:
repository: GenXProject/GenX.jl
ref: support/0.3.x # PG is still creating inputs for 0.3.x
path: GenX
# Install GenX.jl package using the checked out directory
- name: Install GenX.jl
uses: julia-actions/julia-buildpkg@v1
with:
project: GenX
precompile: yes
# Checkout the current repository
- name: Checkout current repository
uses: actions/checkout@v4
with:
path: current-repo
- name: Checkout PowerGenome repository
uses: actions/checkout@v4
with:
repository: PowerGenome/PowerGenome
ref: ${{ matrix.branch }}
path: PowerGenome
# Create env.yml that points to test data
- name: Create env.yml file
run: |
mkdir -p ${{ github.workspace }}/current-repo/example_systems/CA_AZ/settings
echo 'PUDL_DB: sqlite://///${{ github.workspace }}/PowerGenome/tests/data/pudl_test_data.db' > ${{ github.workspace }}/current-repo/example_systems/CA_AZ/settings/env.yml
echo 'PG_DB: sqlite://///${{ github.workspace }}/PowerGenome/tests/data/pg_misc_tables.sqlite3' >> ${{ github.workspace }}/current-repo/example_systems/CA_AZ/settings/env.yml
echo 'EFS_DATA: ${{ github.workspace }}/PowerGenome/tests/data/efs' >> ${{ github.workspace }}/current-repo/example_systems/CA_AZ/settings/env.yml
echo 'DISTRIBUTED_GEN_DATA: ${{ github.workspace }}/PowerGenome/tests/data/dist_gen' >> ${{ github.workspace }}/current-repo/example_systems/CA_AZ/settings/env.yml
echo 'RESOURCE_GROUPS: ${{ github.workspace }}/PowerGenome/tests/data/resource_groups_base' >> ${{ github.workspace }}/current-repo/example_systems/CA_AZ/settings/env.yml
- name: Install Conda environment with Micromamba
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ${{ github.workspace }}/PowerGenome/environment.yml
cache-environment: true
init-shell: bash
- name: Install powergenome
run: |
pip install -e PowerGenome/.
# Need to modify some of the settings so they work with the test data
- name: Run PowerGenome
run: |
cd ${{ github.workspace }}/current-repo/example_systems/CA_AZ/settings
sed -i 's/nrel_cambium_distr_pv_2022_utc.parquet/nrel_cambium_distr_pv_2022_slim.parquet/' distributed_gen.yml
sed -i 's/eia_data_years:/eia_data_years: [2018, 2020]/' resources.yml
sed -i 's/ - 2020/ # - 2020/' resources.yml
cd ..
run_powergenome_multiple -sf settings -rf genx-test -c p1 -mp
cd ..
cp Run.jl ${{ github.workspace }}/current-repo/example_systems/CA_AZ/genx-test/p1/Inputs/Inputs_p1
cp -r Settings/ ${{ github.workspace }}/current-repo/example_systems/CA_AZ/genx-test/p1/Inputs/Inputs_p1/
cd CA_AZ
# Upload GenX inputs (PG outputs) as artifact in case something fails
- name: Upload Inputs
uses: actions/upload-artifact@v4
if: always() # This ensures the step runs even if the previous step fails
with:
name: PG-outputs-${{ matrix.branch }}
path: ${{ github.workspace }}/current-repo/example_systems/CA_AZ/genx-test/p1/Inputs/Inputs_p1/
if-no-files-found: ignore # This option prevents the step from failing if no error.log file is created
- name: Run GenX
run: |
cd ${{ github.workspace }}/GenX
julia --project=. ${{ github.workspace }}/current-repo/example_systems/CA_AZ/genx-test/p1/Inputs/Inputs_p1/Run.jl
# Upload GenX results to look at and confirm everything looks good
- name: Upload Results
uses: actions/upload-artifact@v4
if: always() # This ensures the step runs even if the previous step fails
with:
name: GenX-results-${{ matrix.branch }}
path: ${{ github.workspace }}/current-repo/example_systems/CA_AZ/genx-test/p1/Inputs/Inputs_p1/Results
if-no-files-found: ignore # This option prevents the step from failing if no error.log file is created