nipype / pydra

Pydra Dataflow Engine
https://nipype.github.io/pydra/
Other
119 stars 57 forks source link

MNT: Relaxing lazy-field type-checking to permit super types to be passed to sub-type fields #682

Open tclose opened 11 months ago

tclose commented 11 months ago

With the motivation of keeping the typing infrastructure out of the way of new users I have been considering relaxing the type-checking at construction time (i.e. lazy fields) so that base classes can be passed to sub-classed type fields. This will avoid need to add cast statements between loosely-typed tasks and tightly-typed tasks. Stricter type-checking/coercing can still be performed at runtime.

For example, if B is a subclass of A, then currently you can connect a B-typed output into a A-typed input but if you wanted to connect A-typed to B-typed you would need to cast it to B first. While this aligns with how traditional type-checking is done, we might want to be a bit more flexible so you could connect generic File type fields to Nifti fields for example. If both upstream and downstream nodes use to specific formats that don't match, e.g. MrtrixImage -> Nifti then we would still raise an error.

It would somewhat reduce the effectiveness of the type-checking, but would probably avoid any (false-positive) cases where the type-checking could be annoying