Skip to content

Commit a60c5a6

Browse files
committed
feat: add support for cancel api
jira: cq-1123 risk: low
1 parent ce27f75 commit a60c5a6

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

gooddata-sdk/gooddata_sdk/compute/service.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import logging
55

6+
from gooddata_api_client.model.afm_cancel_tokens import AfmCancelTokens
67
from gooddata_api_client.model.chat_history_request import ChatHistoryRequest
78
from gooddata_api_client.model.chat_history_result import ChatHistoryResult
89
from gooddata_api_client.model.chat_request import ChatRequest
@@ -108,3 +109,24 @@ def ai_chat_history_reset(self, workspace_id: str) -> None:
108109
"""
109110
chat_history_request = ChatHistoryRequest(reset=True)
110111
self._actions_api.ai_chat_history(workspace_id, chat_history_request, _check_return_type=False)
112+
113+
def cancel_executions(self, executions: list[Execution]) -> None:
114+
"""
115+
Try to cancel given executions using the cancel api endpoint.
116+
117+
*Note that this is currently a noop, we will be enabling this functionality soon.*
118+
119+
Args:
120+
executions: list of executions to send for cancellation
121+
"""
122+
workspace_to_tokens: dict[str, set[str]] = {}
123+
124+
for execution in executions:
125+
if not workspace_to_tokens[execution.workspace_id]:
126+
workspace_to_tokens[execution.workspace_id] = set()
127+
128+
if execution.cancel_token:
129+
workspace_to_tokens[execution.workspace_id].add(execution.cancel_token)
130+
131+
for workspace_id, token_ids in workspace_to_tokens.items():
132+
self._actions_api.cancel_executions(workspace_id, AfmCancelTokens(list(token_ids)))

0 commit comments

Comments
 (0)