Hi everyone the latest release from kedro from yes...
# questions
v
Hi everyone the latest release from kedro from yesterday has introduced the parameter validation framework, which I find super cool. But it looks like the current implementation doesn't support the
UnionType
as parameters. My code is breaking on
validation/type_extractor:117
, when calling
expected_type.__name__
(in the debug log message) with an error _AttributeError: 'types.UnionType' object has no attribute '__name__'._ My node signature looks something like
def foo(a: list[str] | None)
Could you help me figure out if that's a bug in the implementation or is this framework intended to be used differently?
m
Hi Viktoria, amazing you are already trying the new parameter validation! I'll tag @Sajid Alam @Ravi Kumar Pilla who built the feature, they should be able to help you 🙂
l
By extension, does it not validate primitives, should as e.g., ints?
s
Thanks for flagging this! That's a bug the debug log assumes all types have
__name__
, which
UnionType
doesn't. We'll push a fix. In the meantime, your usage is fine the framework is intended for Pydantic/dataclass type hints on
params:
inputs. Types like
list[str] | None
should be silently skipped, not crash.
👍 1
@Laurens Vijnck no it doesn't validate primitives the framework should only activate for Pydantic models and dataclasses.
v
thank you for looking into it 🙂
s
We've made a patch release to fix this, let us know if its resolved. 😊
p
@Sajid Alam we're using "object injection" quite a bit. https://github.com/everycure-org/matrix/blob/main/libs/matrix-inject/src/matrix_inject/inject.py Which is inspired by some former work 😇 This feels like it can almost enable this behaviour, if you're invoking the
___init___
of whatever entity that is defined, it would achieve the same objective. And it really cleans up kedro nodes as it allows fully inflated object injection. WDYT is that worth expanding to?