Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
b0695b7
New schema files from simanti
Sep 23, 2019
3da2c94
Added tests, come necessary project files (LICENSE, etc) and made the…
Sep 23, 2019
4113e88
Added readme data
Sep 23, 2019
be0eed3
Updated the sara file to support intermediate damage state conversions
Sep 27, 2019
43e4449
updated metadata
sensum-zz Sep 30, 2019
b2d62c2
New schema files from Simantini
Sep 23, 2019
5fcfd3b
Added tests, come necessary project files (LICENSE, etc) and made the…
Sep 23, 2019
db61247
Added readme data
Sep 23, 2019
9e24bed
Updated the sara file to support intermediate damage state conversions
Sep 27, 2019
187034e
Merge pull request #1 from gfzriesgos/update_schemas
ruester Oct 1, 2019
921e2d9
Update schema SARA with repository version
ruester Oct 1, 2019
9d5b5c2
Rename Dockerfile
ruester Oct 1, 2019
e926d33
Update Dockerfile
ruester Oct 1, 2019
f33aa31
added .DS_Store
sensum-zz Oct 1, 2019
aaec429
Update .gitignore
ruester Oct 2, 2019
f33bfd6
Add configuration for Travis CI
ruester Oct 2, 2019
aab25c5
Add build badges to README.md
ruester Oct 14, 2019
d7fc261
Add output folder to .gitignore
ruester Oct 14, 2019
4c2bd2a
Changes for notebook to work with current service versions
ruester Oct 14, 2019
1e6c2a4
Fix use of lognorm function in notebook
ruester Oct 14, 2019
543a3f9
Merge branch 'travis-ci'
ruester Oct 14, 2019
63b44d8
Skip installation when testing the docker build
ruester Oct 14, 2019
645ee6d
Updated the fragility model
Oct 28, 2019
0dd6489
Merge branch 'master' into update_schemas
nbrinckm Oct 28, 2019
d3d34d1
Merge pull request #2 from gfzriesgos/update_schemas
nbrinckm Oct 28, 2019
782fecb
Fixed an additional useless fragility function dataset
Oct 28, 2019
1a5953f
Updated schema for suppasri json file
Oct 28, 2019
72d4eb0
Added the mavrouli and torres to modelprop + test
Nov 14, 2019
bb9b485
Added more possible schemas to modelprop for wps
Nov 14, 2019
fee9bd9
Merge pull request #3 from gfzriesgos/add-ecuador-fragility-files
ruester Nov 14, 2019
a1503a0
Travis CI: Add test_all.py script to test phase
ruester Nov 14, 2019
86a6620
Use Python version 3.7 for docker image
ruester Nov 14, 2019
882e8eb
Fix PEP8 issues
ruester Nov 14, 2019
232531a
Update README.md
ruester Nov 14, 2019
ee08dac
Updated fragility functions for SARA, SUPPASRI & Mavrouli
Jul 2, 2020
2a61549
Merge pull request #4 from gfzriesgos/update-fragility-functions-2020…
nbrinckm Jul 2, 2020
d031fec
Fix the export, so that we don't have nans in resulting json
Jul 3, 2020
0568bde
Merge pull request #5 from gfzriesgos/bugfix-nan-export
nbrinckm Jul 3, 2020
91839ff
Added license & copyright headers
Jun 22, 2021
f9c9620
Added citation string
Jun 22, 2021
6ed0ec6
Keep newline to be consistent
Oct 11, 2021
b3755c0
Use cication string with full names
Oct 11, 2021
7b0f576
Merge pull request #6 from gfzriesgos/add-copyright-statnement-and-di…
nbrinckm Oct 11, 2021
36921d7
Added medina scheme
Oct 11, 2021
13e7cfe
Merge pull request #7 from gfzriesgos/add-medina-scheme
nbrinckm Oct 26, 2021
1f8a6bf
Use full legal name for GFZ copyright
Nov 18, 2021
81d86e6
Merge tag '1.0'
Nov 18, 2021
36226e6
Apply changes from black
ruester Nov 18, 2021
847df73
Use GitLab CI for testing and docker images
ruester Nov 18, 2021
b8a2fca
Merge branch 'use-gitlab-ci' into 'master'
gfzriesgos-bot Jan 11, 2022
f46ce43
CI: Fix installation of pip packages + black long lines
ruester Jan 19, 2022
ff977f8
Fix image name in metadata
ruester Jan 19, 2022
1d6f959
CI: Include versions in process description
ruester Jan 24, 2022
9f33f56
CI: Add trigger for deployment of latest docker image
ruester Mar 28, 2022
3a2ca7d
Minify JSON output
ruester Apr 19, 2022
63849ed
CI: Fix execution of black
ruester Apr 19, 2022
800f5fc
Merge branch 'minifiy-json-output' into 'master'
gfzriesgos-bot Apr 19, 2022
6e24ce2
Resolve "Normal distribution torres corredor files"
gfzriesgos-bot Apr 19, 2022
1a1afa1
Merge branch '2-normal-distribution-torres-corredor-files' into 'master'
gfzriesgos-bot Apr 19, 2022
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
11 changes: 9 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
htmlcov/schema
.tox/
.coverage
.coverage.*
Expand All @@ -49,7 +49,7 @@ coverage.xml

