Skip to content

feat: add exections_cancellable to sdk.create and export Execution #1024

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 17, 2025
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: 1 addition & 0 deletions gooddata-sdk/gooddata_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@
from gooddata_sdk.compute.model.base import ExecModelEntity, ObjId
from gooddata_sdk.compute.model.execution import (
BareExecutionResponse,
Execution,
ExecutionDefinition,
ExecutionResponse,
ExecutionResult,
Expand Down
10 changes: 9 additions & 1 deletion gooddata-sdk/gooddata_sdk/sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ def create(
host_: str,
token_: str,
extra_user_agent_: Optional[str] = None,
*,
executions_cancellable: bool = False,
**custom_headers_: Optional[str],
) -> GoodDataSdk:
"""
Expand All @@ -56,7 +58,13 @@ def create(
This is preferred way of creating GoodDataSdk, when no tweaks are needed.
"""
filtered_headers = {key: value for key, value in custom_headers_.items() if value is not None}
client = GoodDataApiClient(host_, token_, custom_headers=filtered_headers, extra_user_agent=extra_user_agent_)
client = GoodDataApiClient(
host_,
token_,
custom_headers=filtered_headers,
extra_user_agent=extra_user_agent_,
executions_cancellable=executions_cancellable,
)
return cls(client)

def __init__(self, client: GoodDataApiClient) -> None:
Expand Down
32 changes: 32 additions & 0 deletions gooddata-sdk/tests/sdk/test_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,35 @@ def test_non_existing_token(setenvvar):
def test_corrupted_config():
with pytest.raises(ValueError):
GoodDataSdk.create_from_profile(profiles_path=CORRUPTED_PROFILES)


def test_new_options(setenvvar):
sdk1 = GoodDataSdk.create("host", "token", "agent_foo", header1="header1", header2="header2")
assert sdk1._client._hostname == "host"
assert sdk1._client._token == "token"
assert sdk1._client._api_client.user_agent[-9:] == "agent_foo"
assert sdk1._client._custom_headers == {"header1": "header1", "header2": "header2"}
assert not sdk1._client.executions_cancellable

sdk2 = GoodDataSdk.create(
"host", "token", "agent_foo", header1="header1", executions_cancellable=True, header2="header2"
)
assert sdk1._client._hostname == sdk2._client._hostname
assert sdk1._client._token == sdk2._client._token
assert sdk1._client._api_client.user_agent == sdk2._client._api_client.user_agent
assert sdk1._client._custom_headers == sdk2._client._custom_headers
assert sdk2._client.executions_cancellable

sdk3 = GoodDataSdk.create(
"host", "token", "agent_foo", executions_cancellable=True, header1="header1", header2="header2"
)
assert sdk1._client._api_client.user_agent == sdk3._client._api_client.user_agent
assert sdk1._client._custom_headers == sdk3._client._custom_headers
assert sdk3._client.executions_cancellable

sdk4 = GoodDataSdk.create(
"host", "token", "agent_foo", header1="header1", header2="header2", executions_cancellable=True
)
assert sdk1._client._api_client.user_agent == sdk4._client._api_client.user_agent
assert sdk1._client._custom_headers == sdk4._client._custom_headers
assert sdk4._client.executions_cancellable
Loading