:bug: #2120 in model.from_pretrained, PosixPath crashes at "albert" check
- `pretrained_model_name_or_path` is now stringified to allow the "albert" and "v2" checks with PosixPath (or any other path representation that isn't iterable).
- If `pretrained_model_name_or_path` is None, it gives string "None" which doesn't contain "albert" so it's OK.
- 2 x `str(pretrained_model_name_or_path)` doesn't impact performances as it's called only once per program and `and` operator will generally fail at left side.
- added a test to check non-regression
Ok, I've checked the errors in CI. Those are linked to the fact that in older python version, PosixPath is not converted automatically to String and `os.path.isdir/isfile` crash because it expects a string or int. So my patch works perfectly in latest version of python (like 3.7) but not older (like 3.5) which is quite ugly.
Solutions are:
- anywhere there is `isdir/isfile`, force `str(path)` in call which is ugly but will work except if you want to manage other types than strings in path
- officially ask people to convert their path to strings when calling `from_pretrained` which is shame because it shows the impossibility to be backward compatible completely but it won't introduce `str()` everywhere in the code.

WDYT?
<|||||>Hey @mandubian, thanks for offering that fix. I think that in the next release we'll remove this warning about albert models v2, which will solve the problem with PosixPaths.<|||||>@LysandreJik perfect! It will still fail with python 3.5 on `isdir/isfile` but can we do anything for that? I'm not sure... that's the history of Python ;)<|||||>The line was removed for version 2.3.0 so there's no need for that anymore. Thanks @mandubian :).