arkindex-base-worker 0.5.0rc1__py3-none-any.whl → 0.5.1__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.0rc1.dist-info → arkindex_base_worker-0.5.1.dist-info}/METADATA +7 -8
- {arkindex_base_worker-0.5.0rc1.dist-info → arkindex_base_worker-0.5.1.dist-info}/RECORD +23 -22
- arkindex_worker/cache.py +6 -1
- arkindex_worker/image.py +5 -1
- arkindex_worker/models.py +5 -0
- arkindex_worker/utils.py +27 -0
- arkindex_worker/worker/__init__.py +62 -6
- arkindex_worker/worker/base.py +53 -1
- arkindex_worker/worker/element.py +20 -0
- arkindex_worker/worker/metadata.py +3 -3
- tests/conftest.py +113 -12
- tests/test_base_worker.py +99 -125
- tests/test_cache.py +1 -1
- tests/test_dataset_worker.py +5 -0
- tests/test_element.py +52 -12
- tests/test_elements_worker/__init__.py +4 -0
- tests/test_elements_worker/test_worker.py +106 -0
- tests/test_image.py +19 -3
- tests/test_modern_config.py +81 -0
- tests/test_utils.py +42 -0
- {arkindex_base_worker-0.5.0rc1.dist-info → arkindex_base_worker-0.5.1.dist-info}/WHEEL +0 -0
- {arkindex_base_worker-0.5.0rc1.dist-info → arkindex_base_worker-0.5.1.dist-info}/licenses/LICENSE +0 -0
- {arkindex_base_worker-0.5.0rc1.dist-info → arkindex_base_worker-0.5.1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
def test_simple_configuration(mock_base_worker_modern_conf, responses):
|
|
2
|
+
# Provide the full configuration directly from the worker run
|
|
3
|
+
responses.add(
|
|
4
|
+
responses.GET,
|
|
5
|
+
"http://testserver/api/v1/workers/runs/56785678-5678-5678-5678-567856785678/configuration/",
|
|
6
|
+
status=200,
|
|
7
|
+
json={"configuration": [{"key": "some_key", "value": "test", "secret": False}]},
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
mock_base_worker_modern_conf.configure()
|
|
11
|
+
|
|
12
|
+
assert mock_base_worker_modern_conf.config == {"some_key": "test"}
|
|
13
|
+
assert (
|
|
14
|
+
mock_base_worker_modern_conf.user_configuration
|
|
15
|
+
== mock_base_worker_modern_conf.config
|
|
16
|
+
)
|
|
17
|
+
assert mock_base_worker_modern_conf.secrets == {}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def test_empty(mock_base_worker_modern_conf, responses):
|
|
21
|
+
# Provide the full configuration directly from the worker run
|
|
22
|
+
responses.add(
|
|
23
|
+
responses.GET,
|
|
24
|
+
"http://testserver/api/v1/workers/runs/56785678-5678-5678-5678-567856785678/configuration/",
|
|
25
|
+
status=200,
|
|
26
|
+
json={"configuration": []},
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
mock_base_worker_modern_conf.configure()
|
|
30
|
+
|
|
31
|
+
assert mock_base_worker_modern_conf.config == {}
|
|
32
|
+
assert (
|
|
33
|
+
mock_base_worker_modern_conf.user_configuration
|
|
34
|
+
== mock_base_worker_modern_conf.config
|
|
35
|
+
)
|
|
36
|
+
assert mock_base_worker_modern_conf.secrets == {}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def test_with_secrets(mock_base_worker_modern_conf, responses):
|
|
40
|
+
# Provide the full configuration directly from the worker run
|
|
41
|
+
responses.add(
|
|
42
|
+
responses.GET,
|
|
43
|
+
"http://testserver/api/v1/workers/runs/56785678-5678-5678-5678-567856785678/configuration/",
|
|
44
|
+
status=200,
|
|
45
|
+
json={
|
|
46
|
+
"configuration": [
|
|
47
|
+
{"key": "some_key", "value": "test", "secret": False},
|
|
48
|
+
{
|
|
49
|
+
"key": "a_secret",
|
|
50
|
+
"value": "471b9e64-29af-48dc-8bda-1a64a2da0c12",
|
|
51
|
+
"secret": True,
|
|
52
|
+
},
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
# Provide a secret value
|
|
58
|
+
responses.add(
|
|
59
|
+
responses.GET,
|
|
60
|
+
"http://testserver/api/v1/secret/471b9e64-29af-48dc-8bda-1a64a2da0c12",
|
|
61
|
+
status=200,
|
|
62
|
+
json={
|
|
63
|
+
"id": "471b9e64-29af-48dc-8bda-1a64a2da0c12",
|
|
64
|
+
"name": "a_secret",
|
|
65
|
+
"content": "My super duper secret value",
|
|
66
|
+
},
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
mock_base_worker_modern_conf.configure()
|
|
70
|
+
|
|
71
|
+
assert mock_base_worker_modern_conf.config == {
|
|
72
|
+
"a_secret": "My super duper secret value",
|
|
73
|
+
"some_key": "test",
|
|
74
|
+
}
|
|
75
|
+
assert (
|
|
76
|
+
mock_base_worker_modern_conf.user_configuration
|
|
77
|
+
== mock_base_worker_modern_conf.config
|
|
78
|
+
)
|
|
79
|
+
assert mock_base_worker_modern_conf.secrets == {
|
|
80
|
+
"a_secret": "My super duper secret value"
|
|
81
|
+
}
|
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.0rc1.dist-info → arkindex_base_worker-0.5.1.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{arkindex_base_worker-0.5.0rc1.dist-info → arkindex_base_worker-0.5.1.dist-info}/top_level.txt
RENAMED
|
File without changes
|