arkindex-base-worker 0.5.1rc1__tar.gz → 0.5.1rc2__tar.gz

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.
Files changed (66) hide show
  1. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/PKG-INFO +1 -1
  2. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/arkindex_base_worker.egg-info/PKG-INFO +1 -1
  3. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/arkindex_worker/utils.py +27 -0
  4. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/pyproject.toml +1 -1
  5. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/tests/test_utils.py +42 -0
  6. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/LICENSE +0 -0
  7. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/README.md +0 -0
  8. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/arkindex_base_worker.egg-info/SOURCES.txt +0 -0
  9. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/arkindex_base_worker.egg-info/dependency_links.txt +0 -0
  10. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/arkindex_base_worker.egg-info/requires.txt +0 -0
  11. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/arkindex_base_worker.egg-info/top_level.txt +0 -0
  12. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/arkindex_worker/__init__.py +0 -0
  13. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/arkindex_worker/cache.py +0 -0
  14. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/arkindex_worker/image.py +0 -0
  15. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/arkindex_worker/models.py +0 -0
  16. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/arkindex_worker/worker/__init__.py +0 -0
  17. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/arkindex_worker/worker/base.py +0 -0
  18. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/arkindex_worker/worker/classification.py +0 -0
  19. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/arkindex_worker/worker/corpus.py +0 -0
  20. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/arkindex_worker/worker/dataset.py +0 -0
  21. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/arkindex_worker/worker/element.py +0 -0
  22. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/arkindex_worker/worker/entity.py +0 -0
  23. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/arkindex_worker/worker/image.py +0 -0
  24. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/arkindex_worker/worker/metadata.py +0 -0
  25. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/arkindex_worker/worker/process.py +0 -0
  26. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/arkindex_worker/worker/task.py +0 -0
  27. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/arkindex_worker/worker/training.py +0 -0
  28. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/arkindex_worker/worker/transcription.py +0 -0
  29. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/examples/standalone/python/worker.py +0 -0
  30. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/examples/tooled/python/worker.py +0 -0
  31. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/hooks/pre_gen_project.py +0 -0
  32. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/setup.cfg +0 -0
  33. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/tests/__init__.py +0 -0
  34. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/tests/conftest.py +0 -0
  35. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/tests/test_base_worker.py +0 -0
  36. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/tests/test_cache.py +0 -0
  37. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/tests/test_dataset_worker.py +0 -0
  38. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/tests/test_element.py +0 -0
  39. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/tests/test_elements_worker/__init__.py +0 -0
  40. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/tests/test_elements_worker/test_classification.py +0 -0
  41. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/tests/test_elements_worker/test_cli.py +0 -0
  42. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/tests/test_elements_worker/test_corpus.py +0 -0
  43. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/tests/test_elements_worker/test_dataset.py +0 -0
  44. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/tests/test_elements_worker/test_element.py +0 -0
  45. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/tests/test_elements_worker/test_element_create_multiple.py +0 -0
  46. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/tests/test_elements_worker/test_element_create_single.py +0 -0
  47. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/tests/test_elements_worker/test_element_list_children.py +0 -0
  48. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/tests/test_elements_worker/test_element_list_parents.py +0 -0
  49. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/tests/test_elements_worker/test_entity.py +0 -0
  50. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/tests/test_elements_worker/test_image.py +0 -0
  51. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/tests/test_elements_worker/test_metadata.py +0 -0
  52. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/tests/test_elements_worker/test_process.py +0 -0
  53. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/tests/test_elements_worker/test_task.py +0 -0
  54. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/tests/test_elements_worker/test_training.py +0 -0
  55. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/tests/test_elements_worker/test_transcription_create.py +0 -0
  56. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/tests/test_elements_worker/test_transcription_create_with_elements.py +0 -0
  57. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/tests/test_elements_worker/test_transcription_list.py +0 -0
  58. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/tests/test_elements_worker/test_worker.py +0 -0
  59. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/tests/test_image.py +0 -0
  60. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/tests/test_merge.py +0 -0
  61. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/tests/test_modern_config.py +0 -0
  62. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/worker-demo/tests/__init__.py +0 -0
  63. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/worker-demo/tests/conftest.py +0 -0
  64. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/worker-demo/tests/test_worker.py +0 -0
  65. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/worker-demo/worker_demo/__init__.py +0 -0
  66. {arkindex_base_worker-0.5.1rc1 → arkindex_base_worker-0.5.1rc2}/worker-demo/worker_demo/worker.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: arkindex-base-worker
3
- Version: 0.5.1rc1
3
+ Version: 0.5.1rc2
4
4
  Summary: Base Worker to easily build Arkindex ML workflows
5
5
  Author-email: Teklia <contact@teklia.com>
6
6
  Maintainer-email: Teklia <contact@teklia.com>
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: arkindex-base-worker
3
- Version: 0.5.1rc1
3
+ Version: 0.5.1rc2
4
4
  Summary: Base Worker to easily build Arkindex ML workflows
5
5
  Author-email: Teklia <contact@teklia.com>
6
6
  Maintainer-email: Teklia <contact@teklia.com>
@@ -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
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "arkindex-base-worker"
7
- version = "0.5.1rc1"
7
+ version = "0.5.1rc2"
8
8
  description = "Base Worker to easily build Arkindex ML workflows"
9
9
  license = { file = "LICENSE" }
10
10
  dependencies = [
@@ -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()