Skip to content
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

Tweak WMS query parameters and timeouts #312

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: 1 addition & 1 deletion arpav_ppcv/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down
4 changes: 4 additions & 0 deletions arpav_ppcv/thredds/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
3 changes: 0 additions & 3 deletions arpav_ppcv/webapp/api_v2/routers/coverages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
12 changes: 8 additions & 4 deletions arpav_ppcv/webapp/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down