Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ividito committed Oct 24, 2022
1 parent 6b7422f commit 142b5d0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 32 deletions.
43 changes: 22 additions & 21 deletions .github/workflows/tests/test_raster.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""test delta-backend.raster."""

import httpx
import json

import httpx

raster_endpoint = "http://0.0.0.0:8082"


Expand Down Expand Up @@ -52,32 +53,32 @@ def test_mosaic_api():
assert "content-encoding" not in resp.headers

stats_body = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"coordinates": [
[
[-85.6501, 36.1751],
[-85.6501, 36.1499],
[-85.6249, 36.1499],
[-85.6249, 36.1751],
[-85.6501, 36.1751]
]
],
"type": "Polygon"
}
}
]
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"coordinates": [
[
[-85.6501, 36.1751],
[-85.6501, 36.1499],
[-85.6249, 36.1499],
[-85.6249, 36.1751],
[-85.6501, 36.1751],
]
],
"type": "Polygon",
},
}
],
}

resp = httpx.post(
f"{raster_endpoint}/mosaic/{searchid}/statistics",
json=stats_body,
params={"assets": "cog"},
timeout=None # this response is slowwww
timeout=None, # this response is slowwww
)
assert resp.status_code == 200
assert resp.headers["content-type"] == "application/geo+json"
Expand Down
2 changes: 1 addition & 1 deletion raster_api/infrastructure/construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(
timeout=Duration.seconds(delta_raster_settings.timeout),
log_retention=aws_logs.RetentionDays.ONE_WEEK,
environment=delta_raster_settings.env or {},
tracing=aws_lambda.Tracing.ACTIVE
tracing=aws_lambda.Tracing.ACTIVE,
)

database.pgstac.secret.grant_read(delta_raster_function)
Expand Down
16 changes: 6 additions & 10 deletions raster_api/runtime/src/app.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
"""TiTiler+PgSTAC FastAPI application."""
import logging

import botocore # noqa: F401 - need import for xray patch_all()
from aws_xray_sdk.core import patch_all, xray_recorder
from rio_cogeo.cogeo import cog_info as rio_cogeo_info
from rio_cogeo.models import Info
from src.config import ApiSettings
from src.datasetparams import DatasetParams
from src.factory import MosaicTilerFactory, MultiBaseTilerFactory
from src.version import __version__ as delta_raster_version
from xraysink.asgi.middleware import xray_middleware

from fastapi import Depends, FastAPI, Query
from starlette.middleware.base import BaseHTTPMiddleware
Expand All @@ -24,11 +27,6 @@
from titiler.pgstac.db import close_db_connection, connect_to_db
from titiler.pgstac.dependencies import ItemPathParams
from titiler.pgstac.reader import PgSTACReader
from aws_xray_sdk.core import patch_all, xray_recorder
from xraysink.asgi.middleware import xray_middleware

import botocore


logging.getLogger("botocore.credentials").disabled = True
logging.getLogger("botocore.utils").disabled = True
Expand All @@ -37,14 +35,12 @@
settings = ApiSettings()




if settings.debug:
optional_headers = [OptionalHeader.server_timing, OptionalHeader.x_assets]
else:
optional_headers = []

if settings.enable_xray: # xray config that must be performed before app init
if settings.enable_xray: # xray config that must be performed before app init
xray_recorder.configure(service="veda-raster-api")
patch_all()

Expand All @@ -53,8 +49,8 @@
add_exception_handlers(app, DEFAULT_STATUS_CODES)
add_exception_handlers(app, MOSAIC_STATUS_CODES)

if settings.enable_xray: # xray config that must be performed after app init
app.add_middleware(BaseHTTPMiddleware, dispatch=xray_middleware)
if settings.enable_xray: # xray config that must be performed after app init
app.add_middleware(BaseHTTPMiddleware, dispatch=xray_middleware)


# Custom PgSTAC mosaic tiler
Expand Down

0 comments on commit 142b5d0

Please sign in to comment.