# Translations
*.mo
*.pot
*.potschema

# Django stuff:
*.log
Expand Down Expand Up @@ -102,3 +102,10 @@ venv.bak/

# mypy
.mypy_cache/
*.swp

# Mac OS stuff
.DS_Store

.idea
output/*
154 changes: 154 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
# Copyright © 2021 Helmholtz Centre Potsdam GFZ German Research Centre for Geosciences, Potsdam, Germany
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

stages:
- test
- build
- deploy

cache:
key: "$CI_COMMIT_REF_SLUG"
paths:
- .pip

.install_requirements: &install_requirements
- DEBIAN_FRONTEND=noninteractive apt-get update && apt-get upgrade -y
- pip3 install --cache-dir=.pip -r requirements.txt

verify_python:
image: python:3.7-buster
stage: test
tags:
- group
before_script:
- *install_requirements
script:
- python3 -m compileall .

python_pycodestyle:
image: python:3.7-buster
stage: test
# TODO: fix code to fit with PEP8 guidelines
allow_failure: true
tags:
- group
before_script:
- *install_requirements
- pip3 install --cache-dir=.pip pycodestyle
script:
- shopt -s globstar && pycodestyle {,**/}*.py

python_pylint:
image: python:3.7-buster
stage: test
# TODO: fix code to get a better pylint rating
allow_failure: true
tags:
- group
before_script:
- *install_requirements
- pip3 install --cache-dir=.pip pylint
script:
- shopt -s globstar && pylint --fail-under=8 {,**/}*.py

python_black:
image: python:3.7-buster
stage: test
tags:
- group
before_script:
- *install_requirements
- pip3 install --cache-dir=.pip black==22.3.0
script:
- black -l 79 --check .

run_tests:
image: python:3.7-buster
stage: test
tags:
- group
before_script:
- *install_requirements
script:
- python3 test_all.py

run_notebook:
image: python:3.7-buster
stage: test
tags:
- group
before_script:
- *install_requirements
- pip3 install scipy jupyter nbconvert ipykernel matplotlib
script:
- jupyter nbconvert --to html --execute --ExecutePreprocessor.kernel_name=python3 --output output.ipynb service_test.ipynb

verify_json:
stage: test
image: registry.gitlab.com/pipeline-components/jsonlint:0.12.0
cache: {}
script:
- |
find . -not -path './.git/*' -name '*.json' -type f -print0 |
parallel --will-cite -k -0 -n1 jsonlint -q

dockerbuild_latest:
image: docker/compose:1.29.2
stage: build
cache: {}
tags:
- group
script:
- docker build -t modelprop:latest -f metadata/Dockerfile .

# push latest image to Docker Hub
- docker tag modelprop:latest gfzriesgos/modelprop:latest
- docker login -u ${DOCKERHUB_USER} -p ${DOCKERHUB_PASSWORD}
- docker push gfzriesgos/modelprop:latest

# push latest image to GitLab Container Registry
- docker tag modelprop:latest git.gfz-potsdam.de:5000/id2/riesgos/modelprop:latest
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker push git.gfz-potsdam.de:5000/id2/riesgos/modelprop:latest

dockerbuild_tagged:
image: docker/compose:1.29.2
stage: build
cache: {}
tags:
- group
rules:
- if: $CI_COMMIT_TAG
script:
- sed -i -e "s@:latest@:${CI_COMMIT_TAG}@g" metadata/modelprop.json
- docker build -t modelprop:${CI_COMMIT_TAG} -f metadata/Dockerfile .

# push image to Docker Hub
- docker tag modelprop:${CI_COMMIT_TAG} gfzriesgos/modelprop:${CI_COMMIT_TAG}
- docker login -u ${DOCKERHUB_USER} -p ${DOCKERHUB_PASSWORD}
- docker push gfzriesgos/modelprop:${CI_COMMIT_TAG}

# push image to GitLab Container Registry
- docker tag modelprop:${CI_COMMIT_TAG} git.gfz-potsdam.de:5000/id2/riesgos/modelprop:${CI_COMMIT_TAG}
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker push git.gfz-potsdam.de:5000/id2/riesgos/modelprop:${CI_COMMIT_TAG}

