diff --git a/dagrunner/execute_graph.py b/dagrunner/execute_graph.py index 5d63ddf..088732a 100755 --- a/dagrunner/execute_graph.py +++ b/dagrunner/execute_graph.py @@ -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: diff --git a/dagrunner/tests/execute_graph/test_plugin_executor.py b/dagrunner/tests/execute_graph/test_plugin_executor.py index b952b12..cdcdfb3 100644 --- a/dagrunner/tests/execute_graph/test_plugin_executor.py +++ b/dagrunner/tests/execute_graph/test_plugin_executor.py @@ -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}" + )