arkindex-base-worker 0.3.7rc10__py3-none-any.whl → 0.4.0__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.3.7rc10.dist-info → arkindex_base_worker-0.4.0.dist-info}/METADATA +16 -20
- arkindex_base_worker-0.4.0.dist-info/RECORD +61 -0
- {arkindex_base_worker-0.3.7rc10.dist-info → arkindex_base_worker-0.4.0.dist-info}/WHEEL +1 -1
- arkindex_worker/cache.py +1 -1
- arkindex_worker/image.py +120 -1
- arkindex_worker/models.py +6 -0
- arkindex_worker/utils.py +85 -4
- arkindex_worker/worker/__init__.py +68 -162
- arkindex_worker/worker/base.py +39 -34
- arkindex_worker/worker/classification.py +34 -18
- arkindex_worker/worker/corpus.py +86 -0
- arkindex_worker/worker/dataset.py +71 -1
- arkindex_worker/worker/element.py +352 -91
- arkindex_worker/worker/entity.py +11 -11
- arkindex_worker/worker/image.py +21 -0
- arkindex_worker/worker/metadata.py +19 -9
- arkindex_worker/worker/process.py +92 -0
- arkindex_worker/worker/task.py +5 -4
- arkindex_worker/worker/training.py +25 -10
- arkindex_worker/worker/transcription.py +89 -68
- arkindex_worker/worker/version.py +3 -1
- tests/__init__.py +8 -0
- tests/conftest.py +36 -52
- tests/test_base_worker.py +212 -12
- tests/test_dataset_worker.py +21 -45
- tests/test_elements_worker/{test_classifications.py → test_classification.py} +216 -100
- tests/test_elements_worker/test_cli.py +3 -11
- tests/test_elements_worker/test_corpus.py +168 -0
- tests/test_elements_worker/test_dataset.py +7 -12
- tests/test_elements_worker/test_element.py +427 -0
- tests/test_elements_worker/test_element_create_multiple.py +715 -0
- tests/test_elements_worker/test_element_create_single.py +528 -0
- tests/test_elements_worker/test_element_list_children.py +969 -0
- tests/test_elements_worker/test_element_list_parents.py +530 -0
- tests/test_elements_worker/{test_entities.py → test_entity_create.py} +37 -195
- tests/test_elements_worker/test_entity_list_and_check.py +160 -0
- tests/test_elements_worker/test_image.py +66 -0
- tests/test_elements_worker/test_metadata.py +230 -139
- tests/test_elements_worker/test_process.py +89 -0
- tests/test_elements_worker/test_task.py +8 -18
- tests/test_elements_worker/test_training.py +17 -8
- tests/test_elements_worker/test_transcription_create.py +873 -0
- tests/test_elements_worker/test_transcription_create_with_elements.py +951 -0
- tests/test_elements_worker/test_transcription_list.py +450 -0
- tests/test_elements_worker/test_version.py +60 -0
- tests/test_elements_worker/test_worker.py +563 -279
- tests/test_image.py +432 -209
- tests/test_merge.py +1 -2
- tests/test_utils.py +66 -3
- arkindex_base_worker-0.3.7rc10.dist-info/RECORD +0 -47
- tests/test_elements_worker/test_elements.py +0 -2713
- tests/test_elements_worker/test_transcriptions.py +0 -2119
- {arkindex_base_worker-0.3.7rc10.dist-info → arkindex_base_worker-0.4.0.dist-info}/LICENSE +0 -0
- {arkindex_base_worker-0.3.7rc10.dist-info → arkindex_base_worker-0.4.0.dist-info}/top_level.txt +0 -0
tests/test_merge.py
CHANGED
|
@@ -161,7 +161,7 @@ def test_merge_from_worker(
|
|
|
161
161
|
"""
|
|
162
162
|
responses.add(
|
|
163
163
|
responses.GET,
|
|
164
|
-
"http://testserver/api/v1/task/my_task/
|
|
164
|
+
"http://testserver/api/v1/task/my_task/",
|
|
165
165
|
status=200,
|
|
166
166
|
json={"parents": ["first", "second"]},
|
|
167
167
|
)
|
|
@@ -181,7 +181,6 @@ def test_merge_from_worker(
|
|
|
181
181
|
(tmp_path / "my_task").mkdir()
|
|
182
182
|
mock_base_worker_with_cache.args = mock_base_worker_with_cache.parser.parse_args()
|
|
183
183
|
mock_base_worker_with_cache.configure()
|
|
184
|
-
mock_base_worker_with_cache.configure_cache()
|
|
185
184
|
# Store parent tasks IDs as attribute
|
|
186
185
|
assert mock_base_worker_with_cache.task_parents == ["first", "second"]
|
|
187
186
|
|
tests/test_utils.py
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
import logging
|
|
2
2
|
|
|
3
3
|
import pytest
|
|
4
4
|
|
|
5
|
+
from arkindex_worker.cache import unsupported_cache
|
|
5
6
|
from arkindex_worker.utils import (
|
|
7
|
+
DEFAULT_BATCH_SIZE,
|
|
8
|
+
batch_publication,
|
|
6
9
|
close_delete_file,
|
|
7
10
|
extract_tar_zst_archive,
|
|
8
11
|
parse_source_id,
|
|
9
12
|
)
|
|
13
|
+
from tests import FIXTURES_DIR
|
|
10
14
|
|
|
11
|
-
|
|
12
|
-
ARCHIVE = FIXTURES / "archive.tar.zst"
|
|
15
|
+
ARCHIVE = FIXTURES_DIR / "archive.tar.zst"
|
|
13
16
|
|
|
14
17
|
|
|
15
18
|
@pytest.mark.parametrize(
|
|
@@ -55,3 +58,63 @@ def test_close_delete_file(tmp_path):
|
|
|
55
58
|
close_delete_file(archive_fd, archive_path)
|
|
56
59
|
|
|
57
60
|
assert not archive_path.exists()
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class TestMixin:
|
|
64
|
+
def __init__(self, use_cache: bool = False):
|
|
65
|
+
"""
|
|
66
|
+
Args:
|
|
67
|
+
use_cache (bool, optional): To mock BaseWorker.use_cache attribute. Defaults to False.
|
|
68
|
+
"""
|
|
69
|
+
self.use_cache = use_cache
|
|
70
|
+
|
|
71
|
+
@batch_publication
|
|
72
|
+
def custom_publication_in_batches(self, batch_size: int = DEFAULT_BATCH_SIZE):
|
|
73
|
+
return batch_size
|
|
74
|
+
|
|
75
|
+
@unsupported_cache
|
|
76
|
+
@batch_publication
|
|
77
|
+
def custom_publication_in_batches_without_cache(
|
|
78
|
+
self, batch_size: int = DEFAULT_BATCH_SIZE
|
|
79
|
+
):
|
|
80
|
+
return batch_size
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def test_batch_publication_decorator_no_parameter():
|
|
84
|
+
assert TestMixin().custom_publication_in_batches() == DEFAULT_BATCH_SIZE
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
@pytest.mark.parametrize("wrong_batch_size", [None, "not an int", 0])
|
|
88
|
+
def test_batch_publication_decorator_wrong_parameter(wrong_batch_size):
|
|
89
|
+
with pytest.raises(
|
|
90
|
+
AssertionError,
|
|
91
|
+
match="batch_size shouldn't be null and should be a strictly positive integer",
|
|
92
|
+
):
|
|
93
|
+
TestMixin().custom_publication_in_batches(batch_size=wrong_batch_size)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
@pytest.mark.parametrize("batch_size", [1, 10, DEFAULT_BATCH_SIZE])
|
|
97
|
+
def test_batch_publication_decorator_right_parameter(batch_size):
|
|
98
|
+
assert (
|
|
99
|
+
TestMixin().custom_publication_in_batches(batch_size=batch_size) == batch_size
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def test_batch_publication_decorator_alongside_unsupported_cache(caplog):
|
|
104
|
+
# Capture log messages
|
|
105
|
+
caplog.clear()
|
|
106
|
+
with caplog.at_level(logging.WARNING):
|
|
107
|
+
# Call the helper
|
|
108
|
+
assert (
|
|
109
|
+
TestMixin(use_cache=True).custom_publication_in_batches_without_cache()
|
|
110
|
+
== DEFAULT_BATCH_SIZE
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
# Check logs
|
|
114
|
+
assert caplog.record_tuples == [
|
|
115
|
+
(
|
|
116
|
+
"arkindex_worker",
|
|
117
|
+
logging.WARNING,
|
|
118
|
+
"This API helper `custom_publication_in_batches_without_cache` did not update the cache database",
|
|
119
|
+
),
|
|
120
|
+
]
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
arkindex_worker/__init__.py,sha256=OlgCtTC9MaWeejviY0a3iQpALcRQGMVArFVVYwTF6I8,162
|
|
2
|
-
arkindex_worker/cache.py,sha256=FTlB0coXofn5zTNRTcVIvh709mcw4a1bPGqkwWjKs3w,11248
|
|
3
|
-
arkindex_worker/image.py,sha256=5ymIGaTm2D7Sp2YYQkbuheuGnx5VJo0_AzYAEIvNGhs,14267
|
|
4
|
-
arkindex_worker/models.py,sha256=xSvOadkNg3rgccic1xLgonzP28ugzmcGw0IUqXn51Cc,9844
|
|
5
|
-
arkindex_worker/utils.py,sha256=0Mu7Fa8DVcHn19pg-FIXqMDpfgzQkb7QR9IAlAi-x_k,7243
|
|
6
|
-
arkindex_worker/worker/__init__.py,sha256=U-_zOrQ09xmpBF9SmrTVj_UwnsCjFueV5G2hJAFEwv0,18806
|
|
7
|
-
arkindex_worker/worker/base.py,sha256=qtkCGfpGn7SWsQZRJ5cpW0gQ4tV_cyR_AHbuHZr53z4,19585
|
|
8
|
-
arkindex_worker/worker/classification.py,sha256=JVz-6YEeuavOy7zGfQi4nE_wpj9hwMUZDXTem-hXQY8,10328
|
|
9
|
-
arkindex_worker/worker/dataset.py,sha256=roX2IMMNA-icteTtRADiFSZiZSRPClqS62ZPJm9s2JI,2923
|
|
10
|
-
arkindex_worker/worker/element.py,sha256=AWK3YJSHWy3j4ajntJloi_2X4zxsgXZ6c6dzphgq3OI,33848
|
|
11
|
-
arkindex_worker/worker/entity.py,sha256=suhycfikC9oTPEWmX48_cnvFEw-Wu5zBA8n_00K4KUk,14714
|
|
12
|
-
arkindex_worker/worker/metadata.py,sha256=Bouuc_JaXogKykVXOTKDVP3tX--OUQeHoazxIGrGrJI,6702
|
|
13
|
-
arkindex_worker/worker/task.py,sha256=cz3wJNPgogZv1lm_3lm7WScitQtYQtL6H6I7Xokq208,1475
|
|
14
|
-
arkindex_worker/worker/training.py,sha256=SOs3YKGikTr3rdWYp9H-jbtgRnZxQAoqtwB26ztx9j8,10235
|
|
15
|
-
arkindex_worker/worker/transcription.py,sha256=6R7ofcGnNqX4rjT0kRKIE-G9FHq2TJ1tfztNM5sTqYE,20464
|
|
16
|
-
arkindex_worker/worker/version.py,sha256=cs2pdlDxpKRO2Oldvcu54w-D_DQhf1cdeEt4tKX_QYs,1927
|
|
17
|
-
hooks/pre_gen_project.py,sha256=xQJERv3vv9VzIqcBHI281eeWLWREXUF4mMw7PvJHHXM,269
|
|
18
|
-
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
|
-
tests/conftest.py,sha256=Oi5SJic4TNwDj8Pm0WHgg657yB7_JKxbLC0HYPI3RUc,22134
|
|
20
|
-
tests/test_base_worker.py,sha256=Uq6_MpLW23gmKFXkU-SyDUaA_4dlViLBGG4e3gpBBz0,24512
|
|
21
|
-
tests/test_cache.py,sha256=ii0gyr0DrG7ChEs7pmT8hMdSguAOAcCze4bRMiFQxuk,10640
|
|
22
|
-
tests/test_dataset_worker.py,sha256=1joFRFmkL6XfPL9y1NYB_5QO-5FF56rwigAHrqtJMMA,23848
|
|
23
|
-
tests/test_element.py,sha256=2G9M15TLxQRmvrWM9Kw2ucnElh4kSv_oF_5FYwwAxTY,13181
|
|
24
|
-
tests/test_image.py,sha256=FZv8njLxh45sVgmY71UFHt0lv1cHr0cK4rrtPhQleX8,16262
|
|
25
|
-
tests/test_merge.py,sha256=Q4zCbtZbe0wBfqE56gvAD06c6pDuhqnjKaioFqIgAQw,8331
|
|
26
|
-
tests/test_utils.py,sha256=vpeHMeL7bJQonv5ZEbJmlJikqVKn5VWlVEbvmYFzDYA,1650
|
|
27
|
-
tests/test_elements_worker/__init__.py,sha256=Fh4nkbbyJSMv_VtjQxnWrOqTnxXaaWI8S9WU0VrzCHs,179
|
|
28
|
-
tests/test_elements_worker/test_classifications.py,sha256=vU6al1THtDSmERyVscMXaqiRPwTllcpRUHyeyBQ8M9U,26417
|
|
29
|
-
tests/test_elements_worker/test_cli.py,sha256=BsFTswLti63WAZ2pf6ipiZKWJJyCQuSfuKnSlESuK8g,2878
|
|
30
|
-
tests/test_elements_worker/test_dataset.py,sha256=hityecntzrldkuBHBWApYDkXSzSySdG3AZXJlM_sCOM,11777
|
|
31
|
-
tests/test_elements_worker/test_elements.py,sha256=6XKtgXSVQJnTSgTHWwEVsAtIwLBapjYjUYPUdjxcHsY,84971
|
|
32
|
-
tests/test_elements_worker/test_entities.py,sha256=yi1mXzvKvNwUNMzo0UZ56YOIJstYHcLyeepPJ8f10MQ,34557
|
|
33
|
-
tests/test_elements_worker/test_metadata.py,sha256=YMYmkUSEp4WKNBm3QLcrg4yn6qVTWQ_aZzSu9Xygr80,18756
|
|
34
|
-
tests/test_elements_worker/test_task.py,sha256=FCpxE9UpouKXgjGvWgNHEai_Hiy2d1YmqRG-_v2s27s,6312
|
|
35
|
-
tests/test_elements_worker/test_training.py,sha256=WeG-cDuJ-YhPgfKH47TtXBxyargtLuk7c8tsik2WnL8,8414
|
|
36
|
-
tests/test_elements_worker/test_transcriptions.py,sha256=WVJG26sZyY66fu-Eka9A1_WWIeNI2scogjypzURnp8A,73468
|
|
37
|
-
tests/test_elements_worker/test_worker.py,sha256=7-jGJVT3yMGpIyN96Uafz5eIUrO4ieNLgw0k1D8BhGc,17163
|
|
38
|
-
worker-demo/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
39
|
-
worker-demo/tests/conftest.py,sha256=XzNMNeg6pmABUAH8jN6eZTlZSFGLYjS3-DTXjiRN6Yc,1002
|
|
40
|
-
worker-demo/tests/test_worker.py,sha256=3DLd4NRK4bfyatG5P_PK4k9P9tJHx9XQq5_ryFEEFVg,304
|
|
41
|
-
worker-demo/worker_demo/__init__.py,sha256=2BPomV8ZMNf3YXJgloatKeHQCE6QOkwmsHGkO6MkQuM,125
|
|
42
|
-
worker-demo/worker_demo/worker.py,sha256=Rt-DjWa5iBP08k58NDZMfeyPuFbtNcbX6nc5jFX7GNo,440
|
|
43
|
-
arkindex_base_worker-0.3.7rc10.dist-info/LICENSE,sha256=NVshRi1efwVezMfW7xXYLrdDr2Li1AfwfGOd5WuH1kQ,1063
|
|
44
|
-
arkindex_base_worker-0.3.7rc10.dist-info/METADATA,sha256=2o2yKl7p5h3ZPrMDZTnkXabR5WNGsmBCDwA7v8uAHyo,3563
|
|
45
|
-
arkindex_base_worker-0.3.7rc10.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
46
|
-
arkindex_base_worker-0.3.7rc10.dist-info/top_level.txt,sha256=58NuslgxQC2vT4DiqZEgO4JqJRrYa2yeNI9QvkbfGQU,40
|
|
47
|
-
arkindex_base_worker-0.3.7rc10.dist-info/RECORD,,
|