Skip to content
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,5 @@ cython_debug/

# Input files
local/rest_api_gcbm/input/
GCBM_Demo_Run/
GCBM_New_Demo_Run/
Binary file modified GCBM_New_Demo_Run.zip
Binary file not shown.
6 changes: 5 additions & 1 deletion local/rest_api_flint.example/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
version: "3.9"
services:
flint.example:
build: .
# - when developing use local builds
# build: .
# - or deploy using our CI
image: ghcr.io/moja-global/rest_api_flint.example:master
container_name: flint.example
ports:
- "8080:8080"
volumes:
Expand Down
319 changes: 167 additions & 152 deletions local/rest_api_gcbm/app.py

Large diffs are not rendered by default.

13 changes: 2 additions & 11 deletions local/rest_api_gcbm/curl.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h3> Endpoints </h3>

1. `/gcbm/new/`
1. `/gcbm/new/`

The title of a new simulation can be passed or the default title `simulation` will be used. (i.e the default title of the simulation is `simulation`, here the title `run4` is used)

Expand Down Expand Up @@ -31,15 +31,6 @@
-F db='@db/gcbm_input.db' \
-F miscellaneous='@miscellaneous/initial_age_moja.tiff' \
-F miscellaneous='@miscellaneous/mean_annual_temperature_moja.tiff' \
-F templates='@templates/internal_variables.json' \
-F templates='@templates/localdomain.json' \
-F templates='@templates/modules_cbm.json' \
-F templates='@templates/modules_output.json' \
-F templates='@templates/pools_cbm.json' \
-F templates='@templates/provider_config.json' \
-F templates='@templates/spinup.json' \
-F templates='@templates/variables.json' \
-F templates='@templates/gcbm_config.cfg' \
-F title="run4" \
http://localhost:8080/gcbm/upload

Expand All @@ -56,7 +47,7 @@
```
5. `/gcbm/download`
A file named `output.zip` will be obtained. This file contains the outputs generated, which can be analysed on unzipping.

```
curl -d "title=run4" -X POST http://localhost:8080/gcbm/download -L -o output.zip
```
Expand Down
5 changes: 4 additions & 1 deletion local/rest_api_gcbm/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
version: "3.9"
services:
gcbm:
# - when developing use local builds
build: .
# - or deploy using our CI
# image: ghcr.io/moja-global/rest_api_gcbm:master
container_name: flint.gcbm
ports:
- "8080:8080"
volumes:
- .:/app

Empty file.
7 changes: 7 additions & 0 deletions local/rest_api_gcbm/templates/gcbm_config.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
config=localdomain.json
config=pools_cbm.json
config=modules_cbm.json
config=modules_output.json
config=spinup.json
config=variables.json
config=internal_variables.json
34 changes: 34 additions & 0 deletions local/rest_api_gcbm/templates/internal_variables.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"Variables": {
"spatialLocationInfo": {
"flintdata": {
"type": "SpatialLocationInfo",
"library": "internal.flint",
"settings": {}
}
},
"simulateLandUnit": true,
"is_decaying": true,
"spinup_moss_only": false,
"run_peatland": false,
"peatlandId": -1,
"is_forest": true,
"run_moss": false,
"run_delay": false,
"landUnitBuildSuccess": true,
"regen_delay": 0,
"age": 0,
"tileIndex": 0,
"blockIndex": 0,
"cellIndex": 0,
"LandUnitId": -1,
"landUnitArea": 0,
"classifier_set": {},
"localDomainId": 0,
"LocalDomainId": 1,
"age_class": 0,
"historic_land_class": "FL",
"current_land_class": "FL",
"unfccc_land_class": "UNFCCC_FL_R_FL"
}
}
31 changes: 31 additions & 0 deletions local/rest_api_gcbm/templates/localdomain.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"Libraries": {
"moja.modules.cbm": "external",
"moja.modules.gdal": "external"
},
"LocalDomain": {
"start_date": "2010/01/01",
"end_date": "2021/01/01",
"landUnitBuildSuccess": "landUnitBuildSuccess",
"simulateLandUnit": "simulateLandUnit",
"sequencer_library": "moja.modules.cbm",
"sequencer": "CBMSequencer",
"timing": "annual",
"type": "spatial_tiled",
"landscape": {
"provider": "RasterTiled",
"num_threads": 4,
"tiles": [
{
"x": -106,
"y": 55,
"index": 12674
}
],
"x_pixels": 4000,
"y_pixels": 4000,
"tile_size_x": 1.0,
"tile_size_y": 1.0
}
}
}
17 changes: 17 additions & 0 deletions local/rest_api_gcbm/templates/logging.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[Core]
DisableLogging=false

[Sinks.console]
Destination=Console
Asynchronous=false
AutoFlush=true
Format="<%TimeStamp%> (%Severity%) - %Message%"
Filter="%Severity% >= info"

[Sinks.file]
Destination=TextFile
FileName="output/simulation.log"
Asynchronous=false
AutoFlush=true
Format="<%TimeStamp%> (%Severity%) - %Message%"
Filter="%Severity% >= debug"
65 changes: 65 additions & 0 deletions local/rest_api_gcbm/templates/modules_cbm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"Modules": {
"CBMBuildLandUnitModule": {
"order": 1,
"library": "moja.modules.cbm"
},
"CBMSequencer": {
"order": 2,
"library": "moja.modules.cbm"
},
"CBMDisturbanceListener": {
"enabled": true,
"order": 3,
"library": "moja.modules.cbm",
"settings": {
"vars": [
"disturbances_2012_moja",
"disturbances_2015_moja",
"disturbances_2014_moja",
"disturbances_2018_moja",
"disturbances_2016_moja",
"disturbances_2013_moja",
"disturbances_2011_moja"
]
}
},
"CBMDisturbanceEventModule": {
"enabled": true,
"order": 4,
"library": "moja.modules.cbm"
},
"CBMTransitionRulesModule": {
"enabled": true,
"order": 5,
"library": "moja.modules.cbm"
},
"CBMLandClassTransitionModule": {
"enabled": true,
"order": 6,
"library": "moja.modules.cbm"
},
"CBMGrowthModule": {
"enabled": true,
"order": 7,
"library": "moja.modules.cbm"
},
"CBMDecayModule": {
"enabled": true,
"order": 8,
"library": "moja.modules.cbm",
"settings": {
"extra_decay_removals": false
}
},
"CBMAgeIndicators": {
"enabled": true,
"order": 9,
"library": "moja.modules.cbm"
},
"TransactionManagerAfterSubmitModule": {
"order": 10,
"library": "internal.flint"
}
}
}
Loading