Skip to content

Commit 726abe3

Browse files
committed
fix(gooddata-sdk): cancel_executions input
risk: low
1 parent 616e312 commit 726abe3

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

gooddata-sdk/gooddata_sdk/compute/service.py

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

44
import logging
55

6+
from gooddata_api_client import ApiException
67
from gooddata_api_client.model.afm_cancel_tokens import AfmCancelTokens
78
from gooddata_api_client.model.chat_history_request import ChatHistoryRequest
89
from gooddata_api_client.model.chat_history_result import ChatHistoryResult
@@ -114,25 +115,20 @@ def ai_chat_history_reset(self, workspace_id: str) -> None:
114115
chat_history_request = ChatHistoryRequest(reset=True)
115116
self._actions_api.ai_chat_history(workspace_id, chat_history_request, _check_return_type=False)
116117

117-
def cancel_executions(self, executions: list[tuple[str, str]]) -> None:
118+
def cancel_executions(self, executions: dict[str, dict[str, str]]) -> None:
118119
"""
119120
Try to cancel given executions using the cancel api endpoint.
120121
Order of token applications is not guaranteed.
121122
122123
*Note that this is currently a noop, we will be enabling this functionality soon.*
123124
124125
Args:
125-
executions: list of tuples [workspace_id, cancel_token] to send for cancellation
126+
executions: maps workspace_id |-> result_id_to_cancel_token_pairs
126127
"""
127-
workspace_to_tokens: dict[str, set[str]] = {}
128-
129-
for execution in executions:
130-
workspace_id, cancel_token = execution
131-
132-
if workspace_id not in workspace_to_tokens:
133-
workspace_to_tokens[workspace_id] = set()
134-
135-
workspace_to_tokens[workspace_id].add(cancel_token)
136-
137-
for workspace_id, token_ids in workspace_to_tokens.items():
138-
self._actions_api.cancel_executions(workspace_id, AfmCancelTokens(list(token_ids)))
128+
try:
129+
for workspace_id, cancel_tokens in executions.items():
130+
self._actions_api.cancel_executions(
131+
workspace_id, AfmCancelTokens(result_id_to_cancel_token_pairs=cancel_tokens)
132+
)
133+
except ApiException as e:
134+
print("Exception when calling ActionsApi->cancel_executions: %s\n", e)

0 commit comments

Comments
 (0)