Skip to content

Commit

Permalink
fsspec ls gives full path
Browse files Browse the repository at this point in the history
  • Loading branch information
f4hy committed Sep 2, 2020
1 parent b565a0c commit b380a98
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions pytorch_lightning/loggers/tensorboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,10 @@ def _get_next_version(self):

existing_versions = []
for d in self._fs.ls(root_dir):
if self._fs.isdir(os.path.join(root_dir, d)) and d.startswith("version_"):
dir_ver = d.split("_")[1].replace('/', '')
bn = os.path.basename(d)
if self._fs.isdir(d) and bn.startswith("version_"):
dir_ver = bn.split("_")[1].replace('/', '')
existing_versions.append(int(dir_ver))

if len(existing_versions) == 0:
return 0

Expand Down
4 changes: 2 additions & 2 deletions pytorch_lightning/trainer/training_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ def restore_hpc_weights_if_needed(self, model: LightningModule):
folderpath = str(self.weights_save_path)
fs = get_filesystem(folderpath)
if fs.exists(folderpath):
files = fs.ls(folderpath)
files = [os.path.basename(f) for f in fs.ls(folderpath)]
hpc_weight_paths = [x for x in files if 'hpc_ckpt' in x]

# if hpc weights exist restore model
Expand Down Expand Up @@ -523,7 +523,7 @@ def hpc_load(self, folderpath, on_gpu):

def max_ckpt_in_folder(self, path, name_key='ckpt_'):
fs = get_filesystem(path)
files = fs.ls(path)
files = [os.path.basename(f) for f in fs.ls(path)]
files = [x for x in files if name_key in x]
if len(files) == 0:
return 0
Expand Down
3 changes: 2 additions & 1 deletion pytorch_lightning/utilities/cloud_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def load(path_or_url: str, map_location=None):


def get_filesystem(path: pathlike):
if "://" in str(path):
path = str(path)
if "://" in path:
# use the fileystem from the protocol specified
return fsspec.filesystem(path.split(":")[0])
else:
Expand Down

0 comments on commit b380a98

Please sign in to comment.