Issue/Bug in split_by_fname_fiile

Hi,
It seems to me that using data block API with the following methods will have unexpected issue. Split_by_fname_file() won’t read from path_new, instead of using the old path in from_folder().

Please let me know if this is a bug or my misunderstanding.

.from_folder(path)
.split_by_fname_file(file,path_new)

Current behavior:
.from_folder(’…/data/images/’)
.split_by_fname_file(‘valid.txt’,path=’…/data/’)

split_by_fname_file will return FileNotFoundError at path ‘…/data/images/valid.txt’

Expected behavior:
should read fname from path ‘…/data/valid.txt’

As I also looked at source code
def split_by_fname_file(self, fname:PathOrStr, path:PathOrStr=None)->‘ItemLists’:
“Split the data by using the names in fname for the validation set. path will override self.path.”
path = Path(ifnone(path, self.path))
valid_names = loadtxt_str(self.path/fname)
return self.split_by_files(valid_names)

Should we loadtxt_str(path/fname) instead of (self.path/fname)? As we already set path in the previous step?

Thanks

I think you’re right, it’s a bug and you have the fix. You can submit a PR :slight_smile:

Thanks, I wasn’t sure about it.
PR submitted :slight_smile: