Skip to content
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

move default_args into kwargs #1382

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions cosmos/operators/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ def __init__(self, on_warning_callback: Callable[..., Any] | None = None, **kwar
if not on_warning_callback:
super().__init__(**kwargs)
else:
# Make the following code independent of arguments being defaulted or not.
david-mag marked this conversation as resolved.
Show resolved Hide resolved
if "default_args" in kwargs.keys():
kwargs.update(kwargs.pop("default_args"))
self.on_warning_callback = on_warning_callback
self.is_delete_operator_pod_original = kwargs.get("is_delete_operator_pod", None)
if self.is_delete_operator_pod_original is not None:
Expand Down
20 changes: 20 additions & 0 deletions tests/operators/test_kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,26 @@ def test_dbt_kubernetes_build_command():
),
({"is_delete_operator_pod": None, "on_finish_action": "keep_pod"}, (1, 1, False, "keep_pod")),
({}, (1, 1, True, "delete_pod")),
(
{
"default_args": {
"on_failure_callback": (lambda **kwargs: None),
"is_delete_operator_pod": None,
},
"on_finish_action": "delete_pod",
},
(1, 2, True, "delete_pod"),
),
(
{
"default_args": {
"on_failure_callback": [(lambda **kwargs: None), (lambda **kwargs: None)],
"is_delete_operator_pod": None,
},
"on_finish_action": "delete_succeeded_pod",
},
(1, 3, False, "delete_succeeded_pod"),
),
],
)
@pytest.mark.skipif(
Expand Down
Loading