Skip to content

Commit 2c83682

Browse files
Merge pull request #1179 from gooddata/snapshot-master-a602d64d-to-rel/dev
[bot] Merge master/a602d64d into rel/dev
2 parents b8cfb65 + a602d64 commit 2c83682

File tree

3 files changed

+40
-11
lines changed

3 files changed

+40
-11
lines changed

gooddata-sdk/gooddata_sdk/compute/model/execution.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,12 @@ def dimensions(self) -> Any:
334334
def cancel_token(self) -> Optional[str]:
335335
return self._cancel_token
336336

337-
def read_result(self, limit: Union[int, list[int]], offset: Union[None, int, list[int]] = None) -> ExecutionResult:
337+
def read_result(
338+
self,
339+
limit: Union[int, list[int]],
340+
offset: Union[None, int, list[int]] = None,
341+
timeout: Optional[Union[int, float, tuple]] = None,
342+
) -> ExecutionResult:
338343
"""
339344
Reads from the execution result.
340345
"""
@@ -353,6 +358,7 @@ def read_result(self, limit: Union[int, list[int]], offset: Union[None, int, lis
353358
limit=_limit,
354359
_check_return_type=False,
355360
_return_http_data_only=False,
361+
_request_timeout=timeout,
356362
**({"x_gdc_cancel_token": self.cancel_token} if self.cancel_token else {}),
357363
)
358364
custom_headers = self._api_client.custom_headers
@@ -450,8 +456,13 @@ def get_labels_and_formats(self) -> tuple[dict[str, str], dict[str, str]]:
450456
formats[m_group["localIdentifier"]] = m_group["format"]
451457
return labels, formats
452458

453-
def read_result(self, limit: Union[int, list[int]], offset: Union[None, int, list[int]] = None) -> ExecutionResult:
454-
return self.bare_exec_response.read_result(limit, offset)
459+
def read_result(
460+
self,
461+
limit: Union[int, list[int]],
462+
offset: Union[None, int, list[int]] = None,
463+
timeout: Optional[Union[int, float, tuple]] = None,
464+
) -> ExecutionResult:
465+
return self.bare_exec_response.read_result(limit, offset, timeout)
455466

456467
def cancel(self) -> None:
457468
"""

gooddata-sdk/gooddata_sdk/compute/service.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import json
55
import logging
66
from collections.abc import Iterator
7-
from typing import Any, Optional
7+
from typing import Any, Optional, Union
88

99
from gooddata_api_client import ApiException
1010
from gooddata_api_client.model.afm_cancel_tokens import AfmCancelTokens
@@ -40,17 +40,27 @@ def __init__(self, api_client: GoodDataApiClient):
4040
self._actions_api = self._api_client.actions_api
4141
self._entities_api = self._api_client.entities_api
4242

43-
def for_exec_def(self, workspace_id: str, exec_def: ExecutionDefinition) -> Execution:
43+
def for_exec_def(
44+
self,
45+
workspace_id: str,
46+
exec_def: ExecutionDefinition,
47+
timeout: Optional[Union[int, float, tuple]] = None,
48+
) -> Execution:
4449
"""
4550
Starts computation in GoodData.CN workspace, using the provided execution definition.
4651
4752
Args:
4853
workspace_id: workspace identifier
4954
exec_def: execution definition - this prescribes what to calculate, how to place labels and metric values
55+
timeout: request timeout in seconds. If a tuple is provided, it is used as (connection timeout, read timeout).
5056
into dimensions
5157
"""
5258
response, _, headers = self._actions_api.compute_report(
53-
workspace_id, exec_def.as_api_model(), _check_return_type=False, _return_http_data_only=False
59+
workspace_id,
60+
exec_def.as_api_model(),
61+
_check_return_type=False,
62+
_return_http_data_only=False,
63+
_request_timeout=timeout,
5464
)
5565

5666
return Execution(

gooddata-sdk/gooddata_sdk/table.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,11 @@ def _prepare_tabular_definition(
240240
return ExecutionDefinition(attributes=attributes, metrics=metrics, filters=filters, dimensions=dims)
241241

242242

243-
def _as_table(response: ExecutionResponse, always_two_dimensional: bool = False) -> ExecutionTable:
243+
def _as_table(
244+
response: ExecutionResponse,
245+
always_two_dimensional: bool = False,
246+
timeout: Optional[Union[int, float, tuple]] = None,
247+
) -> ExecutionTable:
244248
first_page_offset = [0, 0]
245249
first_page_limit = [_TABLE_ROW_BATCH_SIZE, _MAX_METRICS]
246250

@@ -256,7 +260,7 @@ def _as_table(response: ExecutionResponse, always_two_dimensional: bool = False)
256260
first_page_limit = [first_page_limit[0]]
257261
first_page_offset = [0]
258262

259-
first_page = response.read_result(offset=first_page_offset, limit=first_page_limit)
263+
first_page = response.read_result(offset=first_page_offset, limit=first_page_limit, timeout=timeout)
260264

261265
return ExecutionTable(response=response, first_page=first_page)
262266

@@ -793,7 +797,11 @@ def for_visualization(
793797
return _as_table(response, always_two_dimensional)
794798

795799
def for_items(
796-
self, workspace_id: str, items: list[Union[Attribute, Metric]], filters: Optional[list[Filter]] = None
800+
self,
801+
workspace_id: str,
802+
items: list[Union[Attribute, Metric]],
803+
filters: Optional[list[Filter]] = None,
804+
timeout: Optional[Union[int, float, tuple]] = None,
797805
) -> ExecutionTable:
798806
if filters is None:
799807
filters = []
@@ -810,6 +818,6 @@ def for_items(
810818
raise ValueError(f"Invalid input item: {item}. Expecting instance of Attribute or Metric")
811819

812820
exec_def = _prepare_tabular_definition(attributes=attributes, metrics=metrics, filters=filters)
813-
response = self._compute.for_exec_def(workspace_id=workspace_id, exec_def=exec_def)
821+
response = self._compute.for_exec_def(workspace_id=workspace_id, exec_def=exec_def, timeout=timeout)
814822

815-
return _as_table(response)
823+
return _as_table(response, timeout=timeout)

0 commit comments

Comments
 (0)