From 6dcc9e68dd9922835c8685b9d8f9766a4fe5624a Mon Sep 17 00:00:00 2001 From: Brendan Fahy Date: Sat, 13 Jun 2020 17:00:07 +0000 Subject: [PATCH] use gfile to support remote directories --- pytorch_lightning/callbacks/model_checkpoint.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytorch_lightning/callbacks/model_checkpoint.py b/pytorch_lightning/callbacks/model_checkpoint.py index 39d20125046ec0..1e2f1394890c41 100644 --- a/pytorch_lightning/callbacks/model_checkpoint.py +++ b/pytorch_lightning/callbacks/model_checkpoint.py @@ -101,7 +101,7 @@ def __init__(self, filepath: Optional[str] = None, monitor: str = 'val_loss', ve save_last: bool = False, save_top_k: int = 1, save_weights_only: bool = False, mode: str = 'auto', period: int = 1, prefix: str = ''): super().__init__() - if save_top_k > 0 and filepath is not None and tf.io.gfile.isdir(filepath) and len(os.listdir(filepath)) > 0: + if save_top_k > 0 and filepath is not None and tf.io.gfile.isdir(filepath) and len(tf.io.gfile.listdir(filepath)) > 0: rank_zero_warn( f"Checkpoint directory {filepath} exists and is not empty with save_top_k != 0." "All files in this directory will be deleted when a checkpoint is saved!"