-
Notifications
You must be signed in to change notification settings - Fork 31
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
Allow Projects to Override Layers for Geoprocessing #3411
Conversation
This field will be used to save the layer overrides for each project. All existing projects are initialized with NLCD 2011, and all new projects will be initialized with an empty override dictionary. We use a JSONField which is available as of Django 1.11. This is a better representation than TextField which is what was used so far.
When the front-end requests a model run, we now include the layer_overrides in the model input. This is done for TR-55, MapShed, and Subbasin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments. The rest of the diff is just wiring layer_overrides
through all the necessary parts.
field=django.contrib.postgres.fields.jsonb.JSONField(default={'__LAND__': 'nlcd-2011-30m-epsg5070-512-int8'}, help_text='JSON object of layers to override defaults with'), | ||
preserve_default=False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ensures that the 2011 override is used for all existing projects, but no longer.
migrations.AlterField( | ||
model_name='project', | ||
name='layer_overrides', | ||
field=django.contrib.postgres.fields.jsonb.JSONField(default=dict, help_text='JSON object of layers to override defaults with'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ensures that the default is an empty dictionary, effectively no overrides, for all new projects.
I have started reviewing this, but am switching to pair on another project. |
When setting up the test on the Because the error is a missing Postgres function I am assuming that my database VM may be outdated. I don't know if having a broken weather data endpoint will affect the testing of this feature. |
Hmm, It's possible that reprovisioning your $ vagrant reload services --provision But in case that doesn't work, you'll have to recreate it, which is a bit more time taking: $ vagrant destroy services
$ vagrant up services Then, edit your diff --git a/scripts/aws/setupdb.sh b/scripts/aws/setupdb.sh
index 0d5b8443..4644c371 100755
--- a/scripts/aws/setupdb.sh
+++ b/scripts/aws/setupdb.sh
@@ -81,9 +81,7 @@ function download_and_load {
}
function purge_tile_cache {
- for path in "${PATHS[@]}"; do
- aws s3 rm --recursive "s3://tile-cache.${PUBLIC_HOSTED_ZONE_NAME}/${path}/"
- done
+ echo "Skipping purging tile cache locally"
}
function create_trgm_indexes { and then run: $ vagrant ssh app -c 'cd /vagrant && ./scripts/aws/setupdb.sh -bsdpmqc' to load all the necessary dev data. Then you'll have to create another account for yourself in the app, and then should be ready to go. The DRB 2011 analyses may still fail because they need an API key set. But they are not necessary for testing this work. |
Let's pair on this today. |
@@ -494,19 +494,21 @@ def nlcd_kfactor(result): | |||
return output | |||
|
|||
|
|||
def multi_mapshed(aoi, wkaoi): | |||
def multi_mapshed(aoi, wkaoi, layer_overrides={}): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps I should replace this with dict
def multi_mapshed(aoi, wkaoi, layer_overrides={}): | |
def multi_mapshed(aoi, wkaoi, layer_overrides=dict): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes!
|
||
|
||
def multi_subbasin(parent_aoi, child_shapes): | ||
def multi_subbasin(parent_aoi, child_shapes, layer_overrides={}): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here too
def multi_subbasin(parent_aoi, child_shapes, layer_overrides={}): | |
def multi_subbasin(parent_aoi, child_shapes, layer_overrides=dict): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We traced the 5xx timeout error I was seeing to the fact that my nhdflowlines table had no indexes. We got analysis working on my dev VM by loading/reloading layers. |
Now that we've specified all existing projects to use the old NLCD 2011 layer, we switch the default in the app to be the NLCD 2019 layer.
7bc8353
to
39266d8
Compare
Overview
Previously, every layer class (land, soil, etc.) had a single raster layer for it. As of recent work done in #3396 and #3399, we now have allow multiple raster layers for ever class of raster. The actual raster used is specified in the settings, can be overridden, as of #3406.
This PR adds override capability to Projects, in the form of a
layer_overrides
JSON field. The value of this field will be used to override the default layer configuration on every geoprocessing run. For all existing projects, this is set to override the land layer with NLCD 2011. For all new projects, no overrides are set. The front-end is updated to read this value from the project and use it when firing model runs, and the back-end is updated to expect this value in the model runs and use it. Finally, the default land layer is set to NLCD 2019.This allows us to preserve the work done in all existing projects, thus not changing results from under our users without their awareness, while still using the latest data for all work going forward.
Connects #3400
Testing Instructions
Much of the work in this PR is to preserve existing data. Thus, in order to test this, you must create local saved work on
develop
, then checkout this branch and perform the upgrades, then create some new work, and ensure that the old work is preserved.To compare old and new calculations, we'll use the same Area of Interest in both cases.
develop
$ vagrant ssh app -c 'sudo journalctl -fu mmw-app'
Now that our reference projects are setup, we can start testing the work in this branch.
./scripts/manage.sh migrate
and./scripts/bundle.sh --debug
vagrant ssh services -c 'redis-cli -n 1 --raw KEYS ":1:geop_*" | xargs redis-cli -n 1 DEL'
vagrant ssh worker -c 'sudo service celeryd restart'
layer_overrides: {}
keylayer_overrides: {}
keylayer_overrides: {"__LAND__":"nlcd-2011-30m-epsg5070-512-int8"}
key./scripts/manage.sh dbshell