-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Continuous Integration tests up and running (#116)
* CI updated for GithubActions * Update Project.toml * CI updated with yml file * yml file path updated * yaml file extension fixed * PYTHON variable set to which python * PYTHON env fixed * CI updated * [WIP] Investigating strange behaviour of SIA solver There's some outflow outside the glacier, potentially due to the staggered grid or some processing which brings some ice outside the main glacier catchment. Need to investigate the SIA code in detail and play with the tolerance. * solve problem with boundary condition for SIA PDE (no UDE) * restore old version of action * [WIP] Mass balance fixed. Fixed issue with MB, which was not correctly selecting the subperiods for the climate data. To be merged with Facu's fix of the boundary conditions of the SIA. * New CI and Python environment from Facu * Updated test reference files * Forcing intitialization of gdirs from scratch for CI * CI and environment updated * CI and environment updated * Python env and tests fixed * Update environment.yml Fixing environment name. * Update environment.yml * Update environment.yml * Update environment.yml * Update environment.yml * Update CI.yml * Update CI.yml * Test update and environment.yml * Update CI.yml * Update CI.yml with CA certificate setup * CA certificate * Update CA variable assignment * Update CI.yml * Update CI.yml * Update CI.yml * Update CI.yml * Update CI.yml * SSL certificate added to tests * Ref files for test updated * Docs action removed + tests with less glaciers For now I have deactivated the Documentation action for GitHub, we can provide them in the future once the API is stable. I have also reduced the number of glaciers in the tests from 12 to 5, since it downloads a ton of data on GitHub CI. * Using 2 workers for tests * Using 2 workers for tests (now for OGGM) * Update README with micromamba installation and other details * Fall back multiprocessing in CI for PDE solving * Multiprocessing for OGGM fixed * Avoid downloading Millan22 velocities in CI * Correctly bypassing download of Millan22 velocities * Including missing catch on get_initial_status() --------- Co-authored-by: Facundo Sapienza <[email protected]>
- Loading branch information
1 parent
f46a2b3
commit 5564e48
Showing
21 changed files
with
566 additions
and
232 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 |
---|---|---|
@@ -1,28 +1,97 @@ | ||
name: Run tests | ||
|
||
name: Run Tests | ||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: ['*'] | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
schedule: | ||
- cron: '0 0 * * 0' | ||
|
||
concurrency: | ||
# Skip intermediate builds: always. | ||
# Cancel intermediate builds: only if it is a pull request build. | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} | ||
jobs: | ||
test-github-cpuonly: | ||
env: | ||
test: | ||
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} | ||
runs-on: ${{ matrix.os }} | ||
defaults: | ||
run: | ||
shell: bash -el {0} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-20.04] | ||
julia-version: ['1.8'] | ||
julia-arch: [x64] | ||
|
||
version: | ||
- '1.9' | ||
python: [3.9] | ||
os: | ||
- ubuntu-latest | ||
arch: | ||
- x64 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: julia-actions/setup-julia@latest | ||
- name: Set up Python 🐍 ${{ matrix.python }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
version: ${{ matrix.julia-version }} | ||
- uses: julia-actions/julia-buildpkg@latest | ||
- uses: julia-actions/julia-runtest@latest | ||
python-version: ${{ matrix.python }} | ||
- name: Create environment with micromamba 🐍🖤 | ||
uses: mamba-org/setup-micromamba@v1 | ||
with: | ||
micromamba-version: '1.3.1-0' | ||
environment-file: ./environment.yml | ||
environment-name: oggm_env # it is recommendable to add both name and yml file. | ||
init-shell: bash | ||
cache-environment: true | ||
# condarc-file: ./condarc.yml # If necessary, we can include .condarc to configure environment | ||
- name: Test creation of environment with micromamba 🔧🐍🖤 | ||
run: | | ||
which python | ||
conda env export | ||
shell: bash -el {0} | ||
- name: Update certifi | ||
run: | | ||
pip install --upgrade certifi | ||
shell: bash -el {0} | ||
# - name: Test OGGM installation 🔧🌎 | ||
# run: pytest.oggm | ||
# shell: bash -el {0} | ||
- name: Set ENV Variables for PyCall.jl 🐍 📞 | ||
run: export PYTHON=/home/runner/micromamba/envs/oggm_env/bin/python | ||
shell: bash -el {0} | ||
- uses: julia-actions/setup-julia@v1 | ||
with: | ||
version: ${{ matrix.version }} | ||
arch: ${{ matrix.arch }} | ||
- uses: julia-actions/cache@v1 | ||
with: | ||
cache-registries: "true" | ||
- uses: julia-actions/julia-buildpkg@v1 | ||
env: | ||
PYTHON : /home/runner/micromamba/envs/oggm_env/bin/python | ||
- uses: julia-actions/julia-runtest@v1 | ||
- uses: julia-actions/julia-processcoverage@v1 | ||
- uses: codecov/codecov-action@v2 | ||
with: | ||
files: lcov.info | ||
# docs: | ||
# name: Documentation | ||
# runs-on: ubuntu-latest | ||
# permissions: | ||
# contents: write | ||
# statuses: write | ||
# steps: | ||
# - uses: actions/checkout@v2 | ||
# - uses: julia-actions/setup-julia@v1 | ||
# with: | ||
# version: '1.9' | ||
# - uses: julia-actions/julia-buildpkg@v1 | ||
# env: | ||
# PYTHON : /home/runner/micromamba/envs/oggm_env/bin/python | ||
# - uses: julia-actions/julia-docdeploy@v1 | ||
# env: | ||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# - run: | | ||
# julia --project=docs -e ' | ||
# using Documenter: DocMeta, doctest | ||
# using ODINN | ||
# DocMeta.setdocmeta!(ODINN, :DocTestSetup, :(using ODINN); recursive=true) | ||
# doctest(ODINN)' |
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,16 @@ | ||
name: CompatHelper | ||
on: | ||
schedule: | ||
- cron: 0 0 * * * | ||
workflow_dispatch: | ||
jobs: | ||
CompatHelper: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Pkg.add("CompatHelper") | ||
run: julia -e 'using Pkg; Pkg.add("CompatHelper")' | ||
- name: CompatHelper.main() | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }} | ||
run: julia -e 'using CompatHelper; CompatHelper.main()' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: oggm_env | ||
channels: | ||
- conda-forge | ||
dependencies: | ||
- python=3.9 | ||
- jupyter | ||
- jupyterlab | ||
- numpy | ||
- scipy | ||
- pandas | ||
- shapely | ||
- matplotlib | ||
- Pillow | ||
- netcdf4 | ||
- scikit-image | ||
- scikit-learn | ||
- configobj | ||
- xarray | ||
- pytest | ||
- dask | ||
- bottleneck | ||
- gdal=3.3 | ||
- pyproj | ||
- cartopy | ||
- geopandas | ||
- rasterio | ||
- rioxarray | ||
- pytables | ||
- salem | ||
- motionless | ||
- ipython | ||
- numpydoc | ||
- seaborn | ||
- pip | ||
- pip: | ||
- joblib | ||
- progressbar2 | ||
- git+https://github.com/OGGM/pytest-mpl | ||
- git+https://github.com/OGGM/massbalance-sandbox | ||
- oggm==1.6.0 | ||
- certifi |
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,100 @@ | ||
|
||
# using Plots; gr() | ||
using CairoMakie | ||
using JLD2 | ||
import ODINN: fillZeros | ||
|
||
|
||
function make_plots() | ||
|
||
# plot_type = "only_H" # plot final H | ||
# plot_type = "MB_diff" # differences between runs with different MB models | ||
plot_type = "H_diff" # H - H₀ | ||
tspan = (2010.0, 2015.0) # period in years for simulation | ||
|
||
root_dir = dirname(Base.current_project()) | ||
|
||
# Load forward simulations with different surface MB | ||
grefs = load(joinpath(root_dir, "data/gdir_refs_$tspan.jld2"))["gdir_refs"] | ||
grefs_MBu1 = load(joinpath(root_dir, "data/gdir_refs_updatedMB1.jld2"))["gdir_refs"] | ||
|
||
n=4 | ||
m=3 | ||
hms_MBdiff, MBdiffs = [], [] | ||
figMB = Figure(resolution = (900, 1100)) | ||
axsMB = [Axis(figMB[i, j]) for i in 1:n, j in 1:m] | ||
hidedecorations!.(axsMB) | ||
tightlimits!.(axsMB) | ||
let label="" | ||
for (i, ax) in enumerate(axsMB) | ||
ax.aspect = DataAspect() | ||
name = grefs[i]["RGI_ID"] | ||
ax.title = name | ||
H = reverse(grefs[i]["H"]', dims=2) | ||
H₀ = reverse(grefs[i]["H₀"]', dims=2) | ||
H_MBu1 = reverse(grefs_MBu1[i]["H"]', dims=2) | ||
# H = reverse(grefs[i]["H"]) | ||
# H_MBu1 = reverse(grefs_MBu1[i]["H"]) | ||
if plot_type == "only_H" | ||
H_plot = H | ||
label = "Predicted H (m)" | ||
elseif plot_type == "H_diff" | ||
H_plot = H .- H₀ | ||
label = "H - H₀ (m)" | ||
elseif plot_type == "MB_diff" | ||
H_plot = H .- H_MBu1 | ||
label="Surface mass balance difference (m)" | ||
end | ||
push!(MBdiffs, H_plot) | ||
push!(hms_MBdiff, CairoMakie.heatmap!(ax, fillZeros(H_plot), colormap=:inferno)) | ||
end | ||
|
||
minMBdiff = minimum(minimum.(MBdiffs)) | ||
maxMBdiff = maximum(maximum.(MBdiffs)) | ||
foreach(hms_MBdiff) do hm | ||
hm.colorrange = (minMBdiff, maxMBdiff) | ||
end | ||
Colorbar(figMB[2:3,m+1], limits=(minMBdiff/2,maxMBdiff/2), label=label, colormap=:inferno) | ||
#Label(figH[0, :], text = "Glacier dataset", textsize = 30) | ||
if plot_type == "only_H" | ||
Makie.save(joinpath(root_dir, "plots/MB/H_MB_$tspan.pdf"), figMB, pt_per_unit = 1) | ||
elseif plot_type == "H_diff" | ||
Makie.save(joinpath(root_dir, "plots/MB/H_diff_wMB_$tspan.pdf"), figMB, pt_per_unit = 1) | ||
elseif plot_type == "MB_diff" | ||
Makie.save(joinpath(root_dir, "plots/MB/diffs_noMB_$tspan.pdf"), figMB, pt_per_unit = 1) | ||
end | ||
|
||
end # let | ||
|
||
# hms = [] | ||
# for (gref, gref_MBu1) in zip(grefs, grefs_MBu1) | ||
# H = reverse(gref["H"], dims=1) | ||
# H_MBu1 = reverse(gref_MBu1["H"], dims=1) | ||
# # H = gref["H"] | ||
# # H_MBu1 = gref_MBu1["H"] | ||
# push!(hms, heatmap(H .- H_MBu1, | ||
# clims=(0.0,5.0), | ||
# ylimits=(0, size(H)[1]), | ||
# xlimits=(0, size(H)[2]), | ||
# colorbar = false) | ||
# ) | ||
# end | ||
|
||
# h2 = scatter([0,0], [0,1], clims=(0.0,5.0), | ||
# xlims=(1,1.1), xshowaxis=false, yshowaxis=false, label="", colorbar_title="cbar", grid=false) | ||
|
||
|
||
# l = @layout [grid(6,5) a{0.01w}] | ||
|
||
# # Create the combined plot with the subplots and shared colormap | ||
# p_dhdt = plot(hms..., h2, | ||
# size=(1800, 1200), | ||
# layout=l, | ||
# link=:all, | ||
# aspect_ratio=:equal) | ||
|
||
# savefig(p_dhdt, joinpath(root_dir, "plots/MB/dhdt_MB_1")) | ||
|
||
end | ||
|
||
make_plots() |
Oops, something went wrong.