Skip to content

Commit 8ddcb33

Browse files
authored
PY-321 Add requested URL to the retry exception (#205)
1 parent fea6db3 commit 8ddcb33

24 files changed

+31
-1
lines changed

src/neptune_api_codegen/docker/rofiles/templates/endpoint_module.py.jinja

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt
111111

112112
def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[{{ return_string }}]:
113113
return Response(
114+
url=str(response.url),
114115
status_code=HTTPStatus(response.status_code),
115116
content=response.content,
116117
headers=response.headers,

src/neptune_api_codegen/docker/rofiles/templates/types.py.jinja

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ T = TypeVar("T")
7979
class Response(Generic[T]):
8080
""" A response from an endpoint """
8181

82+
url: str
8283
status_code: HTTPStatus
8384
content: bytes
8485
headers: MutableMapping[str, str]

src/neptune_query/exceptions.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,12 @@ def __init__(self, status_code: int, content: bytes) -> None:
199199

200200
class NeptuneRetryError(NeptuneError):
201201
def __init__(
202-
self, retries: int, time: float, last_status_code: Optional[int] = None, last_content: Optional[bytes] = None
202+
self,
203+
retries: int,
204+
time: float,
205+
last_status_code: Optional[int] = None,
206+
last_content: Optional[bytes] = None,
207+
url: Optional[str] = None,
203208
) -> None:
204209
content_str = _decode_content(last_content) if last_content else ""
205210
super().__init__(
@@ -216,11 +221,13 @@ def __init__(
216221
https://docs.neptune.ai/environment_variables/neptune_query#neptune_query_retry_soft_timeout
217222
https://docs.neptune.ai/environment_variables/neptune_query#neptune_query_retry_hard_timeout
218223
224+
{url_line}
219225
{status_code_line}
220226
{content_line}
221227
""",
222228
retries=retries,
223229
time=time,
230+
url_line=f"Requested URL: {url}" if url is not None else "",
224231
status_code_line=f"Last response status: {last_status_code}" if last_status_code is not None else "",
225232
content_line=f"Last response content: {content_str}" if last_content is not None else "",
226233
soft_limit=env.NEPTUNE_QUERY_RETRY_SOFT_TIMEOUT.get(),

src/neptune_query/generated/neptune_api/api/backend/exchange_api_token.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ def _build_response(
9090
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
9191
) -> Response[Union[Any, Error, NeptuneOauthToken]]:
9292
return Response(
93+
url=str(response.url),
9394
status_code=HTTPStatus(response.status_code),
9495
content=response.content,
9596
headers=response.headers,

src/neptune_query/generated/neptune_api/api/backend/get_client_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ def _build_response(
103103
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
104104
) -> Response[Union[Any, ClientConfig, Error]]:
105105
return Response(
106+
url=str(response.url),
106107
status_code=HTTPStatus(response.status_code),
107108
content=response.content,
108109
headers=response.headers,

src/neptune_query/generated/neptune_api/api/backend/get_project.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def _build_response(
9696
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
9797
) -> Response[Union[Any, Error, ProjectDTO]]:
9898
return Response(
99+
url=str(response.url),
99100
status_code=HTTPStatus(response.status_code),
100101
content=response.content,
101102
headers=response.headers,

src/neptune_query/generated/neptune_api/api/ingestion/bulk_check_status.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def _build_response(
104104
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
105105
) -> Response[Union[Any, File]]:
106106
return Response(
107+
url=str(response.url),
107108
status_code=HTTPStatus(response.status_code),
108109
content=response.content,
109110
headers=response.headers,

src/neptune_query/generated/neptune_api/api/ingestion/check_details.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def _build_response(
104104
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
105105
) -> Response[Union[Any, File]]:
106106
return Response(
107+
url=str(response.url),
107108
status_code=HTTPStatus(response.status_code),
108109
content=response.content,
109110
headers=response.headers,

src/neptune_query/generated/neptune_api/api/ingestion/check_status.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ def _build_response(
108108
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
109109
) -> Response[Union[Any, File]]:
110110
return Response(
111+
url=str(response.url),
111112
status_code=HTTPStatus(response.status_code),
112113
content=response.content,
113114
headers=response.headers,

src/neptune_query/generated/neptune_api/api/ingestion/ingest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def _build_response(
9595
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
9696
) -> Response[Union[Any, File]]:
9797
return Response(
98+
url=str(response.url),
9899
status_code=HTTPStatus(response.status_code),
99100
content=response.content,
100101
headers=response.headers,

0 commit comments

Comments
 (0)