From 254141fa10383d73c5487a132e8973d467d7c15b Mon Sep 17 00:00:00 2001 From: Raunak Bhansali Date: Mon, 5 Aug 2024 01:10:40 +0530 Subject: [PATCH] Fix thread safety issue in directory creation --- terratorch/cli_tools.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/terratorch/cli_tools.py b/terratorch/cli_tools.py index e0d523e1..171710f6 100644 --- a/terratorch/cli_tools.py +++ b/terratorch/cli_tools.py @@ -123,7 +123,7 @@ def write_on_epoch_end(self, trainer, pl_module, predictions, batch_indices): # output_dir = self.output_dir if not os.path.exists(output_dir): - os.mkdir(output_dir) + os.makedirs(output_dir, exist_ok=True) for pred_batch, filename_batch in predictions: for prediction, file_name in zip(torch.unbind(pred_batch, dim=0), filename_batch, strict=False): @@ -467,4 +467,4 @@ def inference(self, file_path: Path) -> torch.Tensor: prediction, file_name = self.inference_on_dir( tmpdir, ) - return prediction.squeeze(0) + return prediction.squeeze(0) \ No newline at end of file