use exist_ok to ensure no conflict

This commit is contained in:
chenfeiyu 2021-02-23 10:50:57 +08:00
parent c6504ade5a
commit 6f1c534557
1 changed files with 2 additions and 8 deletions

View File

@ -204,10 +204,7 @@ class ExperimentBase(object):
"""
# output dir
output_dir = Path(self.args.output).expanduser()
if dist.get_rank() == 0:
output_dir.mkdir(parents=True, exist_ok=True)
while not output_dir.exists():
time.sleep(1)
output_dir.mkdir(parents=True, exist_ok=True)
self.output_dir = output_dir
@ -218,10 +215,7 @@ class ExperimentBase(object):
"""
# checkpoint dir
checkpoint_dir = self.output_dir / "checkpoints"
if dist.get_rank() == 0:
checkpoint_dir.mkdir(exist_ok=True)
while not checkpoint_dir.exists():
time.sleep(1)
checkpoint_dir.mkdir(exist_ok=True)
self.checkpoint_dir = checkpoint_dir