NASA-IMPACT / covid-api

MIT License
14 stars 3 forks source link

Error fetching background Planet tiles #75

Closed leothomas closed 4 years ago

leothomas commented 4 years ago

GET http://localhost:8000/v1/planet/13/7276/3229?date=2020_05_17&site=tk fails with:

Traceback (most recent call last):
  File "/Users/leo/.pyenv/versions/3.8.3/lib/python3.8/site-packages/uvicorn/protocols/http/httptools_impl.py", line 386, in run_asgi
    result = await app(self.scope, self.receive, self.send)
  File "/Users/leo/.pyenv/versions/3.8.3/lib/python3.8/site-packages/uvicorn/middleware/proxy_headers.py", line 45, in __call__
    return await self.app(scope, receive, send)
  File "/Users/leo/.pyenv/versions/3.8.3/lib/python3.8/site-packages/fastapi/applications.py", line 181, in __call__
    await super().__call__(scope, receive, send)
  File "/Users/leo/.pyenv/versions/3.8.3/lib/python3.8/site-packages/starlette/applications.py", line 102, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/Users/leo/.pyenv/versions/3.8.3/lib/python3.8/site-packages/starlette/middleware/errors.py", line 181, in __call__
    raise exc from None
  File "/Users/leo/.pyenv/versions/3.8.3/lib/python3.8/site-packages/starlette/middleware/errors.py", line 159, in __call__
    await self.app(scope, receive, _send)
  File "/Users/leo/.pyenv/versions/3.8.3/lib/python3.8/site-packages/starlette/middleware/base.py", line 25, in __call__
    response = await self.dispatch_func(request, self.call_next)
  File "./covid_api/main.py", line 58, in cache_middleware
    response = await call_next(request)
  File "/Users/leo/.pyenv/versions/3.8.3/lib/python3.8/site-packages/starlette/middleware/base.py", line 45, in call_next
    task.result()
  File "/Users/leo/.pyenv/versions/3.8.3/lib/python3.8/site-packages/starlette/middleware/base.py", line 38, in coro
    await self.app(scope, receive, send)
  File "/Users/leo/.pyenv/versions/3.8.3/lib/python3.8/site-packages/starlette/middleware/gzip.py", line 18, in __call__
    await responder(scope, receive, send)
  File "/Users/leo/.pyenv/versions/3.8.3/lib/python3.8/site-packages/starlette/middleware/gzip.py", line 35, in __call__
    await self.app(scope, receive, self.send_with_gzip)
  File "/Users/leo/.pyenv/versions/3.8.3/lib/python3.8/site-packages/starlette/middleware/cors.py", line 86, in __call__
    await self.simple_response(scope, receive, send, request_headers=headers)
  File "/Users/leo/.pyenv/versions/3.8.3/lib/python3.8/site-packages/starlette/middleware/cors.py", line 142, in simple_response
    await self.app(scope, receive, send)
  File "/Users/leo/.pyenv/versions/3.8.3/lib/python3.8/site-packages/starlette/exceptions.py", line 82, in __call__
    raise exc from None
  File "/Users/leo/.pyenv/versions/3.8.3/lib/python3.8/site-packages/starlette/exceptions.py", line 71, in __call__
    await self.app(scope, receive, sender)
  File "/Users/leo/.pyenv/versions/3.8.3/lib/python3.8/site-packages/starlette/routing.py", line 550, in __call__
    await route.handle(scope, receive, send)
  File "/Users/leo/.pyenv/versions/3.8.3/lib/python3.8/site-packages/starlette/routing.py", line 227, in handle
    await self.app(scope, receive, send)
  File "/Users/leo/.pyenv/versions/3.8.3/lib/python3.8/site-packages/starlette/routing.py", line 41, in app
    response = await func(request)
  File "/Users/leo/.pyenv/versions/3.8.3/lib/python3.8/site-packages/fastapi/routing.py", line 196, in app
    raw_response = await run_endpoint_function(
  File "/Users/leo/.pyenv/versions/3.8.3/lib/python3.8/site-packages/fastapi/routing.py", line 147, in run_endpoint_function
    return await dependant.call(**values)
  File "./covid_api/api/api_v1/endpoints/planet.py", line 66, in tile
    tile, mask = await _tile(scenes, x, y, z)
  File "/Users/leo/.pyenv/versions/3.8.3/lib/python3.8/site-packages/starlette/concurrency.py", line 34, in run_in_threadpool
    return await loop.run_in_executor(None, func, *args)
  File "/Users/leo/.pyenv/versions/3.8.3/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "./covid_api/api/utils.py", line 701, in planet_mosaic_tile
    with memfile.open() as src:
  File "/Users/leo/.pyenv/versions/3.8.3/lib/python3.8/site-packages/rasterio/env.py", line 382, in wrapper
    return f(*args, **kwds)
  File "/Users/leo/.pyenv/versions/3.8.3/lib/python3.8/site-packages/rasterio/io.py", line 130, in open
    return DatasetReader(mempath, driver=driver, sharing=sharing, **kwargs)
  File "rasterio/_base.pyx", line 218, in rasterio._base.DatasetBase.__init__
rasterio.errors.RasterioIOError: '/vsimem/2912284a-6282-4b72-bfb8-2c4b2782c0c0/2912284a-6282-4b72-bfb8-2c4b2782c0c0.' not recognized as a supported file format.

in the API.

drewbo commented 4 years ago

@leothomas is this off of current develop? I see a returned image

leothomas commented 4 years ago

Yeah I'm getting this with the develop branch of the API and the dashboard both running locally - could it be that the image is cached and returned from the API running in AWS but the logic to fetch the image if the cache is empty (as is the case locally) is failing?

drewbo commented 4 years ago

I see the image returned against the API running locally only (no cache). Just hitting http://localhost:8000/v1/planet/13/7276/3229?date=2020_05_17&site=tk in the browser, running the api with docker-compose up --build (can compare .env if you ping me directly)

leothomas commented 4 years ago

I'm running the API with: uvicorn covid_api.main:app --reload, is that the problem?

leothomas commented 4 years ago

Issue was resolved by updating Planet API Key