GEO-BON / bon-in-a-box-pipeline-engine

Pipeline engine that can run R, Julia, Python and shell scripts seamlessly.
GNU General Public License v3.0
3 stars 1 forks source link

Fix viewer #116

Closed glaroc closed 2 months ago

jmlord commented 2 months ago

Je ne suis pas capable de visualiser la couche "density of gbif occurences" dans le viewer.

500 internal server error dans :

http://localhost/tiler/cog/statistics?expression=b1*(b1%3E0)&url=%2Foutput%2Fdata%2FheatmapFromSTAC%2F8f27847fa76fed8fdfda0a3e5b3509e0%2FheatmapGBIF-reptiles.tif

Logs:

biab-tiler          | 172.18.0.9:43964 - "GET /cog/bounds?url=%2Foutput%2Fdata%2FheatmapFromSTAC%2F8f27847fa76fed8fdfda0a3e5b3509e0%2FheatmapGBIF-reptiles.tif HTTP/1.0" 200
http-rev-prox       | 172.18.0.1 - - [30/Aug/2024:17:02:49 +0000] "GET /tiler/cog/bounds?url=%2Foutput%2Fdata%2FheatmapFromSTAC%2F8f27847fa76fed8fdfda0a3e5b3509e0%2FheatmapGBIF-reptiles.tif HTTP/1.1" 200 95 "http://localhost/viewer/SDM%3ESDM_maxEnt%3Ec3d3b7c126ac7c1badd6ffdd1d3a3852" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36" "-"
biab-tiler          | 172.18.0.9:43960 - "GET /cog/statistics?expression=b1*(b1%3E0)&url=%2Foutput%2Fdata%2FheatmapFromSTAC%2F8f27847fa76fed8fdfda0a3e5b3509e0%2FheatmapGBIF-reptiles.tif HTTP/1.0" 500
biab-tiler          | [2024-08-30 17:02:49 +0000] [7] [ERROR] Exception in ASGI application
biab-tiler          | Traceback (most recent call last):
biab-tiler          |   File "/opt/bitnami/python/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 412, in run_asgi
biab-tiler          |     result = await app(  # type: ignore[func-returns-value]
biab-tiler          |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
biab-tiler          |   File "/opt/bitnami/python/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 69, in __call__
biab-tiler          |     return await self.app(scope, receive, send)
biab-tiler          |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
http-rev-prox       | 172.18.0.1 - - [30/Aug/2024:17:02:49 +0000] "GET /tiler/cog/statistics?expression=b1*(b1%3E0)&url=%2Foutput%2Fdata%2FheatmapFromSTAC%2F8f27847fa76fed8fdfda0a3e5b3509e0%2FheatmapGBIF-reptiles.tif HTTP/1.1" 500 53 "http://localhost/viewer/SDM%3ESDM_maxEnt%3Ec3d3b7c126ac7c1badd6ffdd1d3a3852" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36" "-"
biab-tiler          |   File "/opt/bitnami/python/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in __call__
biab-tiler          |     await super().__call__(scope, receive, send)
biab-tiler          |   File "/opt/bitnami/python/lib/python3.11/site-packages/starlette/applications.py", line 123, in __call__
biab-tiler          |     await self.middleware_stack(scope, receive, send)
biab-tiler          |   File "/opt/bitnami/python/lib/python3.11/site-packages/starlette/middleware/errors.py", line 186, in __call__
biab-tiler          |     raise exc
biab-tiler          |   File "/opt/bitnami/python/lib/python3.11/site-packages/starlette/middleware/errors.py", line 164, in __call__
biab-tiler          |     await self.app(scope, receive, _send)
biab-tiler          |   File "/opt/bitnami/python/lib/python3.11/site-packages/titiler/core/middleware.py", line 63, in __call__
biab-tiler          |     await self.app(scope, receive, send_wrapper)
biab-tiler          |   File "/opt/bitnami/python/lib/python3.11/site-packages/starlette_cramjam/middleware.py", line 112, in __call__
biab-tiler          |     await responder(scope, receive, send)
biab-tiler          |   File "/opt/bitnami/python/lib/python3.11/site-packages/starlette_cramjam/middleware.py", line 142, in __call__
biab-tiler          |     await self.app(scope, receive, self.send_with_compression)
biab-tiler          |   File "/opt/bitnami/python/lib/python3.11/site-packages/starlette/middleware/cors.py", line 85, in __call__
biab-tiler          |     await self.app(scope, receive, send)
biab-tiler          |   File "/opt/bitnami/python/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 65, in __call__
biab-tiler          |     await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
biab-tiler          |   File "/opt/bitnami/python/lib/python3.11/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
biab-tiler          |     raise exc
biab-tiler          |   File "/opt/bitnami/python/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
biab-tiler          |     await app(scope, receive, sender)
biab-tiler          |   File "/opt/bitnami/python/lib/python3.11/site-packages/starlette/routing.py", line 754, in __call__
biab-tiler          |     await self.middleware_stack(scope, receive, send)
biab-tiler          |   File "/opt/bitnami/python/lib/python3.11/site-packages/starlette/routing.py", line 774, in app
biab-tiler          |     await route.handle(scope, receive, send)
biab-tiler          |   File "/opt/bitnami/python/lib/python3.11/site-packages/starlette/routing.py", line 295, in handle
biab-tiler          |     await self.app(scope, receive, send)
biab-tiler          |   File "/opt/bitnami/python/lib/python3.11/site-packages/starlette/routing.py", line 77, in app
biab-tiler          |     await wrap_app_handling_exceptions(app, request)(scope, receive, send)
biab-tiler          |   File "/opt/bitnami/python/lib/python3.11/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
biab-tiler          |     raise exc
biab-tiler          |   File "/opt/bitnami/python/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
biab-tiler          |     await app(scope, receive, sender)
biab-tiler          |   File "/opt/bitnami/python/lib/python3.11/site-packages/starlette/routing.py", line 74, in app
biab-tiler          |     response = await f(request)
biab-tiler          |                ^^^^^^^^^^^^^^^^
biab-tiler          |   File "/opt/bitnami/python/lib/python3.11/site-packages/fastapi/routing.py", line 297, in app
biab-tiler          |     raw_response = await run_endpoint_function(
biab-tiler          |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
biab-tiler          |   File "/opt/bitnami/python/lib/python3.11/site-packages/fastapi/routing.py", line 212, in run_endpoint_function
biab-tiler          |     return await run_in_threadpool(dependant.call, **values)
biab-tiler          |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
biab-tiler          |   File "/opt/bitnami/python/lib/python3.11/site-packages/starlette/concurrency.py", line 42, in run_in_threadpool
biab-tiler          |     return await anyio.to_thread.run_sync(func, *args)
biab-tiler          |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
biab-tiler          |   File "/opt/bitnami/python/lib/python3.11/site-packages/anyio/to_thread.py", line 56, in run_sync
biab-tiler          |     return await get_async_backend().run_sync_in_worker_thread(
biab-tiler          |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
biab-tiler          |   File "/opt/bitnami/python/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 2144, in run_sync_in_worker_thread
biab-tiler          |     return await future
biab-tiler          |            ^^^^^^^^^^^^
biab-tiler          |   File "/opt/bitnami/python/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 851, in run
biab-tiler          |     result = context.run(func, *args)
biab-tiler          |              ^^^^^^^^^^^^^^^^^^^^^^^^
biab-tiler          |   File "/opt/bitnami/python/lib/python3.11/site-packages/titiler/core/factory.py", line 453, in statistics
biab-tiler          |     return image.statistics(
biab-tiler          |            ^^^^^^^^^^^^^^^^^
biab-tiler          |   File "/opt/bitnami/python/lib/python3.11/site-packages/rio_tiler/models.py", line 776, in statistics
biab-tiler          |     stats = get_array_statistics(
biab-tiler          |             ^^^^^^^^^^^^^^^^^^^^^
biab-tiler          |   File "/opt/bitnami/python/lib/python3.11/site-packages/rio_tiler/utils.py", line 191, in get_array_statistics
biab-tiler          |     "std": _weighted_stdev(data_comp, masked_coverage.compressed()),
biab-tiler          |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
biab-tiler          |   File "/opt/bitnami/python/lib/python3.11/site-packages/rio_tiler/utils.py", line 52, in _weighted_stdev
biab-tiler          |     average = numpy.average(values, weights=weights)
biab-tiler          |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
biab-tiler          |   File "/opt/bitnami/python/lib/python3.11/site-packages/numpy/lib/_function_base_impl.py", line 575, in average
biab-tiler          |     raise ZeroDivisionError(
biab-tiler          | ZeroDivisionError: Weights sum to zero, can't be normalized
jmlord commented 2 months ago

Above error is due to file not being a COG, but a regular tiff.

We should detect this and show a more elegant error, or make sure none go past review.

jmlord commented 2 months ago

closes #115