arkindex-base-worker 0.5.1rc1__py3-none-any.whl → 0.5.1rc2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {arkindex_base_worker-0.5.1rc1.dist-info → arkindex_base_worker-0.5.1rc2.dist-info}/METADATA +1 -1
- {arkindex_base_worker-0.5.1rc1.dist-info → arkindex_base_worker-0.5.1rc2.dist-info}/RECORD +7 -7
- arkindex_worker/utils.py +27 -0
- tests/test_utils.py +42 -0
- {arkindex_base_worker-0.5.1rc1.dist-info → arkindex_base_worker-0.5.1rc2.dist-info}/WHEEL +0 -0
- {arkindex_base_worker-0.5.1rc1.dist-info → arkindex_base_worker-0.5.1rc2.dist-info}/licenses/LICENSE +0 -0
- {arkindex_base_worker-0.5.1rc1.dist-info → arkindex_base_worker-0.5.1rc2.dist-info}/top_level.txt +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
arkindex_base_worker-0.5.
|
|
1
|
+
arkindex_base_worker-0.5.1rc2.dist-info/licenses/LICENSE,sha256=NVshRi1efwVezMfW7xXYLrdDr2Li1AfwfGOd5WuH1kQ,1063
|
|
2
2
|
arkindex_worker/__init__.py,sha256=Sdt5KXn8EgURb2MurYVrUWaHbH3iFA1XLRo0Lc5AJ44,250
|
|
3
3
|
arkindex_worker/cache.py,sha256=XpEXMSnbhYCvrJquwA9XXqZo-ajMLpaCxKG5wH3Gp6Y,10959
|
|
4
4
|
arkindex_worker/image.py,sha256=sGE8to5iykXv25bpkftOEWzlh5NzBZSKy4lSRoHYHPU,20929
|
|
5
5
|
arkindex_worker/models.py,sha256=7GnKqpWPOSxyR_eKlDNVBe_r3TcE4ofK-1GzaonJEdM,10132
|
|
6
|
-
arkindex_worker/utils.py,sha256=
|
|
6
|
+
arkindex_worker/utils.py,sha256=yq_LmRlqfWOzB09Aiz2XYx4xPZnoEXR3As48h2HxOVc,10974
|
|
7
7
|
arkindex_worker/worker/__init__.py,sha256=SzD0s1_m6gMV02EUF-NeciqZdVPA4dpXI84tSj-g494,17869
|
|
8
8
|
arkindex_worker/worker/base.py,sha256=-ASOgLzemHOAz7EnPZ9hT6wON_9GJ7uadxx7oZLgUD4,22149
|
|
9
9
|
arkindex_worker/worker/classification.py,sha256=qvykymkgd4nGywHCxL8obo4egstoGsmWNS4Ztc1qNWQ,11024
|
|
@@ -29,7 +29,7 @@ tests/test_element.py,sha256=hlj5VSF4plwC7uz9R4LGOOXZJQcHZiYCIDZT5V6EIB8,14334
|
|
|
29
29
|
tests/test_image.py,sha256=yAM5mMfpQcIurT1KLHmu0AhSX2Qm3YvCu7afyZ3XUdU,28314
|
|
30
30
|
tests/test_merge.py,sha256=REpZ13jkq_qm_4L5URQgFy5lxvPZtXxQEiWfYLMdmF0,7956
|
|
31
31
|
tests/test_modern_config.py,sha256=Bm-a4LYQXgLZWQX7AmVyfJW0LNoLy1wj2d2GjzDkcBk,2683
|
|
32
|
-
tests/test_utils.py,sha256=
|
|
32
|
+
tests/test_utils.py,sha256=tgzNqyJMpddpeFWEjgsew_yDzmqnCA9HDaA5IpevAcM,5353
|
|
33
33
|
tests/test_elements_worker/__init__.py,sha256=2t3NciCIOun_N-Wv63FWGsTm5W9N3mbwAWVuFORlMg8,308
|
|
34
34
|
tests/test_elements_worker/test_classification.py,sha256=nya7veSPR_O9G41Enodp2-o6AifMBcaSTWJP2vXSSJ4,30133
|
|
35
35
|
tests/test_elements_worker/test_cli.py,sha256=a23i1pUDbXi23MUtbWwGEcLLrmc_YlrbDgOG3h66wLM,2620
|
|
@@ -55,7 +55,7 @@ worker-demo/tests/conftest.py,sha256=XzNMNeg6pmABUAH8jN6eZTlZSFGLYjS3-DTXjiRN6Yc
|
|
|
55
55
|
worker-demo/tests/test_worker.py,sha256=3DLd4NRK4bfyatG5P_PK4k9P9tJHx9XQq5_ryFEEFVg,304
|
|
56
56
|
worker-demo/worker_demo/__init__.py,sha256=2BPomV8ZMNf3YXJgloatKeHQCE6QOkwmsHGkO6MkQuM,125
|
|
57
57
|
worker-demo/worker_demo/worker.py,sha256=Rt-DjWa5iBP08k58NDZMfeyPuFbtNcbX6nc5jFX7GNo,440
|
|
58
|
-
arkindex_base_worker-0.5.
|
|
59
|
-
arkindex_base_worker-0.5.
|
|
60
|
-
arkindex_base_worker-0.5.
|
|
61
|
-
arkindex_base_worker-0.5.
|
|
58
|
+
arkindex_base_worker-0.5.1rc2.dist-info/METADATA,sha256=Hur6AEbZLwqTw-hbggG-IOgDib14f0p6ujRGx6nD_jE,3138
|
|
59
|
+
arkindex_base_worker-0.5.1rc2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
60
|
+
arkindex_base_worker-0.5.1rc2.dist-info/top_level.txt,sha256=-vNjP2VfROx0j83mdi9aIqRZ88eoJjxeWz-R_gPgyXU,49
|
|
61
|
+
arkindex_base_worker-0.5.1rc2.dist-info/RECORD,,
|
arkindex_worker/utils.py
CHANGED
|
@@ -4,6 +4,7 @@ import logging
|
|
|
4
4
|
import os
|
|
5
5
|
import tarfile
|
|
6
6
|
import tempfile
|
|
7
|
+
import zipfile
|
|
7
8
|
from collections.abc import Callable, Generator
|
|
8
9
|
from itertools import islice
|
|
9
10
|
from pathlib import Path
|
|
@@ -225,6 +226,32 @@ def create_tar_zst_archive(
|
|
|
225
226
|
return zst_fd, zst_archive, zst_hash, tar_hash
|
|
226
227
|
|
|
227
228
|
|
|
229
|
+
def create_zip_archive(source: Path, destination: Path | None = None) -> Path:
|
|
230
|
+
"""Helper to create a ZIP archive from a source folder.
|
|
231
|
+
|
|
232
|
+
:param source: Path to the folder whose content should be archived.
|
|
233
|
+
:param destination: Path to the created archive, defaults to None. If unspecified, a temporary file will be created.
|
|
234
|
+
:return: The file descriptor of the created tempfile (if one was created), path to the archive.
|
|
235
|
+
"""
|
|
236
|
+
# Parse destination and create a tmpfile if none was specified
|
|
237
|
+
file_d, destination = (
|
|
238
|
+
tempfile.mkstemp(prefix="teklia-", suffix=".zip")
|
|
239
|
+
if destination is None
|
|
240
|
+
else (None, destination)
|
|
241
|
+
)
|
|
242
|
+
destination = Path(destination)
|
|
243
|
+
logger.debug(f"Compressing file to {destination}")
|
|
244
|
+
|
|
245
|
+
with zipfile.ZipFile(
|
|
246
|
+
destination, mode="w", compression=zipfile.ZIP_BZIP2
|
|
247
|
+
) as archive:
|
|
248
|
+
for p in source.rglob("*"):
|
|
249
|
+
relpath = p.relative_to(source)
|
|
250
|
+
archive.write(p, arcname=relpath)
|
|
251
|
+
|
|
252
|
+
return archive, destination
|
|
253
|
+
|
|
254
|
+
|
|
228
255
|
DEFAULT_BATCH_SIZE = 50
|
|
229
256
|
"""Batch size used for bulk publication to Arkindex"""
|
|
230
257
|
|
tests/test_utils.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import logging
|
|
2
|
+
import zipfile
|
|
2
3
|
|
|
3
4
|
import pytest
|
|
4
5
|
|
|
@@ -7,6 +8,7 @@ from arkindex_worker.utils import (
|
|
|
7
8
|
DEFAULT_BATCH_SIZE,
|
|
8
9
|
batch_publication,
|
|
9
10
|
close_delete_file,
|
|
11
|
+
create_zip_archive,
|
|
10
12
|
extract_tar_zst_archive,
|
|
11
13
|
parse_source_id,
|
|
12
14
|
)
|
|
@@ -118,3 +120,43 @@ def test_batch_publication_decorator_alongside_unsupported_cache(caplog):
|
|
|
118
120
|
"This API helper `custom_publication_in_batches_without_cache` did not update the cache database",
|
|
119
121
|
),
|
|
120
122
|
]
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def test_zip_archive():
|
|
126
|
+
# Create zip archive from fixtures
|
|
127
|
+
_, archive = create_zip_archive(FIXTURES_DIR / "extract_parent_archives/expected")
|
|
128
|
+
|
|
129
|
+
# Check the files in the archive
|
|
130
|
+
with zipfile.ZipFile(archive, mode="r") as f:
|
|
131
|
+
assert sorted(f.namelist()) == [
|
|
132
|
+
"test/",
|
|
133
|
+
"test/images/",
|
|
134
|
+
"test/images/f2649ce7-333e-44d2-ae73-387f18aad1f6.png",
|
|
135
|
+
"test/labels/",
|
|
136
|
+
"test/labels/f2649ce7-333e-44d2-ae73-387f18aad1f6.png",
|
|
137
|
+
"test/labels_json/",
|
|
138
|
+
"test/labels_json/f2649ce7-333e-44d2-ae73-387f18aad1f6.json",
|
|
139
|
+
"train/",
|
|
140
|
+
"train/images/",
|
|
141
|
+
"train/images/98115546-df07-448c-a2f0-34aa24789b77.png",
|
|
142
|
+
"train/images/ebeaa451-9287-4df7-9c40-07eb25cadb78.png",
|
|
143
|
+
"train/labels/",
|
|
144
|
+
"train/labels/98115546-df07-448c-a2f0-34aa24789b77.png",
|
|
145
|
+
"train/labels/ebeaa451-9287-4df7-9c40-07eb25cadb78.png",
|
|
146
|
+
"train/labels_json/",
|
|
147
|
+
"train/labels_json/98115546-df07-448c-a2f0-34aa24789b77.json",
|
|
148
|
+
"train/labels_json/ebeaa451-9287-4df7-9c40-07eb25cadb78.json",
|
|
149
|
+
"val/",
|
|
150
|
+
"val/images/",
|
|
151
|
+
"val/images/2987176d-4338-40f2-90d9-6d2cb4fd4a00.png",
|
|
152
|
+
"val/images/e3f91312-9201-45b7-9c32-e04a97ff1334.png",
|
|
153
|
+
"val/labels/",
|
|
154
|
+
"val/labels/2987176d-4338-40f2-90d9-6d2cb4fd4a00.png",
|
|
155
|
+
"val/labels/e3f91312-9201-45b7-9c32-e04a97ff1334.png",
|
|
156
|
+
"val/labels_json/",
|
|
157
|
+
"val/labels_json/2987176d-4338-40f2-90d9-6d2cb4fd4a00.json",
|
|
158
|
+
"val/labels_json/e3f91312-9201-45b7-9c32-e04a97ff1334.json",
|
|
159
|
+
]
|
|
160
|
+
|
|
161
|
+
# Cleanup
|
|
162
|
+
archive.unlink()
|
|
File without changes
|
{arkindex_base_worker-0.5.1rc1.dist-info → arkindex_base_worker-0.5.1rc2.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{arkindex_base_worker-0.5.1rc1.dist-info → arkindex_base_worker-0.5.1rc2.dist-info}/top_level.txt
RENAMED
|
File without changes
|