Skip to content

Commit

Permalink
fix: extract metadata fetching
Browse files Browse the repository at this point in the history
Fix bug causing duplication of extract metadata when working with multiple data sources.
  • Loading branch information
kennedykori committed Sep 20, 2022
1 parent 5ef21ec commit 0f5f824
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/lib/transports/http/api_v1_dialect.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def fetch_data_source_extracts(
) -> HTTPRequestParams:
return {
"headers": {"Accept": "application/json"},
"params": {"data_source": data_source.id},
"expected_http_status_code": 200,
"method": _GET_METHOD,
"url": "%s/%s/sql_extract_metadata/"
Expand Down
19 changes: 17 additions & 2 deletions app/lib/transports/http/http_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@
_LOGGER = logging.getLogger(__name__)


# =============================================================================
# HELPER TASKS
# =============================================================================


def _log_response(
response: Response, *args, **kwargs
) -> None: # pragma: no cover
request_message: str = "HTTP Request ({} | {})".format(
response.request.method,
response.request.url,
)
_LOGGER.debug(request_message)


# =============================================================================
# HTTP TRANSPORT
# =============================================================================
Expand Down Expand Up @@ -71,6 +86,7 @@ def __init__(
"User-Agent": f"{__title__}/{__version__}",
}
)
self._session.hooks["response"].append(_log_response)
self._auth: AuthBase = _NoAuth()
self._is_closed: bool = False

Expand Down Expand Up @@ -190,7 +206,7 @@ def post_upload_metadata(
# -------------------------------------------------------------------------
def _authenticate(self) -> AuthBase:
self._ensure_not_closed()
_LOGGER.info("Authenticating HTTP transport.")
_LOGGER.debug("Authenticating HTTP transport.")
request: HTTPRequestParams = self._api_dialect.authenticate()
response: Response = self._session.request(
data=request.get("data"),
Expand Down Expand Up @@ -226,7 +242,6 @@ def _make_request(self, request: HTTPRequestParams) -> Response:
request["method"],
request["url"],
)
_LOGGER.info(request_message)
response: Response = self._session.request(
data=request.get("data"),
files=request.get("files"),
Expand Down

0 comments on commit 0f5f824

Please sign in to comment.