Skip to content
Snippets Groups Projects
Commit ec0b94eb authored by Yoann Schneider's avatar Yoann Schneider :tennis: Committed by Bastien Abadie
Browse files

Properly compute files hashes during models publication

parent 9caaa275
No related branches found
No related tags found
1 merge request!267Properly compute files hashes during models publication
Pipeline #79882 passed
...@@ -50,10 +50,14 @@ def create_archive(path: DirPath) -> Tuple[Path, Hash, FileSize, Hash]: ...@@ -50,10 +50,14 @@ def create_archive(path: DirPath) -> Tuple[Path, Hash, FileSize, Hash]:
# Create an uncompressed tar archive with all the needed files # Create an uncompressed tar archive with all the needed files
# Files hierarchy ifs kept in the archive. # Files hierarchy ifs kept in the archive.
file_list = []
with tarfile.open(path_to_tar_archive, "w") as tar: with tarfile.open(path_to_tar_archive, "w") as tar:
tar.add(path) for p in path.glob("**/*"):
file_list = [member for member in tar.getnames() if os.path.isfile(member)] x = p.relative_to(path)
tar.add(p, arcname=x, recursive=False)
# Only keep files when computing the hash
if p.is_file():
file_list.append(p)
# Sort by path # Sort by path
file_list.sort() file_list.sort()
......
...@@ -26,7 +26,7 @@ from arkindex_worker.worker import BaseWorker, ElementsWorker ...@@ -26,7 +26,7 @@ from arkindex_worker.worker import BaseWorker, ElementsWorker
from arkindex_worker.worker.transcription import TextOrientation from arkindex_worker.worker.transcription import TextOrientation
FIXTURES_DIR = Path(__file__).resolve().parent / "data" FIXTURES_DIR = Path(__file__).resolve().parent / "data"
SAMPLES_DIR = Path("tests") / "samples" SAMPLES_DIR = Path(__file__).resolve().parent / "samples"
__yaml_cache = {} __yaml_cache = {}
...@@ -282,7 +282,7 @@ def model_file_dir(): ...@@ -282,7 +282,7 @@ def model_file_dir():
@pytest.fixture @pytest.fixture
def model_file_dir_with_subfolder(): def model_file_dir_with_subfolder():
return SAMPLES_DIR / "model_files_with_subfolder" return SAMPLES_DIR / "root_folder"
@pytest.fixture @pytest.fixture
......
Wow this is actually the data of the best model ever created on Arkindex
\ No newline at end of file
...@@ -56,7 +56,7 @@ def test_create_archive_with_subfolder(model_file_dir_with_subfolder): ...@@ -56,7 +56,7 @@ def test_create_archive_with_subfolder(model_file_dir_with_subfolder):
): ):
assert os.path.exists(zst_archive_path), "The archive was not created" assert os.path.exists(zst_archive_path), "The archive was not created"
assert ( assert (
hash == "e2fa86cefc33b24502ad4151a638dd29" hash == "3e453881404689e6e125144d2db3e605"
), "Hash was not properly computed" ), "Hash was not properly computed"
assert 300 < size < 1500 assert 300 < size < 1500
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment