pydra icon indicating copy to clipboard operation
pydra copied to clipboard

Automatically coerce string/PathLike objects to File/Directory objects when passed to Any-typed fields

Open tclose opened this issue 8 months ago • 3 comments

I'm not 100% on this, but think it is probably a good idea. When using properly typed tasks, if you pass a string to a File/Directory-typed field, it will be coerced to a fileformats object and then properly checked for existence/format and have its contents hashed. However, if you don't type your task and just leave the field as typing.Any, the string representing the file path will be just treated as a string and the node won't be rerun if its contents change.

To avoid this, for typing.Any-typed fields, we could check all strings and see if they correspond to an existing file path, and if so implicitly convert it to a File/Directory object before passing it the task, in which its contents will be hashed when building the task checksum.

tclose avatar Apr 29 '25 02:04 tclose