diff --git a/deployment/ansible/group_vars/all b/deployment/ansible/group_vars/all index 45d7dd213..4a8fb22f2 100644 --- a/deployment/ansible/group_vars/all +++ b/deployment/ansible/group_vars/all @@ -44,7 +44,7 @@ docker_compose_version: "1.26.*" geop_host: "localhost" geop_port: 8090 -geop_version: "5.0.0" +geop_version: "5.1.0" geop_cache_enabled: 1 nginx_cache_dir: "/var/cache/nginx" diff --git a/src/mmw/apps/modeling/calcs.py b/src/mmw/apps/modeling/calcs.py index 5fbc254e2..4960bce1b 100644 --- a/src/mmw/apps/modeling/calcs.py +++ b/src/mmw/apps/modeling/calcs.py @@ -10,8 +10,6 @@ from django.conf import settings from django.db import connection -from django.contrib.gis.geos import WKBReader - from apps.modeling.mapshed.calcs import (area_calculations, nearest_weather_stations, average_weather_data @@ -431,7 +429,7 @@ def _get_boundary_search_query(search_term): subquery = ' UNION ALL '.join(selects) return f""" - SELECT id, code, name, rank, center + SELECT id, code, name, rank, ST_X(center) AS x, ST_Y(center) AS y FROM ({subquery}) AS subquery ORDER BY rank DESC, name """ @@ -448,14 +446,13 @@ def _do_boundary_search(search_term): wildcard_term = f'%{search_term}%' cursor.execute(query, {'term': wildcard_term}) - wkb_r = WKBReader() - for row in cursor.fetchall(): id = row[0] code = row[1] name = row[2] rank = row[3] - point = wkb_r.read(row[4]) + x = row[4] + y = row[5] layer = _get_boundary_layer_by_code(code) @@ -465,8 +462,8 @@ def _do_boundary_search(search_term): 'text': name, 'label': layer['short_display'], 'rank': rank, - 'y': point.y, - 'x': point.x, + 'x': x, + 'y': y, }) return result diff --git a/src/mmw/apps/modeling/migrations/0039_override_sedaadjust_for_old_scenarios.py b/src/mmw/apps/modeling/migrations/0039_override_sedaadjust_for_old_scenarios.py new file mode 100644 index 000000000..f6a036e99 --- /dev/null +++ b/src/mmw/apps/modeling/migrations/0039_override_sedaadjust_for_old_scenarios.py @@ -0,0 +1,49 @@ +# Generated by Django 3.2.10 on 2021-12-27 19:26 +import json +from django.db import migrations + + +def override_sedaadjust_for_old_projects(apps, schema_editor): + """ + The default value of SedAAdjust is being changed from 1.5 to 1.25 for all + new projects, which will use the high resolution "nhdhr" stream data. For + older projects using the medium resolution "nhd" data, we override the + value to be 1.5, so they remain consistent with old data, unless they were + overridden by a user. + """ + db_alias = schema_editor.connection.alias + Project = apps.get_model('modeling', 'Project') + + ps = Project.objects.filter(layer_overrides__contains={'__STREAMS__':'nhd'}) + + for p in ps: + for s in p.scenarios.all(): + mods = json.loads(s.modifications) + m_other = next((m for m in mods if m['modKey'] == 'entry_other'), None) + + if m_other: + if 'SedAAdjust' not in m_other['output']: + m_other['output']['SedAAdjust'] = 1.5 + m_other['userInput']['SedAAdjust'] = 1.5 + + s.modifications = json.dumps(mods) + s.save() + else: + mods.append({ + 'modKey': 'entry_other', + 'output': {'SedAAdjust': 1.5}, + 'userInput': {'SedAAdjust': 1.5}}) + + s.modifications = json.dumps(mods) + s.save() + + +class Migration(migrations.Migration): + + dependencies = [ + ('modeling', '0038_alter_project_layer_overrides'), + ] + + operations = [ + migrations.RunPython(override_sedaadjust_for_old_projects), + ] diff --git a/src/mmw/apps/modeling/views.py b/src/mmw/apps/modeling/views.py index a3657c4a9..ccd94b4cb 100644 --- a/src/mmw/apps/modeling/views.py +++ b/src/mmw/apps/modeling/views.py @@ -455,21 +455,22 @@ def _initiate_subbasin_gwlfe_job_chain(model_input, mapshed_job_uuid, # If we don't chunk, a shape that has 60+ subbasins could take >60sec # to generate a response (and thus timeout) because we'll be waiting to # submit one task for each subbasin. - gwlfe_chunked_group = group(iter([ + gwlfe_chunked_group = group([ tasks.run_subbasin_gwlfe_chunks.s(mapshed_job_uuid, modifications, stream_lengths, inputmod_hash, watershed_id_chunk) .set(link_error=errback) - for watershed_id_chunk in watershed_id_chunks])) + for watershed_id_chunk in watershed_id_chunks]) - post_process = \ - tasks.subbasin_results_to_dict.s().set(link_error=errback) | \ - tasks.run_srat.s(mapshed_job_uuid).set(link_error=errback) | \ - save_job_result.s(job_id, mapshed_job_uuid) + job_chain = ( + gwlfe_chunked_group | + tasks.subbasin_results_to_dict.s().set(link_error=errback) | + tasks.run_srat.s(mapshed_job_uuid).set(link_error=errback) | + save_job_result.s(job_id, mapshed_job_uuid)) - return (gwlfe_chunked_group | post_process).apply_async() + return chain(job_chain).apply_async() @decorators.api_view(['POST']) diff --git a/src/mmw/js/src/modeling/gwlfe/quality/templates/result.html b/src/mmw/js/src/modeling/gwlfe/quality/templates/result.html index bd26bb196..2fbafa291 100644 --- a/src/mmw/js/src/modeling/gwlfe/quality/templates/result.html +++ b/src/mmw/js/src/modeling/gwlfe/quality/templates/result.html @@ -24,7 +24,7 @@
{% if showSubbasinModelingButton %} - View subbasin attentuated results + View subbasin attenuated results {% endif %} diff --git a/src/mmw/mmw/settings/base.py b/src/mmw/mmw/settings/base.py index 455356ed4..566682a3e 100644 --- a/src/mmw/mmw/settings/base.py +++ b/src/mmw/mmw/settings/base.py @@ -130,7 +130,7 @@ def get_env_setting(setting): # The longest running tasks contain geoprocessing requests # Keep the task and request time limit above, but in the ballpark of # https://github.com/WikiWatershed/mmw-geoprocessing/blob/develop/api/src/main/resources/application.conf#L9 -CELERY_TASK_TIME_LIMIT = 90 +CELERY_TASK_TIME_LIMIT = 120 TASK_REQUEST_TIMEOUT = CELERY_TASK_TIME_LIMIT - 10 # END CELERY CONFIGURATION diff --git a/src/mmw/mmw/settings/gwlfe_settings.py b/src/mmw/mmw/settings/gwlfe_settings.py index c99368c1e..675ef876b 100644 --- a/src/mmw/mmw/settings/gwlfe_settings.py +++ b/src/mmw/mmw/settings/gwlfe_settings.py @@ -57,7 +57,7 @@ 'CountyFlag': b.NO, # Flag: County Layer Detected (0 No; 1 Yes) 'SoilPFlag': b.YES, # Flag: Soil P Layer Detected (0 No; 1 Yes) 'GWNFlag': b.YES, # Flag: Groundwater N Layer Detected (0 No; 1 Yes) - 'SedAAdjust': 1.5, # Default Percent ET + 'SedAAdjust': 0.8, # Default Percent ET 'BankNFrac': 0.25, # % Bank N Fraction (0 - 1) 'BankPFrac': 0.25, # % Bank P Fraction (0 - 1) 'ManuredAreas': 2, # Manure Spreading Periods (Default = 2) diff --git a/src/mmw/requirements/development.txt b/src/mmw/requirements/development.txt index c31fbbd8d..bd770fa6a 100644 --- a/src/mmw/requirements/development.txt +++ b/src/mmw/requirements/development.txt @@ -1,5 +1,6 @@ -r base.txt flake8==4.0.1 +jedi==0.17.2 ipython==7.17.0 ipdb==0.13.9