save_pretrained: mkdir(exist_ok=True) (#5258)
* all save_pretrained methods mkdir if not os.path.exists
This commit is contained in:
@@ -132,10 +132,9 @@ class PretrainedConfig(object):
|
||||
save_directory (:obj:`string`):
|
||||
Directory where the configuration JSON file will be saved.
|
||||
"""
|
||||
assert os.path.isdir(
|
||||
save_directory
|
||||
), "Saving path should be a directory where the model and configuration can be saved"
|
||||
|
||||
if os.path.isfile(save_directory):
|
||||
raise AssertionError("Provided path ({}) should be a directory, not a file".format(save_directory))
|
||||
os.makedirs(save_directory, exist_ok=True)
|
||||
# If we save using the predefined names, we can load using `from_pretrained`
|
||||
output_config_file = os.path.join(save_directory, CONFIG_NAME)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user