arkindex-base-worker 0.4.0rc3__py3-none-any.whl → 0.4.0rc4__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.4.0rc3.dist-info → arkindex_base_worker-0.4.0rc4.dist-info}/METADATA +15 -14
- {arkindex_base_worker-0.4.0rc3.dist-info → arkindex_base_worker-0.4.0rc4.dist-info}/RECORD +21 -13
- {arkindex_base_worker-0.4.0rc3.dist-info → arkindex_base_worker-0.4.0rc4.dist-info}/WHEEL +1 -1
- arkindex_worker/cache.py +1 -1
- tests/test_elements_worker/{test_classifications.py → test_classification.py} +86 -0
- tests/test_elements_worker/test_corpus.py +31 -31
- 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} +0 -153
- tests/test_elements_worker/test_entity_list_and_check.py +160 -0
- 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 +525 -88
- tests/test_image.py +181 -198
- tests/test_elements_worker/test_elements.py +0 -3704
- tests/test_elements_worker/test_transcriptions.py +0 -2252
- {arkindex_base_worker-0.4.0rc3.dist-info → arkindex_base_worker-0.4.0rc4.dist-info}/LICENSE +0 -0
- {arkindex_base_worker-0.4.0rc3.dist-info → arkindex_base_worker-0.4.0rc4.dist-info}/top_level.txt +0 -0
{arkindex_base_worker-0.4.0rc3.dist-info → arkindex_base_worker-0.4.0rc4.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: arkindex-base-worker
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.0rc4
|
|
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>
|
|
@@ -37,24 +37,25 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
37
37
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
38
38
|
Classifier: Programming Language :: Python :: 3.10
|
|
39
39
|
Classifier: Programming Language :: Python :: 3.11
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
40
41
|
Requires-Python: >=3.10
|
|
41
42
|
Description-Content-Type: text/markdown
|
|
42
43
|
License-File: LICENSE
|
|
43
|
-
Requires-Dist: humanize
|
|
44
|
-
Requires-Dist: peewee
|
|
45
|
-
Requires-Dist: Pillow
|
|
46
|
-
Requires-Dist: python-gnupg
|
|
47
|
-
Requires-Dist: shapely
|
|
48
|
-
Requires-Dist: teklia-toolbox
|
|
49
|
-
Requires-Dist: zstandard
|
|
44
|
+
Requires-Dist: humanize==4.10.0
|
|
45
|
+
Requires-Dist: peewee~=3.17
|
|
46
|
+
Requires-Dist: Pillow==10.4.0
|
|
47
|
+
Requires-Dist: python-gnupg==0.5.2
|
|
48
|
+
Requires-Dist: shapely==2.0.6
|
|
49
|
+
Requires-Dist: teklia-toolbox==0.1.7b1
|
|
50
|
+
Requires-Dist: zstandard==0.22.0
|
|
50
51
|
Provides-Extra: docs
|
|
51
|
-
Requires-Dist: black
|
|
52
|
-
Requires-Dist: mkdocs-material
|
|
53
|
-
Requires-Dist: mkdocstrings-python
|
|
52
|
+
Requires-Dist: black==24.4.2; extra == "docs"
|
|
53
|
+
Requires-Dist: mkdocs-material==9.5.33; extra == "docs"
|
|
54
|
+
Requires-Dist: mkdocstrings-python==1.11.1; extra == "docs"
|
|
54
55
|
Provides-Extra: tests
|
|
55
|
-
Requires-Dist: pytest
|
|
56
|
-
Requires-Dist: pytest-mock
|
|
57
|
-
Requires-Dist: pytest-responses
|
|
56
|
+
Requires-Dist: pytest==8.3.2; extra == "tests"
|
|
57
|
+
Requires-Dist: pytest-mock==3.14.0; extra == "tests"
|
|
58
|
+
Requires-Dist: pytest-responses==0.5.1; extra == "tests"
|
|
58
59
|
|
|
59
60
|
# Arkindex base Worker
|
|
60
61
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
arkindex_worker/__init__.py,sha256=OlgCtTC9MaWeejviY0a3iQpALcRQGMVArFVVYwTF6I8,162
|
|
2
|
-
arkindex_worker/cache.py,sha256=
|
|
2
|
+
arkindex_worker/cache.py,sha256=qTblc_zKdYC47Wip6_O9Jf5qBkQW2ozQQrg-nsx1WuY,11221
|
|
3
3
|
arkindex_worker/image.py,sha256=oEgVCrSHiGh3D5-UXfM6PvT17TttSxC0115irpvB3Dw,18581
|
|
4
4
|
arkindex_worker/models.py,sha256=bPQzGZNs5a6z6DEcygsa8T33VOqPlMUbwKzHqlKzwbw,9923
|
|
5
5
|
arkindex_worker/utils.py,sha256=q1EeLdC6ebYIH-C0LOAqw2cNpjCjVoP-Vbr-39mF4w0,9884
|
|
@@ -24,29 +24,37 @@ tests/test_base_worker.py,sha256=2EIYcd_3f9O0zB5WiGIQV0Cn9wndLvnEnSfcAE1qWWU,306
|
|
|
24
24
|
tests/test_cache.py,sha256=ii0gyr0DrG7ChEs7pmT8hMdSguAOAcCze4bRMiFQxuk,10640
|
|
25
25
|
tests/test_dataset_worker.py,sha256=gApYz0LArHr1cNn079_fa_BQABF6RVQYuM1Tc4m3NsQ,22089
|
|
26
26
|
tests/test_element.py,sha256=2G9M15TLxQRmvrWM9Kw2ucnElh4kSv_oF_5FYwwAxTY,13181
|
|
27
|
-
tests/test_image.py,sha256=
|
|
27
|
+
tests/test_image.py,sha256=03E24JVa7TZJfuwQyfVEBe3RAq3R993IMl1AHXRr7zY,25497
|
|
28
28
|
tests/test_merge.py,sha256=TuOeUS0UCz66DPOQFFhc4NQBxIjZL9f5czi4XnvGrr4,8270
|
|
29
29
|
tests/test_utils.py,sha256=_WJUPnt-pM_TQ0er4yjPZy-u_LePrHq1lxwk_teky7M,2544
|
|
30
30
|
tests/test_elements_worker/__init__.py,sha256=Fh4nkbbyJSMv_VtjQxnWrOqTnxXaaWI8S9WU0VrzCHs,179
|
|
31
|
-
tests/test_elements_worker/
|
|
31
|
+
tests/test_elements_worker/test_classification.py,sha256=nya7veSPR_O9G41Enodp2-o6AifMBcaSTWJP2vXSSJ4,30133
|
|
32
32
|
tests/test_elements_worker/test_cli.py,sha256=a23i1pUDbXi23MUtbWwGEcLLrmc_YlrbDgOG3h66wLM,2620
|
|
33
|
-
tests/test_elements_worker/test_corpus.py,sha256=
|
|
33
|
+
tests/test_elements_worker/test_corpus.py,sha256=kscJyM8k1njYJJFGuvliVzn89lWh41mEyDCCawnp3W8,5483
|
|
34
34
|
tests/test_elements_worker/test_dataset.py,sha256=00IlOZv9YFlZ23rGXyR-HLbKLQxGelZ1Bf9lEZYA0IY,11412
|
|
35
|
-
tests/test_elements_worker/
|
|
36
|
-
tests/test_elements_worker/
|
|
35
|
+
tests/test_elements_worker/test_element.py,sha256=lb5tLjl0jsixX0OWVhBAaKLE9GKkBw79kFHDNGommaQ,12535
|
|
36
|
+
tests/test_elements_worker/test_element_create_multiple.py,sha256=arYFGmxc0517ZUii6k__G_UQQatuNIASTC8MXvUrSwk,21887
|
|
37
|
+
tests/test_elements_worker/test_element_create_single.py,sha256=Fa9zm12J2rQ3VrUe3yIlHAc7Vty_eQYb_YGnNPQB3IE,16697
|
|
38
|
+
tests/test_elements_worker/test_element_list_children.py,sha256=2zH4h663w3EduqpzQr-7bf9zIDzO1x2WxdUYYHsIHkI,31358
|
|
39
|
+
tests/test_elements_worker/test_element_list_parents.py,sha256=TXeGW-a3W-7GmB2QrhJH9mMnvxuybeAwQ4tL3iIxwXo,16734
|
|
40
|
+
tests/test_elements_worker/test_entity_create.py,sha256=TkEoQDmwuP1AlSYf42WXJVMMa0lIEPMn6PGy5ExA_5c,31343
|
|
41
|
+
tests/test_elements_worker/test_entity_list_and_check.py,sha256=ENBLaqbXlRUDbHRvQla3080a0HJltrWAPYWNohUA9NU,4992
|
|
37
42
|
tests/test_elements_worker/test_image.py,sha256=BljMNKgec_9a5bzNzFpYZIvSbuvwsWDfdqLHVJaTa7M,2079
|
|
38
43
|
tests/test_elements_worker/test_metadata.py,sha256=Xfggy-vxw5DZ3hFKx3sB7OYb2d1tu1RiNK8fvKJIaBs,22294
|
|
39
44
|
tests/test_elements_worker/test_task.py,sha256=wTUWqN9UhfKmJn3IcFY75EW4I1ulRhisflmY1kmP47s,5574
|
|
40
45
|
tests/test_elements_worker/test_training.py,sha256=Qxi9EzGr_uKcn2Fh5aE6jNrq1K8QKLiOiSew4upASPs,8721
|
|
41
|
-
tests/test_elements_worker/
|
|
42
|
-
tests/test_elements_worker/
|
|
46
|
+
tests/test_elements_worker/test_transcription_create.py,sha256=yznO9B_BVsOR0Z_VY5ZL8gJp0ZPCz_4sPUs5dXtixAg,29281
|
|
47
|
+
tests/test_elements_worker/test_transcription_create_with_elements.py,sha256=tmcyglgssEqMnt1Mdy_u6X1m2wgLWTo_HdWst3GrK2k,33056
|
|
48
|
+
tests/test_elements_worker/test_transcription_list.py,sha256=ikz7HYPCoQWTdTRCd382SB-y-T2BbigPLlIcx5Eow-I,15324
|
|
49
|
+
tests/test_elements_worker/test_version.py,sha256=xqCgcgukTFJzkMgYfQG-8mTbu0o2fdYjWC07FktThfw,2125
|
|
50
|
+
tests/test_elements_worker/test_worker.py,sha256=fnFwkcDb6tx5i7lbelifeHD-BrGz6o5UBEojPCdtuAo,23474
|
|
43
51
|
worker-demo/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
44
52
|
worker-demo/tests/conftest.py,sha256=XzNMNeg6pmABUAH8jN6eZTlZSFGLYjS3-DTXjiRN6Yc,1002
|
|
45
53
|
worker-demo/tests/test_worker.py,sha256=3DLd4NRK4bfyatG5P_PK4k9P9tJHx9XQq5_ryFEEFVg,304
|
|
46
54
|
worker-demo/worker_demo/__init__.py,sha256=2BPomV8ZMNf3YXJgloatKeHQCE6QOkwmsHGkO6MkQuM,125
|
|
47
55
|
worker-demo/worker_demo/worker.py,sha256=Rt-DjWa5iBP08k58NDZMfeyPuFbtNcbX6nc5jFX7GNo,440
|
|
48
|
-
arkindex_base_worker-0.4.
|
|
49
|
-
arkindex_base_worker-0.4.
|
|
50
|
-
arkindex_base_worker-0.4.
|
|
51
|
-
arkindex_base_worker-0.4.
|
|
52
|
-
arkindex_base_worker-0.4.
|
|
56
|
+
arkindex_base_worker-0.4.0rc4.dist-info/LICENSE,sha256=NVshRi1efwVezMfW7xXYLrdDr2Li1AfwfGOd5WuH1kQ,1063
|
|
57
|
+
arkindex_base_worker-0.4.0rc4.dist-info/METADATA,sha256=Du-kBAZ-QL6SjvASaOK1Nxsw8yqN8Efx4L1JR-dA720,3338
|
|
58
|
+
arkindex_base_worker-0.4.0rc4.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
|
59
|
+
arkindex_base_worker-0.4.0rc4.dist-info/top_level.txt,sha256=58NuslgxQC2vT4DiqZEgO4JqJRrYa2yeNI9QvkbfGQU,40
|
|
60
|
+
arkindex_base_worker-0.4.0rc4.dist-info/RECORD,,
|
arkindex_worker/cache.py
CHANGED
|
@@ -380,7 +380,7 @@ def unsupported_cache(func):
|
|
|
380
380
|
def wrapper(self, *args, **kwargs):
|
|
381
381
|
results = func(self, *args, **kwargs)
|
|
382
382
|
|
|
383
|
-
if
|
|
383
|
+
if self.use_cache:
|
|
384
384
|
logger.warning(
|
|
385
385
|
f"This API helper `{func.__name__}` did not update the cache database"
|
|
386
386
|
)
|
|
@@ -17,6 +17,92 @@ from . import BASE_API_CALLS
|
|
|
17
17
|
DELETE_PARAMETER = "DELETE_PARAMETER"
|
|
18
18
|
|
|
19
19
|
|
|
20
|
+
def test_load_corpus_classes_api_error(responses, mock_elements_worker):
|
|
21
|
+
responses.add(
|
|
22
|
+
responses.GET,
|
|
23
|
+
f"http://testserver/api/v1/corpus/{CORPUS_ID}/classes/",
|
|
24
|
+
status=418,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
assert not mock_elements_worker.classes
|
|
28
|
+
with pytest.raises(
|
|
29
|
+
Exception, match="Stopping pagination as data will be incomplete"
|
|
30
|
+
):
|
|
31
|
+
mock_elements_worker.load_corpus_classes()
|
|
32
|
+
|
|
33
|
+
assert len(responses.calls) == len(BASE_API_CALLS) + 5
|
|
34
|
+
assert [
|
|
35
|
+
(call.request.method, call.request.url) for call in responses.calls
|
|
36
|
+
] == BASE_API_CALLS + [
|
|
37
|
+
# We do 5 retries
|
|
38
|
+
(
|
|
39
|
+
"GET",
|
|
40
|
+
f"http://testserver/api/v1/corpus/{CORPUS_ID}/classes/",
|
|
41
|
+
),
|
|
42
|
+
(
|
|
43
|
+
"GET",
|
|
44
|
+
f"http://testserver/api/v1/corpus/{CORPUS_ID}/classes/",
|
|
45
|
+
),
|
|
46
|
+
(
|
|
47
|
+
"GET",
|
|
48
|
+
f"http://testserver/api/v1/corpus/{CORPUS_ID}/classes/",
|
|
49
|
+
),
|
|
50
|
+
(
|
|
51
|
+
"GET",
|
|
52
|
+
f"http://testserver/api/v1/corpus/{CORPUS_ID}/classes/",
|
|
53
|
+
),
|
|
54
|
+
(
|
|
55
|
+
"GET",
|
|
56
|
+
f"http://testserver/api/v1/corpus/{CORPUS_ID}/classes/",
|
|
57
|
+
),
|
|
58
|
+
]
|
|
59
|
+
assert not mock_elements_worker.classes
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def test_load_corpus_classes(responses, mock_elements_worker):
|
|
63
|
+
responses.add(
|
|
64
|
+
responses.GET,
|
|
65
|
+
f"http://testserver/api/v1/corpus/{CORPUS_ID}/classes/",
|
|
66
|
+
status=200,
|
|
67
|
+
json={
|
|
68
|
+
"count": 3,
|
|
69
|
+
"next": None,
|
|
70
|
+
"results": [
|
|
71
|
+
{
|
|
72
|
+
"id": "0000",
|
|
73
|
+
"name": "good",
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"id": "1111",
|
|
77
|
+
"name": "average",
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"id": "2222",
|
|
81
|
+
"name": "bad",
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
assert not mock_elements_worker.classes
|
|
88
|
+
mock_elements_worker.load_corpus_classes()
|
|
89
|
+
|
|
90
|
+
assert len(responses.calls) == len(BASE_API_CALLS) + 1
|
|
91
|
+
assert [
|
|
92
|
+
(call.request.method, call.request.url) for call in responses.calls
|
|
93
|
+
] == BASE_API_CALLS + [
|
|
94
|
+
(
|
|
95
|
+
"GET",
|
|
96
|
+
f"http://testserver/api/v1/corpus/{CORPUS_ID}/classes/",
|
|
97
|
+
),
|
|
98
|
+
]
|
|
99
|
+
assert mock_elements_worker.classes == {
|
|
100
|
+
"good": "0000",
|
|
101
|
+
"average": "1111",
|
|
102
|
+
"bad": "2222",
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
|
|
20
106
|
def test_get_ml_class_id_load_classes(responses, mock_elements_worker):
|
|
21
107
|
responses.add(
|
|
22
108
|
responses.GET,
|
|
@@ -9,6 +9,37 @@ from tests import CORPUS_ID
|
|
|
9
9
|
from tests.test_elements_worker import BASE_API_CALLS
|
|
10
10
|
|
|
11
11
|
|
|
12
|
+
def test_download_export_not_a_uuid(responses, mock_elements_worker):
|
|
13
|
+
with pytest.raises(ValueError, match="export_id is not a valid uuid."):
|
|
14
|
+
mock_elements_worker.download_export("mon export")
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def test_download_export(responses, mock_elements_worker):
|
|
18
|
+
responses.add(
|
|
19
|
+
responses.GET,
|
|
20
|
+
"http://testserver/api/v1/export/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeffff/",
|
|
21
|
+
status=302,
|
|
22
|
+
body=b"some SQLite export",
|
|
23
|
+
content_type="application/x-sqlite3",
|
|
24
|
+
stream=True,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
export = mock_elements_worker.download_export(
|
|
28
|
+
"aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeffff"
|
|
29
|
+
)
|
|
30
|
+
assert export.name == "/tmp/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeffff"
|
|
31
|
+
|
|
32
|
+
assert len(responses.calls) == len(BASE_API_CALLS) + 1
|
|
33
|
+
assert [
|
|
34
|
+
(call.request.method, call.request.url) for call in responses.calls
|
|
35
|
+
] == BASE_API_CALLS + [
|
|
36
|
+
(
|
|
37
|
+
"GET",
|
|
38
|
+
"http://testserver/api/v1/export/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeffff/",
|
|
39
|
+
),
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
|
|
12
43
|
def mock_list_exports_call(responses, export_id):
|
|
13
44
|
responses.add(
|
|
14
45
|
responses.GET,
|
|
@@ -135,34 +166,3 @@ def test_download_latest_export(responses, mock_elements_worker):
|
|
|
135
166
|
("GET", f"http://testserver/api/v1/corpus/{CORPUS_ID}/export/"),
|
|
136
167
|
("GET", f"http://testserver/api/v1/export/{export_id}/"),
|
|
137
168
|
]
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
def test_download_export_not_a_uuid(responses, mock_elements_worker):
|
|
141
|
-
with pytest.raises(ValueError, match="export_id is not a valid uuid."):
|
|
142
|
-
mock_elements_worker.download_export("mon export")
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
def test_download_export(responses, mock_elements_worker):
|
|
146
|
-
responses.add(
|
|
147
|
-
responses.GET,
|
|
148
|
-
"http://testserver/api/v1/export/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeffff/",
|
|
149
|
-
status=302,
|
|
150
|
-
body=b"some SQLite export",
|
|
151
|
-
content_type="application/x-sqlite3",
|
|
152
|
-
stream=True,
|
|
153
|
-
)
|
|
154
|
-
|
|
155
|
-
export = mock_elements_worker.download_export(
|
|
156
|
-
"aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeffff"
|
|
157
|
-
)
|
|
158
|
-
assert export.name == "/tmp/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeffff"
|
|
159
|
-
|
|
160
|
-
assert len(responses.calls) == len(BASE_API_CALLS) + 1
|
|
161
|
-
assert [
|
|
162
|
-
(call.request.method, call.request.url) for call in responses.calls
|
|
163
|
-
] == BASE_API_CALLS + [
|
|
164
|
-
(
|
|
165
|
-
"GET",
|
|
166
|
-
"http://testserver/api/v1/export/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeffff/",
|
|
167
|
-
),
|
|
168
|
-
]
|