Skip to content

Commit a28525e

Browse files
authored
Merge pull request #1047 from no23reason/dho/cq-1124-cancel-exec
feat: add cancel method to the Execution object
2 parents 3b84eee + 469c750 commit a28525e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from attrs import define, field
99
from gooddata_api_client import models
1010
from gooddata_api_client.model.afm import AFM
11+
from gooddata_api_client.model.afm_cancel_tokens import AfmCancelTokens
1112
from gooddata_api_client.model.result_spec import ResultSpec
1213

1314
from gooddata_sdk.client import GoodDataApiClient
@@ -365,6 +366,16 @@ def read_result(self, limit: Union[int, list[int]], offset: Union[None, int, lis
365366
)
366367
return ExecutionResult(execution_result)
367368

369+
def cancel(self) -> None:
370+
"""
371+
Cancels the execution backing this execution result.
372+
"""
373+
if self.cancel_token is not None:
374+
self._api_client.actions_api.cancel_executions(
375+
self._workspace_id,
376+
AfmCancelTokens({self.result_id: self.cancel_token}),
377+
)
378+
368379
def __str__(self) -> str:
369380
return self.__repr__()
370381

@@ -442,6 +453,12 @@ def get_labels_and_formats(self) -> tuple[dict[str, str], dict[str, str]]:
442453
def read_result(self, limit: Union[int, list[int]], offset: Union[None, int, list[int]] = None) -> ExecutionResult:
443454
return self.bare_exec_response.read_result(limit, offset)
444455

456+
def cancel(self) -> None:
457+
"""
458+
Cancels the execution.
459+
"""
460+
self.bare_exec_response.cancel()
461+
445462
def __str__(self) -> str:
446463
return self.__repr__()
447464

0 commit comments

Comments
 (0)