Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion gooddata-sdk/gooddata_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@
from gooddata_sdk.compute.model.base import ExecModelEntity, ObjId
from gooddata_sdk.compute.model.execution import (
BareExecutionResponse,
Execution,
ExecutionDefinition,
ExecutionResponse,
ExecutionResult,
Expand Down
20 changes: 12 additions & 8 deletions gooddata-sdk/gooddata_sdk/compute/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,16 @@ def for_exec_def(self, workspace_id: str, exec_def: ExecutionDefinition) -> Exec
exec_def: execution definition - this prescribes what to calculate, how to place labels and metric values
into dimensions
"""
response = self._actions_api.compute_report(workspace_id, exec_def.as_api_model(), _check_return_type=False)
response, _, headers = self._actions_api.compute_report(
workspace_id, exec_def.as_api_model(), _check_return_type=False, _return_http_data_only=False
)

return Execution(
api_client=self._api_client,
workspace_id=workspace_id,
exec_def=exec_def,
response=response,
cancel_token=response.headers.get("X-GDC-CANCEL-TOKEN")
cancel_token=headers.get("X-Gdc-Cancel-Token")
if exec_def.is_cancellable or self._api_client.executions_cancellable
else None,
)
Expand Down Expand Up @@ -112,23 +114,25 @@ def ai_chat_history_reset(self, workspace_id: str) -> None:
chat_history_request = ChatHistoryRequest(reset=True)
self._actions_api.ai_chat_history(workspace_id, chat_history_request, _check_return_type=False)

def cancel_executions(self, executions: list[Execution]) -> None:
def cancel_executions(self, executions: list[tuple[str, str]]) -> None:
"""
Try to cancel given executions using the cancel api endpoint.
Order of token applications is not guaranteed.

*Note that this is currently a noop, we will be enabling this functionality soon.*

Args:
executions: list of executions to send for cancellation
executions: list of tuples [workspace_id, cancel_token] to send for cancellation
"""
workspace_to_tokens: dict[str, set[str]] = {}

for execution in executions:
if not workspace_to_tokens[execution.workspace_id]:
workspace_to_tokens[execution.workspace_id] = set()
workspace_id, cancel_token = execution

if workspace_id not in workspace_to_tokens:
workspace_to_tokens[workspace_id] = set()

if execution.cancel_token:
workspace_to_tokens[execution.workspace_id].add(execution.cancel_token)
workspace_to_tokens[workspace_id].add(cancel_token)

for workspace_id, token_ids in workspace_to_tokens.items():
self._actions_api.cancel_executions(workspace_id, AfmCancelTokens(list(token_ids)))
Loading