alibi icon indicating copy to clipboard operation
alibi copied to clipboard

Pydantic runtime type validation

Open jklaise opened this issue 2 years ago • 2 comments

In light of https://github.com/SeldonIO/alibi/pull/511#issuecomment-950861810 let's test pydantic approach to runtime type validaton.

jklaise avatar Oct 25 '21 14:10 jklaise

Updating the decorator to @validate_arguments(config=dict(arbitrary_types_allowed=True)) allows type-checking of arbitrary objects such as np.ndarray.

Now it seems the decorator struggles with forward refs such as those that are returned from fit methods (i.e. the class itself is returned).

jklaise avatar Oct 25 '21 15:10 jklaise

See bug/limitation here: https://github.com/samuelcolvin/pydantic/issues/2901

Another note, pydantic currently doesn't validate the return type at all.

jklaise avatar Oct 25 '21 16:10 jklaise