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

Changes required to facilitate running of pp_demo_suite using head of dagrunner #43

Merged
merged 1 commit into from
Jul 8, 2024
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
6 changes: 3 additions & 3 deletions dagrunner/execute_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ def plugin_executor(
callable_obj = callable_obj(**callable_kwargs_init)
call_msg = f"(**{callable_kwargs_init})"

callable_kwargs = callable_kwargs | _get_common_args_matching_signature(
callable_obj, common_kwargs
)
callable_kwargs = callable_kwargs | {
key: value for key, value in common_kwargs.items() if key in callable_kwargs
} # based on overriding arguments

msg = f"{obj_name}{call_msg}(*{args}, **{callable_kwargs})"
if verbose:
Expand Down
34 changes: 34 additions & 0 deletions dagrunner/tests/execute_graph/test_plugin_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,37 @@ def test_pass_common_args():
res
== "iarg1=sentinel.iarg1; ikwarg1=sentinel.ikwarg1; args=(sentinel.arg1, sentinel.arg2); kwarg1=sentinel.kwarg1; kwargs={}"
)


class DummyPlugin2:
"""Plugin that is reliant on data not explicitly defined in its UI."""

def __call__(self, *args, **kwargs):
return f"args={args}; kwargs={kwargs}"


def test_pass_common_args_via_override():
"""
Passing 'common args' to a plugin that doesn't have such arguments
defined in its signature. Instead, filter out those that aren't
specified in the graph.
"""
common_kwargs = {
"kwarg1": mock.sentinel.kwarg1,
"kwarg2": mock.sentinel.kwarg2,
"kwarg3": mock.sentinel.kwarg3,
}
args = []
call = tuple(
[
DummyPlugin2,
{
"kwarg1": mock.sentinel.kwarg1,
"kwarg2": mock.sentinel.kwarg2,
},
]
)
res = plugin_executor(*args, call=call, common_kwargs=common_kwargs)
assert (
res == "args=(); kwargs={'kwarg1': sentinel.kwarg1, 'kwarg2': sentinel.kwarg2}"
)
Loading