Skip to content

Add C/I workflow that verifies everything still works icw the latest LUE release #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# https://editorconfig.org

root = true

[*]
charset = utf-8
indent_style = space
indent_size = 4
insert_final_newline = true
max_line_length = 110
trim_trailing_whitespace = true

[*.yml]
indent_size = 2
51 changes: 51 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Linux

on:
push:
branches: [ "main" ]
pull_request:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

defaults:
run:
shell: bash -l {0}

steps:
- uses: actions/checkout@v4

- uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: latest
auto-update-conda: true
conda-solver: "libmamba"
python-version: 3.12

- name: setup platform
run: |
conda env create --file=environment/configuration/conda_environment.yml
conda activate lue_tutorial
export LD_PRELOAD=$(find $CONDA_PREFIX -name libtcmalloc_minimal.so.4)
python -c 'import lue; print(f"lue: {lue.__version__} ({lue.git_short_sha1})")'

- name: game_of_life
run: |
conda activate lue_tutorial
export LD_PRELOAD=$(find $CONDA_PREFIX -name libtcmalloc_minimal.so.4)

cd use_case/game_of_life
python game_of_life.py 5000 1000 10 generation
ls -l *.tif

- name: usle
run: |
conda activate lue_tutorial
export LD_PRELOAD=$(find $CONDA_PREFIX -name libtcmalloc_minimal.so.4)

cd use_case/usle
curl --remote-name --silent https://lue.computationalgeography.org/download/lue_qa/elevation.tif
python usle.py 1000 elevation.tif usle.tif
ls -l *.tif
51 changes: 51 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: macOS

on:
push:
branches: [ "main" ]
pull_request:
workflow_dispatch:

jobs:
build:
runs-on: macos-latest

defaults:
run:
shell: bash -l {0}

steps:
- uses: actions/checkout@v4

- uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: latest
auto-update-conda: true
conda-solver: "libmamba"
python-version: 3.12

- name: setup platform
run: |
conda env create --file=environment/configuration/conda_environment.yml
conda activate lue_tutorial
export DYLD_INSERT_LIBRARIES=$(find $CONDA_PREFIX -name libtcmalloc_minimal.so.4)
python -c 'import lue; print(f"lue: {lue.__version__} ({lue.git_short_sha1})")'

- name: game_of_life
run: |
conda activate lue_tutorial
export DYLD_INSERT_LIBRARIES=$(find $CONDA_PREFIX -name libtcmalloc_minimal.so.4)

cd use_case/game_of_life
python game_of_life.py 5000 1000 10 generation
ls -l *.tif

- name: usle
run: |
conda activate lue_tutorial
export DYLD_INSERT_LIBRARIES=$(find $CONDA_PREFIX -name libtcmalloc_minimal.so.4)

cd use_case/usle
wget --quiet https://lue.computationalgeography.org/download/lue_qa/elevation.tif
python usle.py 1000 elevation.tif usle.tif
ls -l *.tif
48 changes: 48 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Windows

on:
push:
branches: [ "main" ]
pull_request:
workflow_dispatch:

jobs:
build:
runs-on: "windows-2022"

defaults:
run:
shell: bash -l {0}

steps:
- uses: actions/checkout@v4

- uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: latest
auto-update-conda: true
conda-solver: "libmamba"
python-version: 3.12

- name: setup platform
run: |
conda env create --file=environment/configuration/conda_environment.yml
conda activate lue_tutorial
python -c 'import lue; print(f"lue: {lue.__version__} ({lue.git_short_sha1})")'

- name: game_of_life
run: |
conda activate lue_tutorial

cd use_case/game_of_life
python game_of_life.py 5000 1000 10 generation
ls -l *.tif

- name: usle
run: |
conda activate lue_tutorial

cd use_case/usle
curl --remote-name --silent https://lue.computationalgeography.org/download/lue_qa/elevation.tif
python usle.py 1000 elevation.tif usle.tif
ls -l *.tif
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
# - id: check-yaml
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 22.12.0
rev: 24.10.0
hooks:
- id: black
27 changes: 25 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

🚧 🚧 🚧 🚧 🚧 🚧 Work in progress. 🚧 🚧 🚧 🚧 🚧 🚧

[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)
[![black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
| Branch | Status |
| --- | --- |
| main | [![Linux](https://github.com/computationalgeography/lue_tutorial/actions/workflows/linux.yml/badge.svg)](https://github.com/computationalgeography/lue_tutorial/actions/workflows/linux.yml) [![macOS](https://github.com/computationalgeography/lue_tutorial/actions/workflows/macos.yml/badge.svg)](https://github.com/computationalgeography/lue_tutorial/actions/workflows/macos.yml) [![Windows](https://github.com/computationalgeography/lue_tutorial/actions/workflows/windows.yml/badge.svg)](https://github.com/computationalgeography/lue_tutorial/actions/workflows/windows.yml) |
| develop | |


## Use cases

We have added relatively simple use-cases here, to illustrate what LUE can be used for. They
are very simple, which is on purpose of course. LUE hides much of the complicated stuff to
perform very large models on large amounts of hardware.
Expand All @@ -21,3 +24,23 @@ Current list:
- [Merge raster](use_case/merge_raster)
- Run a non-LUE numerical simulation model concurrently for multiple areas, and aggregate
the results in a single LUE dataset.


## Quick start

To be able to run one or more use-cases, the following steps must be performed first:

- Install a Conda client, like [Miniforge](https://conda-forge.org/miniforge/).
- Clone the tutorial repository:

```bash
git clone https://github.com/computationalgeography/lue_tutorial.git
cd lue_tutorial
```

- Create and activate a Conda environment with the required Python packages:

```bash
conda env create --file=environment/configuration/conda_environment.yml
conda activate lue_tutorial
```
5 changes: 5 additions & 0 deletions environment/configuration/conda_environment-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include: conda_environment.yml
dependencies:
- pre-commit
- pyright
- python-lsp-server
4 changes: 2 additions & 2 deletions environment/configuration/conda_environment.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: lue_tutorial
channels:
- conda-forge
- defaults
- nodefaults
dependencies:
- docopt
- gdal
- imageio
- ipython # Optional
- matplotlib
- lue>=0.3.4
- lue==0.3.7
- rasterio
4 changes: 3 additions & 1 deletion use_case/game_of_life/game_of_life.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ def initialize_generation(array_shape, partition_shape):
)

fraction_alive_cells = 0.25
generation = lfr.uniform(generation, 0, 1) <= fraction_alive_cells
generation = (
lfr.uniform(generation, np.dtype(np.float32), 0, 1) <= fraction_alive_cells
)

return generation

Expand Down
1 change: 1 addition & 0 deletions use_case/usle/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Universal Soil Loss Equation

The [usle.py](usle.py) script in this directory calculates the average anual soil loss, using the USLE
equation. The goal is to show off how the LUE framework can be used to perform the necessary
calculations. Given enough hardware, LUE will perform the calculations in parallel.
Expand Down
2 changes: 1 addition & 1 deletion use_case/usle/usle-desktop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set -e
export LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libtcmalloc_minimal.so.4"

# This example DEM is downloaded from
# https://www.data.gv.at/katalog/dataset/0454f5f3-1d8c-464e-847d-541901eb021a
# https://www.data.gv.at/katalog/de/dataset/land-tirol_tirolgelnde
# DGM 10m Tirol EPSG:31254
# It is possible to use another DEM though. Note that the usle.py script currently contains a
# hard-coded cell size. Be sure to update it in case your DEM has cells of different size.
Expand Down
Loading