-
Notifications
You must be signed in to change notification settings - Fork 15
119 lines (98 loc) · 3.38 KB
/
ci-linux.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: CI-Linux
on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: "0 5 * * TUE"
env:
CACHE_NUMBER: 1 # Change this value to manually reset the environment cache
jobs:
build:
strategy:
fail-fast: false # don't break CI for ubuntu if windows fails before
matrix:
include:
# Matrix required to handle environment caching with Mambaforge
- os: ubuntu-latest
label: ubuntu-latest
prefix: /usr/share/miniconda3/envs/pypsa-earth
name: ${{ matrix.label }}
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v2
- name: Download PyPSA-Earth
run: |
cd ..
git clone https://github.com/pypsa-meets-earth/pypsa-earth.git
- name: Organize folder structure
run: |
cd ..
cp -r pypsa-kz-data ./pypsa-earth/pypsa-kz-data
- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v2
with:
miniforge-variant: Mambaforge
miniforge-version: latest
activate-environment: pypsa-earth
use-mamba: true
- name: Create environment cache
uses: actions/cache@v2
id: cache
with:
path: ${{ matrix.prefix }}
key: ${{ matrix.label }}-conda-${{ hashFiles('envs/environment.yaml') }}-${{ env.DATE }}-${{ env.CACHE_NUMBER }}
- name: Update environment due to outdated or unavailable cache
if: steps.cache.outputs.cache-hit != 'true'
run: |
ls
mamba env update -n pypsa-earth -f ../pypsa-earth/envs/environment.yaml
- name: Conda list
run: |
conda list
- name: Move test config
run: |
cd ../pypsa-earth
cp pypsa-kz-data/test/config_kz_default_test.yaml ./test/config.landlock.yaml
- name: Create test configs
run: |
cd ../pypsa-earth
snakemake --cores all build_test_configs
- name: Clean scenarios folder
run: |
cd ../pypsa-earth
rm -r pypsa-kz-data/scenarios/*
- name: Move test configs to scenario folder
run: |
cd ../pypsa-earth
cp pypsa-kz-data/test/config_kz_test1.yaml pypsa-kz-data/scenarios/config.kz_2013.yaml
cp ./test/tmp/config.landlock_tmp.yaml pypsa-kz-data/config.kz_default.yaml
- name : Change Snakefile lines
run: |
cd ../pypsa-earth
sed -i 's\os.system("snakemake -j all solve_all_networks --rerun-incomplete")\os.system(f"snakemake -j1 networks/{wildcards.scenario_name}/base.nc")\g' Snakefile
sed -i 's,os.system("snakemake -j1 make_statistics --force"),os.system("cp pypsa-kz-data/data/custom_powerplants.csv data/custom_powerplants.csv")\n\tos.system("snakemake -j1 solve_all_networks --rerun-incomplete"),g' Snakefile
cat Snakefile
- name: Replace Default config
run: |
cd ../pypsa-earth
cp pypsa-kz-data/config.kz_default.yaml config.default.yaml
cp config.default.yaml config.yaml
- name: Prepare KZ-scenarios
run: |
cd ../pypsa-earth
snakemake -j1 prepare_kz_scenarios
mkdir -p ./data/gadm
cp -r pypsa-kz-data/test/gadm ./data/gadm
find data -type f
cat configs/scenarios/config.kz_2013.yaml
- name: Run all scenarios
run: |
cd ../pypsa-earth
snakemake -j1 run_all_scenarios