Skip to content

path-token-fix

Frank Sauerburger requested to merge path-token-fix into master

For some systems such as lxplus, directories may have a dot in their path. As such, the current code can not save or import the fit properly.

Solution/simple test:

fold_i = 0
path = "/system.directory/path/to/model"
path_token = path.rsplit("/", 1)
file_token = path_token[-1].rsplit(".", 1)

if len(file_token) == 1:
    file_token.append(f"fold_{fold_i}")
else:
    file_token.insert(-1, f"fold_{fold_i}")

if len(path_token) == 1:
    path_token = [".".join(file_token)]
else:
    path_token = [path_token[0]] + [".".join(file_token)]

print("/".join(path_token))

Tests:

path = "/system.directory/path/to/model" -> /system.directory/path/to/model.fold_0

path = "/system.directory/path/to/model.h5" -> /system.directory/path/to/model.fold_0.h5

path = "/system_directory/path/to/model" -> /system_directory/path/to/model.fold_0

path = "/system_directory/path/to/model.h5" -> /system_directory/path/to/model.fold_0.h5

path = "model" -> model.fold_0

path = "model.h5" -> model.fold_0.h5

Edited by Frank Sauerburger

Merge request reports