|
3 | 3 |
|
4 | 4 | import logging |
5 | 5 |
|
| 6 | +from gooddata_api_client import ApiException |
6 | 7 | from gooddata_api_client.model.afm_cancel_tokens import AfmCancelTokens |
7 | 8 | from gooddata_api_client.model.chat_history_request import ChatHistoryRequest |
8 | 9 | from gooddata_api_client.model.chat_history_result import ChatHistoryResult |
@@ -114,25 +115,20 @@ def ai_chat_history_reset(self, workspace_id: str) -> None: |
114 | 115 | chat_history_request = ChatHistoryRequest(reset=True) |
115 | 116 | self._actions_api.ai_chat_history(workspace_id, chat_history_request, _check_return_type=False) |
116 | 117 |
|
117 | | - def cancel_executions(self, executions: list[tuple[str, str]]) -> None: |
| 118 | + def cancel_executions(self, executions: dict[str, dict[str, str]]) -> None: |
118 | 119 | """ |
119 | 120 | Try to cancel given executions using the cancel api endpoint. |
120 | 121 | Order of token applications is not guaranteed. |
121 | 122 |
|
122 | 123 | *Note that this is currently a noop, we will be enabling this functionality soon.* |
123 | 124 |
|
124 | 125 | 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 |
126 | 127 | """ |
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