Skip to content
Snippets Groups Projects
Commit ceb2adbc authored by Nolan's avatar Nolan Committed by Yoann Schneider
Browse files

Only use files when computing model archive hash

parent 3f769e02
No related tags found
1 merge request!265Only use files when computing model archive hash
Pipeline #79871 passed
......@@ -50,12 +50,10 @@ def create_archive(path: DirPath) -> Tuple[Path, Hash, FileSize, Hash]:
# Create an uncompressed tar archive with all the needed files
# Files hierarchy ifs kept in the archive.
file_list = []
with tarfile.open(path_to_tar_archive, "w") as tar:
for p in path.glob("**/*"):
x = p.relative_to(path)
tar.add(p, arcname=x, recursive=False)
file_list.append(p)
tar.add(path)
file_list = [member for member in tar.getnames() if os.path.isfile(member)]
# Sort by path
file_list.sort()
......
......@@ -26,7 +26,7 @@ from arkindex_worker.worker import BaseWorker, ElementsWorker
from arkindex_worker.worker.transcription import TextOrientation
FIXTURES_DIR = Path(__file__).resolve().parent / "data"
SAMPLES_DIR = Path(__file__).resolve().parent / "samples"
SAMPLES_DIR = Path("tests") / "samples"
__yaml_cache = {}
......@@ -280,6 +280,11 @@ def model_file_dir():
return SAMPLES_DIR / "model_files"
@pytest.fixture
def model_file_dir_with_subfolder():
return SAMPLES_DIR / "model_files_with_subfolder"
@pytest.fixture
def fake_dummy_worker():
api_client = MockApiClient()
......
Wow this is actually the data of the best model ever created on Arkindex
\ No newline at end of file
Wow this is actually the data of the best model ever created on Arkindex
\ No newline at end of file
......@@ -45,6 +45,24 @@ def test_create_archive(model_file_dir):
assert not os.path.exists(zst_archive_path), "Auto removal failed"
def test_create_archive_with_subfolder(model_file_dir_with_subfolder):
"""Create an archive when the model's file is in a folder containing a subfolder"""
with create_archive(path=model_file_dir_with_subfolder) as (
zst_archive_path,
hash,
size,
archive_hash,
):
assert os.path.exists(zst_archive_path), "The archive was not created"
assert (
hash == "e2fa86cefc33b24502ad4151a638dd29"
), "Hash was not properly computed"
assert 300 < size < 1500
assert not os.path.exists(zst_archive_path), "Auto removal failed"
@pytest.mark.parametrize(
"tag, description",
[
......
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