diff --git a/arpav_ppcv/config.py b/arpav_ppcv/config.py index 6a169756..5864df82 100644 --- a/arpav_ppcv/config.py +++ b/arpav_ppcv/config.py @@ -47,7 +47,6 @@ class ThreddsServerSettings(pydantic.BaseModel): base_url: str = "http://localhost:8080/thredds" wms_service_url_fragment: str = "wms" netcdf_subset_service_url_fragment: str = "ncss/grid" # noqa - netcdf_subset_service_timeout_seconds: int = 30 # noqa opendap_service_url_fragment: str = "dodsC" # noqa uncertainty_visualization_scale_range: tuple[float, float] = pydantic.Field( default=(0, 9) @@ -132,6 +131,7 @@ class ArpavPpcvSettings(BaseSettings): # noqa coverage_download_settings: CoverageDownloadSettings = CoverageDownloadSettings() variable_stations_db_schema: str = "stations" num_uvicorn_worker_processes: int = 1 + http_client_timeout_seconds: float = 30.0 @pydantic.model_validator(mode="after") def ensure_test_db_dsn(self): diff --git a/arpav_ppcv/thredds/utils.py b/arpav_ppcv/thredds/utils.py index 6fa72aa2..078c512b 100644 --- a/arpav_ppcv/thredds/utils.py +++ b/arpav_ppcv/thredds/utils.py @@ -58,6 +58,7 @@ def tweak_wms_get_map_request( num_color_bands = "2" query_params["NUMCOLORBANDS"] = num_color_bands else: + num_color_bands = "250" if "uncertainty_group" in layer_name: palette = ncwms_palette else: @@ -75,4 +76,7 @@ def tweak_wms_get_map_request( query_params["styles"] = palette query_params["colorscalerange"] = color_scale_range + query_params["NUMCOLORBANDS"] = num_color_bands + query_params["ABOVEMAXCOLOR"] = "extend" + query_params["BELOWMINCOLOR"] = "extend" return query_params diff --git a/arpav_ppcv/webapp/api_v2/routers/coverages.py b/arpav_ppcv/webapp/api_v2/routers/coverages.py index cce31dc5..673e71b2 100644 --- a/arpav_ppcv/webapp/api_v2/routers/coverages.py +++ b/arpav_ppcv/webapp/api_v2/routers/coverages.py @@ -452,9 +452,6 @@ async def get_forecast_data( fitted_bbox = None cache_key = datadownloads.get_cache_key(coverage, fitted_bbox, temporal_range) - http_client.timeout = ( - settings.thredds_server.netcdf_subset_service_timeout_seconds - ) response_to_stream = await datadownloads.retrieve_coverage_data( settings, http_client, cache_key, coverage, fitted_bbox, temporal_range ) diff --git a/arpav_ppcv/webapp/dependencies.py b/arpav_ppcv/webapp/dependencies.py index 161cf330..209baf84 100644 --- a/arpav_ppcv/webapp/dependencies.py +++ b/arpav_ppcv/webapp/dependencies.py @@ -29,12 +29,16 @@ def get_db_session(engine=Depends(get_db_engine)): # noqa: B008 yield session -def get_http_client() -> httpx.AsyncClient: - return httpx.AsyncClient() +def get_http_client( + settings: config.ArpavPpcvSettings = Depends(get_settings), +) -> httpx.AsyncClient: + return httpx.AsyncClient(timeout=settings.http_client_timeout_seconds) -def get_sync_http_client() -> httpx.Client: - return httpx.Client() +def get_sync_http_client( + settings: config.ArpavPpcvSettings = Depends(get_settings), +) -> httpx.Client: + return httpx.Client(timeout=settings.http_client_timeout_seconds) class CommonListFilterParameters(pydantic.BaseModel): # noqa: D101