From f56ed169f26da796bbef683054b00ced83663003 Mon Sep 17 00:00:00 2001 From: Deepyaman Datta Date: Wed, 21 Oct 2020 04:12:27 -0400 Subject: [PATCH] Fix TypeError when passing dict to wrapped partial (#556) --- RELEASE.md | 1 + kedro/pipeline/node.py | 2 +- tests/pipeline/test_node.py | 10 ++++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/RELEASE.md b/RELEASE.md index c3bad79143..fb8e32e0a6 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -13,6 +13,7 @@ ## Major features and improvements ## Bug fixes and other changes +* Fixed `TypeError` when converting dict inputs to a node made from a wrapped `partial` function. * Improved handling of non-ASCII word characters in dataset names. - For example, a dataset named `jalapeño` will be accessible as `DataCatalog.datasets.jalapeño` rather than `DataCatalog.datasets.jalape__o`. * Fixed `kedro install` for an Anaconda environment defined in `environment.yml`. diff --git a/kedro/pipeline/node.py b/kedro/pipeline/node.py index 6e21820ddd..4bf0df75c4 100644 --- a/kedro/pipeline/node.py +++ b/kedro/pipeline/node.py @@ -677,7 +677,7 @@ def _dict_inputs_to_list(func: Callable[[Any], Any], inputs: Dict[str, str]): """Convert a dict representation of the node inputs to a list , ensuring the appropriate order for binding them to the node's function. """ - sig = inspect.signature(func).bind(**inputs) + sig = inspect.signature(func, follow_wrapped=False).bind(**inputs) # for deterministic behavior in python 3.5, sort kwargs inputs alphabetically return list(sig.args) + sorted(sig.kwargs.values()) diff --git a/tests/pipeline/test_node.py b/tests/pipeline/test_node.py index 1d90c44931..d82e533365 100644 --- a/tests/pipeline/test_node.py +++ b/tests/pipeline/test_node.py @@ -464,3 +464,13 @@ def test_updated_partial(self): assert str(n) == "identity([in]) -> [out]" assert n.name == "identity([in]) -> [out]" assert n.short_name == "Identity" + + def test_updated_partial_dict_inputs(self): + n = node( + update_wrapper(partial(biconcat, input1=["in1"]), biconcat), + dict(input2="in2"), + ["out"], + ) + assert str(n) == "biconcat([in2]) -> [out]" + assert n.name == "biconcat([in2]) -> [out]" + assert n.short_name == "Biconcat"