Skip to content

Commit

Permalink
put back with suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinBelthle committed Nov 19, 2024
1 parent 6282552 commit 0c4b4bf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions antarest/matrixstore/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,7 @@ def save(self, content: t.Union[t.List[t.List[MatrixData]], npt.NDArray[np.float
# Avoid having to save the matrix again (that's the whole point of using a hash).
return matrix_hash

lock_file = matrix_path.parent.joinpath(
f"{matrix_hash}.tsv.lock"
) # use tsv lock to stay consistent with old data
lock_file = matrix_path.with_suffix(".tsv.lock") # use tsv lock to stay consistent with old data
for internal_format in InternalMatrixFormat:
matrix_in_another_format_path = self.bucket_dir.joinpath(f"{matrix_hash}.{internal_format}")
if matrix_in_another_format_path.exists():
Expand Down Expand Up @@ -282,5 +280,5 @@ def delete(self, matrix_hash: str) -> None:

# IMPORTANT: Deleting the lock file under Linux can make locking unreliable.
# Abandoned lock files are deleted here to maintain consistent behavior.
lock_file = matrix_path.parent.joinpath(f"{matrix_hash}.tsv.lock")
lock_file = matrix_path.with_suffix(".tsv.lock")
lock_file.unlink(missing_ok=True)
4 changes: 2 additions & 2 deletions tests/matrixstore/test_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def test_mixed_formats(self, tmp_path: str, matrix_format: str) -> None:
associated_hash = "d73f023a3f852bf2e5c6d836cd36cd930d0091dcba7f778161c707e1c58222b0"
matrix_path = matrix_content_repo.bucket_dir.joinpath(f"{associated_hash}.{saved_format}")
saved_format.save_matrix(df, matrix_path)
lock_path = matrix_content_repo.bucket_dir.joinpath(f"{associated_hash}.tsv.lock")
lock_path = matrix_path.with_suffix(".tsv.lock")
lock_path.touch()

# asserts the saved matrix object exists
Expand All @@ -331,5 +331,5 @@ def test_mixed_formats(self, tmp_path: str, matrix_format: str) -> None:
assert not saved_matrix_files
repo_matrix_files = list(matrix_content_repo.bucket_dir.glob(f"*.{repository_format}"))
assert len(repo_matrix_files) == 1
new_matrix_path = matrix_content_repo.bucket_dir.joinpath(f"{associated_hash}.{repository_format}")
new_matrix_path = matrix_content_repo.bucket_dir.with_suffix(f".{repository_format}")
assert repo_matrix_files[0] == new_matrix_path

0 comments on commit 0c4b4bf

Please sign in to comment.