os-climate / physrisk

Physical climate risk calculation engine
Apache License 2.0
29 stars 39 forks source link

Ability to visualize and test new hazard indicators in front-end #161

Open joemoorhouse opened 10 months ago

joemoorhouse commented 10 months ago

New hazard indicators are created from code in the hazard repo https://github.com/os-climate/hazard. These are pushed into the development bucket physrisk-hazard-indicators-dev01. Currently in order to test integration with API and UI it is necessary to run both locally which is quite heavy. It is desirable to be able to test via the existing UI https://physrisk-ui-sandbox.apps.odh-cl1.apps.os-climate.org/ in some 'test' mode.

joemoorhouse commented 10 months ago

Hi @mvarfima, FYI, this is the issue discussed last week. @EglantineGiraud, also of interest to you I think.

I have set up a new service end-point: https://physrisk-api-uat-sandbox.apps.odh-cl1.apps.os-climate.org Note the 'uat' in the name. This is identical to the existing service except that it uses the physrisk-hazard-indicators-dev01 bucket as opposed to physrisk-hazard-indicators.

New hazard data sets can be tested using this endpoint. I am also in the process of adding an option to the UI to use the test service rather than prod in a 'test' mode. The process is then 1) Add new hazard indicator data set in physrisk-hazard-indicators-dev01 2) Test using https://physrisk-api-uat-sandbox.apps.odh-cl1.apps.os-climate.org 3) Request promotion to physrisk-hazard-indicators (a set of fewer people doing the promotion!)

A few utilities exist to facilitate testing. In order to update the inventory.json with a new resource, the following code snippet in hazard can help (requires credentials for physrisk-hazard-indicators-dev01): docs_store = DocStore()

docs_store.write_new_empty_inventory()

docs_store.update_inventory([resource])

The inventory.json stored in physrisk-hazard-indicators-dev01 only contains data sets in testing (i.e. ones additional to the ones embedded in physrisk).

On update of the inventory, we can force a reload of the inventory using: https://physrisk-api-uat-sandbox.apps.odh-cl1.apps.os-climate.org/api/reset

mvarfima commented 10 months ago

@joemoorhouse Hi Joe we have updated the dev01 inventory.json (which only had one hazard, drought) with water stress. We have also added water stress to hazard.zarr of dev01 (we are onboarding to hazard_consortium.zarr). Somehow the sandbox test option is not working, and we think it could be related to de dev01 bucket changes we made. Could we maybe take a look at this together? Thank you very much, MV

joemoorhouse commented 10 months ago

Hi @mvarfima, As discussed, this is because the new hazard type has to be added to physrisk first. For now please use 'drought'. I would also suggest you use the same hazard.zarr not hazard_consortium.zarr but just have different paths. physrisk only uses a single root at the moment and no reason to change that (i.e. we have multiple sources already so no reason to add a separate root).

mvarfima commented 10 months ago

Hi @joemoorhouse I completely agree with everything, will do it as you just commented. I separated at the beggining as a testing zarr, I didn't want to break you hazard.zarr (not even the dev01 one).