Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/evaluate/saving.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def save(path_or_file, **data):

def _setup_path(path_or_file, current_time):
path_or_file = Path(path_or_file)
is_file = len(path_or_file.suffix) > 0
is_file = not path_or_file.is_dir() and len(path_or_file.suffix) > 0
if is_file:
folder = path_or_file.parent
file_name = path_or_file.name
Expand Down
9 changes: 9 additions & 0 deletions tests/test_save.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,12 @@ def test_save_to_file(self):
for key in SAVE_EXTRA_KEYS:
_ = loaded_result_dict.pop(key)
self.assertDictEqual(result_dict, loaded_result_dict)


def test_save_to_existing_directory_with_suffix(tmp_path):
directory = tmp_path / "experiment.v1"
directory.mkdir()
path = evaluate.save(directory, accuracy=0.75)
assert path.parent == directory
assert path.name.startswith("result-")
assert json.loads(path.read_text())["accuracy"] == 0.75