deploy_latest:
stage: deploy
variables:
DEPLOY_LATEST_IMAGES: "true"
trigger:
project: id2/riesgos/gfz-riesgos-wps-repository
branch: master
strategy: depend
5 changes: 5 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Max Pittore <pittore@gfz-potsdam.de>
Nils Brinckmann <nils.brinckmann@gfz-potsdam.de>
Simantini Shinde <shinde@gfz-potsdam.de>
Matthias Rüster <matthias.ruester@gfz-potsdam.de>
Juan Camilo Gomez <jcgomez@gfz-potsdam.de>
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 2019-09-23

- Added the changelog
- Added the schemas for hazus and suppasri
- Updated the schema for sara
- Updated the code for finding supported schemas
- Updated json configuration for gfz riesgos wps
integration for supported schemas
- Updated README.md
- Added first unittest
- Code is now pep8 conform
- Code is now mostly pylint3 conform

# 2019-06-16

- Last version purely by Max Pittore (added the metadata for
the gfz riesgos wps integration)
36 changes: 36 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Contributing to the wps-pipeline-notebook

Please feel free to contribute to modelprop.
You can fork it and adopt it as you need, but we would like to
have also extensions flowing back into the original code base.

## Version schema
We use a version schema that is just date oriented.

## Branching policy
We use a development branch for every feature that we add.
Master branch should just be used for
a) the initial version
b) the place to merge feature branches into.

(As this code is written initially by a single person, most of the stuff
is done actually within the master branch).


## Testing
We use unittests.
Please make sure at least, that you write tests for the code you add
or change.

## Code styling

For code styling we use pep8 and pylint3.
Make sure that your code is at least compliant with pep8.

There is no need to care about pylint3 warnings regarding to
too less public methods in classes. Those are a good indicator
to use functions / partitial functions instead, but using classes
is clearer in most cases.

Also we don't care about unused arguments once methods implement a
common protocol and those variables are used in other implementations.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright [2021] [Helmholtz Centre Potsdam GFZ German Research Centre for Geosciences]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
96 changes: 95 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,96 @@
# modelprop
Program to serve a fragility / vulnerability model according to a given schema - RIESGOS Project


[![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/gfzriesgos/modelprop)](https://hub.docker.com/r/gfzriesgos/modelprop)
[![Build Status](https://travis-ci.com/gfzriesgos/modelprop.svg?branch=master)](https://travis-ci.com/gfzriesgos/modelprop)

## Purpose
Program to serve a fragility / vulnerability model
according to a given schema - RIESGOS Project

## Citation

Pittore, Massimiliano; Gomez-Zapata, Juan Camilo; Brinckmann, Nils; Rüster, Matthias (2021): Assetmaster and Modelprop: web services to serve building exposure models and fragility functions for physical vulnerability to natural-hazards. V. 1.0. GFZ Data Services. https://doi.org/10.5880/riesgos.2021.005

## Setup

We use a virtual environment, so you can need to create it and
install the pacakges from pip:

```shell
python3 -m venv env
source env/bin/activate
pip install -r requirements.txt
```

## Example run
After that you can run modelprop as in the following example:

```shell
python3 modelprop.py SARA-v1.0 buildings structural
```

What are the parameters:

| Parameter | Example | Purpose |
|----------------|------------|----------------------------------------------------------------------------------------------------|
| schema | SARA-v1.0 | This is the schema for the taxonomy. |
| asset category | buildings | In this case we are only interested in buildings, and not in other infrastructure. |
| loss category | structural | In this case we care about physical damage on the structure of the buildings. |
| taxonomy | | You can use this to just query a subset of the schema giving a taxonomy. This is empty by default. |

## Supported schemas

At the moment we support the following schemas:
* HAZUS-v1.0
* SARA-v1.0
* SUPPASRI2013-v2.0
* Mavrouli et al. 2014
* Torres Corredor et al. 2017

You can get a up to date list of the supported schemas by running the following commands
in a python shell from within this folder:

```python
import modelprop
modelprop.get_supported_schemas()
```


## Supported asset categories

At the moment only buildings are supported.

## Supported loss categories

At the moment we only support structural as loss category.

## How to add new schemas

### Naming and paths

The very first part is to check that the name of your schema file has the name `<your_schema_name>_struct.json` and
that this will be inserted in the folder `<your_schema_name>` in the schema subfolder.

### Data
It is important to have a meta block, with an id and the list of taxonomies and a data list with the
fragility function data for your taxonomy.

Every taxonomy that is listed in the data list must also be in the meta section and vice versa.

You can test it with the `assistance/check_modelprop_json_file.py` file.

## Copyright & License
Copyright © 2021 Helmholtz Centre Potsdam GFZ German Research Centre for Geosciences, Potsdam, Germany

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

## Project

Deus was developed in the scope of the RIESGOS project:
Multi-Risk Analysis and Information System Components for the Andes Region (https://www.riesgos.de/en)

7 changes: 7 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright © 2021 Helmholtz Centre Potsdam GFZ German Research Centre for Geosciences, Potsdam, Germany
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Loading