diff --git a/arkindex_worker/worker/training.py b/arkindex_worker/worker/training.py index c33c13d1c785d405e01cafcc42fa55d29144cae0..ffe52d6f9632882743dbc7a5340d4fc5b1c5ef66 100644 --- a/arkindex_worker/worker/training.py +++ b/arkindex_worker/worker/training.py @@ -50,23 +50,15 @@ 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) - if p.is_dir(): - continue - - file_list.append(p) + with tarfile.open(path_to_tar_archive, "w") as tar: + tar.add(path) + file_list = [member for member in tar.getnames() if os.path.isfile(member)] # Sort by path file_list.sort() # Compute hash of the files for file_path in file_list: - print("BOOM PATH", file_path) with open(file_path, "rb") as file_data: for chunk in iter(lambda: file_data.read(CHUNK_SIZE), b""): content_hasher.update(chunk) @@ -102,7 +94,6 @@ class TrainingMixin(object): model_id: str, tag: Optional[str] = None, description: Optional[str] = None, - use_parent_folder=False, ): """ This method creates a model archive and its associated hash, diff --git a/tests/conftest.py b/tests/conftest.py index 03a1b841bd85235163c2c688708e843f253acfd1..8b6f16ef834712c769badc8308143c81e58a3a88 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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 = {} diff --git a/tests/test_elements_worker/test_training.py b/tests/test_elements_worker/test_training.py index 519db44b769c66ee3859cd50f076e769737f6af6..4448554da951fcaaa87ccde715af8c31865a92fd 100644 --- a/tests/test_elements_worker/test_training.py +++ b/tests/test_elements_worker/test_training.py @@ -58,7 +58,7 @@ def test_create_archive_with_subfolder(model_file_dir_with_subfolder): assert ( hash == "e2fa86cefc33b24502ad4151a638dd29" ), "Hash was not properly computed" - assert 300 < size < 1200 + assert 300 < size < 1500 assert not os.path.exists(zst_archive_path), "Auto removal failed"