fix(os): fix FileNotFoundError in storage_manager (#455)

* use rank0 to makedirs

* use try-except to handle file error

* fix ci
pull/464/head
Yang Gao 2023-10-27 22:32:46 +08:00 committed by GitHub
parent 4995060d84
commit f77f376fd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -662,8 +662,11 @@ class LocalClient(StorageClient):
def sync_upload_fileobj(fp: str, saved_obj=None, **kwargs):
assert saved_obj is not None
fp_dirname = os.path.dirname(fp)
if not os.path.exists(fp_dirname):
os.makedirs(fp_dirname, exist_ok=True)
try:
if not os.path.exists(fp_dirname):
os.makedirs(fp_dirname, exist_ok=True)
except FileNotFoundError:
pass
torch.save(saved_obj, fp, **kwargs)
@staticmethod