Skip to content

Commit

Permalink
Merge pull request #185 from Deltares/docs
Browse files Browse the repository at this point in the history
Update with working docs workflow
  • Loading branch information
frederique-hub authored Oct 20, 2023
2 parents ff33f9a + 5bba56f commit 20f6a4c
Show file tree
Hide file tree
Showing 10 changed files with 538 additions and 73 deletions.
40 changes: 7 additions & 33 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Build Documentation

on:
workflow_dispatch:
push:
branches: [ main ]
paths:
Expand Down Expand Up @@ -39,50 +40,23 @@ jobs:
miniforge-variant: Mambaforge
miniforge-version: latest
channels: conda-forge
activate-environment: hydromt-fiat-docs
use-mamba: true

- name: load from cache
id: cache
uses: actions/cache/restore@v3
with:
path: |
/usr/share/miniconda3
~/pycache
./docs/_build
# the below two settings mean we'll alway srestore the cache
# but the cache hit output can tell us if we have to update afterwards
key: docs-${{ hashFiles('envs/hydromt-fiat-docs.yml') }}
restore-keys: |
docs
- name: Fail on no cache restore
if: steps.cache.outputs.cache-matched-key == ''
run: |
echo "Failed to restore any cache. exiting..."
exit 1
# by avoiding the mamba setup stage by loading it from cache instead we save
# a lot of setup time, but we do have to do our own PATH management
# hence the exports
- name: Update environment
if: steps.cache.outputs.cache-hit != 'true'
- name: Install and activate environment
run: |
export PATH=/usr/share/miniconda3/bin:$PATH
mamba env update -n hydromt-fiat-docs -f envs/hydromt-fiat-docs.yml
- name: Install hydromt-fiat
run: pip install .
mamba env create -f envs/hydromt-fiat-docs.yml
conda activate hydromt-fiat-docs
pip install .
- name: Generate docs
# if: ${{ github.event_name != 'pull_request' && !github.event.act }}
if: ${{ github.event_name != 'pull_request' && !github.event.act }}
run: |
export PATH=/usr/share/miniconda3/bin:$PATH
PYTHONPYCACHEPREFIX=~/pycache mamba run -n hydromt-fiat-docs sphinx-build -M html ./docs ./docs/_build
echo "DOC_VERSION=$(mamba run -n hydromt-fiat-docs python -c 'from hydromt_fiat import __version__ as v; print("dev" if "dev" in v else "v"+v.replace(".dev",""))')" >> $GITHUB_ENV
- name: Upload to GitHub Pages
# if: ${{ github.event_name != 'pull_request' && !github.event.act }}
if: ${{ github.event_name != 'pull_request' && !github.event.act }}
uses: peaceiris/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,5 @@ venv.bak/
cache
/examples/FIAT_database
hydromt_fiat/data/damage_functions/flooding/AllDDF_HAZUS_fractions.xlsx
hydromt_fiat/data/damage_functions/flooding/~$AllDDF_HAZUS_fractions.xlsx
examples/data/building_footprints/fiat_model_bfs
examples/data/aggregation_zones_example/aggregation_test_1_output
examples/data/aggregation_zones_example/aggregation_test_2_output
examples/data/aggregation_zones/output
1 change: 1 addition & 0 deletions docs/examples/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ Offline example access
Below you can access some of the main examples and go through them in an off-line manner. More examples will be added soon.

1. `Creating a Delft-FIAT model anywhere in the world from OSM and JRC data <../_examples/global_OSM_JRC.ipynb>`_
2. `Adding aggregation zones to your Delft-FIAT model <../_examples/aggregation_zones_example.ipynb>`_

4 changes: 4 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ by configuring the model building process from single *yml* file.

For detailed information on HydroMT itself, you can visit the `core documentation <https://deltares.github.io/hydromt/>`_.

::

Note: This repository is under development, the documentation is not yet complete...


Overview
=============
Expand Down
1 change: 1 addition & 0 deletions envs/hydromt-fiat-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies:
- pip
- pyogrio
- pydata-sphinx-theme
- python=3.10
- rasterio
- requests
- rioxarray
Expand Down
542 changes: 513 additions & 29 deletions examples/aggregation_zones_example.ipynb

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions examples/data/aggregation_zones/config_aggregation.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
cases:
test1_single_aggregation:
new_root: "./data/Aggregation_zones_example/output/aggregation_zones_test1"
new_root: "./data/Aggregation_zones/output/aggregation_zones_test1"
configuration:
setup_aggregation_areas:
aggregation_area_fn: "./data/Aggregation_zones_example/aggregation_zones/base_zones.gpkg"
aggregation_area_fn: "./data/Aggregation_zones/aggregation_zones/base_zones.gpkg"
attribute_names: ZONE_BASE
label_names: Base_zones

test2_multiple_aggregation:
new_root: "./data/Aggregation_zones_example/output/aggregation_zones_test2"
new_root: "./data/Aggregation_zones/output/aggregation_zones_test2"
configuration:
setup_aggregation_areas:
aggregation_area_fn:
- "./data/Aggregation_zones_example/aggregation_zones/base_zones.gpkg"
- "./data/Aggregation_zones_example/aggregation_zones/land_use.gpkg"
- "./data/Aggregation_zones_example/aggregation_zones/accomodation_type.gpkg"
- "./data/Aggregation_zones/aggregation_zones/base_zones.gpkg"
- "./data/Aggregation_zones/aggregation_zones/land_use.gpkg"
- "./data/Aggregation_zones/aggregation_zones/accomodation_type.gpkg"
attribute_names:
- ZONE_BASE
- LAND_USE
Expand Down
4 changes: 3 additions & 1 deletion examples/data/aggregation_zones/fiat_model/settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ file = "./vulnerability/vulnerability_curves.csv"
unit = "feet"
step_size = 0.1

[exposure.csv]
file = "./exposure/exposure.csv"

[exposure.geom]
csv = "./exposure/exposure.csv"
crs = "EPSG:4326"
unit = "ft"
file1 = "./exposure/buildings.gpkg"
2 changes: 1 addition & 1 deletion hydromt_fiat/fiat.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ def read_tables(self):
logging.warning(f"File {vulnerability_fn} does not exist!")

# Now with exposure
exposure_fn = Path(self.root) / self.get_config("exposure.geom.csv")
exposure_fn = Path(self.root) / self.get_config("exposure.csv.file")
if Path(exposure_fn).is_file():
self.logger.debug(f"Reading exposure table {exposure_fn}")
self.exposure = ExposureVector(
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ authors = [
{name = "Mario Fuentes Monjaraz", email = "[email protected]"},
{name = "Luis Rodriguez Galvez", email = "[email protected]"},
{name = "Lieke Meijer", email = "[email protected]"},
{name = "Sarah Rautenbach", email = "[email protected]"},
]
requires-python = ">=3.8"
dependencies = [
Expand Down

0 comments on commit 20f6a4c

Please sign in to comment.