arkindex-base-worker 0.3.5rc6__py3-none-any.whl → 0.3.6rc2__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.
Files changed (43) hide show
  1. arkindex_base_worker-0.3.6rc2.dist-info/METADATA +39 -0
  2. arkindex_base_worker-0.3.6rc2.dist-info/RECORD +40 -0
  3. arkindex_worker/__init__.py +0 -1
  4. arkindex_worker/cache.py +19 -25
  5. arkindex_worker/image.py +16 -17
  6. arkindex_worker/models.py +24 -21
  7. arkindex_worker/utils.py +18 -19
  8. arkindex_worker/worker/__init__.py +17 -27
  9. arkindex_worker/worker/base.py +12 -7
  10. arkindex_worker/worker/classification.py +13 -15
  11. arkindex_worker/worker/dataset.py +3 -4
  12. arkindex_worker/worker/element.py +80 -76
  13. arkindex_worker/worker/entity.py +28 -30
  14. arkindex_worker/worker/metadata.py +21 -27
  15. arkindex_worker/worker/task.py +2 -3
  16. arkindex_worker/worker/training.py +25 -26
  17. arkindex_worker/worker/transcription.py +37 -34
  18. arkindex_worker/worker/version.py +1 -2
  19. tests/conftest.py +56 -76
  20. tests/test_base_worker.py +38 -32
  21. tests/test_cache.py +14 -7
  22. tests/test_dataset_worker.py +25 -22
  23. tests/test_element.py +0 -1
  24. tests/test_elements_worker/__init__.py +0 -1
  25. tests/test_elements_worker/test_classifications.py +0 -1
  26. tests/test_elements_worker/test_cli.py +22 -17
  27. tests/test_elements_worker/test_dataset.py +9 -10
  28. tests/test_elements_worker/test_elements.py +58 -63
  29. tests/test_elements_worker/test_entities.py +10 -20
  30. tests/test_elements_worker/test_metadata.py +72 -96
  31. tests/test_elements_worker/test_task.py +22 -20
  32. tests/test_elements_worker/test_training.py +20 -13
  33. tests/test_elements_worker/test_transcriptions.py +6 -10
  34. tests/test_elements_worker/test_worker.py +16 -14
  35. tests/test_image.py +21 -20
  36. tests/test_merge.py +5 -6
  37. tests/test_utils.py +0 -1
  38. arkindex_base_worker-0.3.5rc6.dist-info/METADATA +0 -27
  39. arkindex_base_worker-0.3.5rc6.dist-info/RECORD +0 -42
  40. arkindex_worker/git.py +0 -392
  41. tests/test_git.py +0 -480
  42. {arkindex_base_worker-0.3.5rc6.dist-info → arkindex_base_worker-0.3.6rc2.dist-info}/WHEEL +0 -0
  43. {arkindex_base_worker-0.3.5rc6.dist-info → arkindex_base_worker-0.3.6rc2.dist-info}/top_level.txt +0 -0
@@ -1,4 +1,3 @@
1
- # . -*- coding: utf-8 -*-
2
1
  import json
3
2
  import sys
4
3
 
@@ -78,7 +77,8 @@ def test_readonly(responses, mock_elements_worker):
78
77
  ] == BASE_API_CALLS
79
78
 
80
79
 
81
- def test_activities_disabled(responses, monkeypatch, mock_worker_run_api):
80
+ @pytest.mark.usefixtures("_mock_worker_run_api")
81
+ def test_activities_disabled(responses, monkeypatch):
82
82
  """Test worker process elements without updating activities when they are disabled for the process"""
83
83
  monkeypatch.setattr(sys, "argv", ["worker"])
84
84
  worker = ElementsWorker()
@@ -105,7 +105,8 @@ def test_activities_dev_mode(mocker):
105
105
  assert worker.store_activity is False
106
106
 
107
107
 
108
- def test_update_call(responses, mock_elements_worker, mock_worker_run_api):
108
+ @pytest.mark.usefixtures("_mock_worker_run_api")
109
+ def test_update_call(responses, mock_elements_worker):
109
110
  """Test an update call with feature enabled triggers an API call"""
110
111
  responses.add(
111
112
  responses.PUT,
@@ -141,8 +142,9 @@ def test_update_call(responses, mock_elements_worker, mock_worker_run_api):
141
142
  }
142
143
 
143
144
 
145
+ @pytest.mark.usefixtures("_mock_activity_calls")
144
146
  @pytest.mark.parametrize(
145
- "process_exception, final_state",
147
+ ("process_exception", "final_state"),
146
148
  [
147
149
  # Successful process_element
148
150
  (None, "processed"),
@@ -161,7 +163,6 @@ def test_run(
161
163
  responses,
162
164
  process_exception,
163
165
  final_state,
164
- mock_activity_calls,
165
166
  ):
166
167
  """Check the normal runtime sends 2 API calls to update activity"""
167
168
  # Disable second configure call from run()
@@ -210,13 +211,8 @@ def test_run(
210
211
  }
211
212
 
212
213
 
213
- def test_run_cache(
214
- monkeypatch,
215
- mocker,
216
- mock_elements_worker_with_cache,
217
- mock_cached_elements,
218
- mock_activity_calls,
219
- ):
214
+ @pytest.mark.usefixtures("_mock_cached_elements", "_mock_activity_calls")
215
+ def test_run_cache(monkeypatch, mocker, mock_elements_worker_with_cache):
220
216
  # Disable second configure call from run()
221
217
  monkeypatch.setattr(mock_elements_worker_with_cache, "configure", lambda: None)
222
218
 
@@ -310,8 +306,14 @@ def test_start_activity_error(
310
306
 
311
307
 
312
308
  @pytest.mark.parametrize(
313
- "wk_version_config,wk_version_user_config,frontend_user_config,model_config,expected_config",
314
309
  (
310
+ "wk_version_config",
311
+ "wk_version_user_config",
312
+ "frontend_user_config",
313
+ "model_config",
314
+ "expected_config",
315
+ ),
316
+ [
315
317
  ({}, {}, {}, {}, {}),
316
318
  # Keep parameters from worker version configuration
317
319
  ({"parameter": 0}, {}, {}, {}, {"parameter": 0}),
@@ -411,7 +413,7 @@ def test_start_activity_error(
411
413
  {"parameter": 2},
412
414
  {"parameter": 3},
413
415
  ),
414
- ),
416
+ ],
415
417
  )
416
418
  def test_worker_config_multiple_source(
417
419
  monkeypatch,
tests/test_image.py CHANGED
@@ -1,4 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
1
  import math
3
2
  import unittest
4
3
  import uuid
@@ -124,13 +123,13 @@ def test_download_tiles_small(responses):
124
123
 
125
124
 
126
125
  @pytest.mark.parametrize(
127
- "path, is_local",
128
- (
126
+ ("path", "is_local"),
127
+ [
129
128
  ("http://somewhere/test.jpg", False),
130
129
  ("https://somewhere/test.jpg", False),
131
130
  ("path/to/something", True),
132
131
  ("/absolute/path/to/something", True),
133
- ),
132
+ ],
134
133
  )
135
134
  def test_open_image(path, is_local, monkeypatch):
136
135
  """Check if the path triggers a local load or a remote one"""
@@ -149,13 +148,13 @@ def test_open_image(path, is_local, monkeypatch):
149
148
 
150
149
 
151
150
  @pytest.mark.parametrize(
152
- "rotation_angle,mirrored,expected_path",
153
- (
151
+ ("rotation_angle", "mirrored", "expected_path"),
152
+ [
154
153
  (0, False, TILE),
155
154
  (45, False, ROTATED_IMAGE),
156
155
  (0, True, MIRRORED_IMAGE),
157
156
  (45, True, ROTATED_MIRRORED_IMAGE),
158
- ),
157
+ ],
159
158
  )
160
159
  def test_open_image_rotate_mirror(rotation_angle, mirrored, expected_path):
161
160
  expected = Image.open(expected_path).convert("RGB")
@@ -245,8 +244,9 @@ class TestTrimPolygon(unittest.TestCase):
245
244
  [99, 208],
246
245
  ]
247
246
  }
248
- with self.assertRaises(
249
- AssertionError, msg="Input polygon must be a valid list or tuple of points."
247
+ with pytest.raises(
248
+ AssertionError,
249
+ match="Input polygon must be a valid list or tuple of points.",
250
250
  ):
251
251
  trim_polygon(bad_polygon, TEST_IMAGE["width"], TEST_IMAGE["height"])
252
252
 
@@ -305,8 +305,8 @@ class TestTrimPolygon(unittest.TestCase):
305
305
  [997, 206],
306
306
  [999, 200],
307
307
  ]
308
- with self.assertRaises(
309
- AssertionError, msg="This polygon is entirely outside the image's bounds."
308
+ with pytest.raises(
309
+ AssertionError, match="This polygon is entirely outside the image's bounds."
310
310
  ):
311
311
  trim_polygon(bad_polygon, TEST_IMAGE["width"], TEST_IMAGE["height"])
312
312
 
@@ -328,8 +328,8 @@ class TestTrimPolygon(unittest.TestCase):
328
328
  [197, 206],
329
329
  [99, 20.8],
330
330
  ]
331
- with self.assertRaises(
332
- AssertionError, msg="Polygon point coordinates must be integers."
331
+ with pytest.raises(
332
+ AssertionError, match="Polygon point coordinates must be integers."
333
333
  ):
334
334
  trim_polygon(bad_polygon, TEST_IMAGE["width"], TEST_IMAGE["height"])
335
335
 
@@ -347,8 +347,8 @@ class TestTrimPolygon(unittest.TestCase):
347
347
  [72, 57],
348
348
  [12, 56],
349
349
  ]
350
- with self.assertRaises(
351
- AssertionError, msg="Polygon points must be tuples or lists."
350
+ with pytest.raises(
351
+ AssertionError, match="Polygon points must be tuples or lists."
352
352
  ):
353
353
  trim_polygon(bad_polygon, TEST_IMAGE["width"], TEST_IMAGE["height"])
354
354
 
@@ -366,15 +366,16 @@ class TestTrimPolygon(unittest.TestCase):
366
366
  [72, 57],
367
367
  [12, 56],
368
368
  ]
369
- with self.assertRaises(
370
- AssertionError, msg="Polygon points must be tuples or lists of 2 elements."
369
+ with pytest.raises(
370
+ AssertionError,
371
+ match="Polygon points must be tuples or lists of 2 elements.",
371
372
  ):
372
373
  trim_polygon(bad_polygon, TEST_IMAGE["width"], TEST_IMAGE["height"])
373
374
 
374
375
 
375
376
  @pytest.mark.parametrize(
376
- "angle, mirrored, updated_bounds, reverse",
377
- (
377
+ ("angle", "mirrored", "updated_bounds", "reverse"),
378
+ [
378
379
  (
379
380
  0,
380
381
  False,
@@ -471,7 +472,7 @@ class TestTrimPolygon(unittest.TestCase):
471
472
  {"x": 11, "y": 295, "width": 47, "height": 111}, # upper right
472
473
  False,
473
474
  ),
474
- ),
475
+ ],
475
476
  )
476
477
  def test_revert_orientation(angle, mirrored, updated_bounds, reverse, tmp_path):
477
478
  """Test cases, for both Elements and CachedElements:
tests/test_merge.py CHANGED
@@ -1,4 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
1
  from uuid import UUID
3
2
 
4
3
  import pytest
@@ -18,8 +17,8 @@ from arkindex_worker.cache import (
18
17
 
19
18
 
20
19
  @pytest.mark.parametrize(
21
- "parents, expected_elements, expected_transcriptions",
22
- (
20
+ ("parents", "expected_elements", "expected_transcriptions"),
21
+ [
23
22
  # Nothing happen when no parents are available
24
23
  ([], [], []),
25
24
  # Nothing happen when the parent file does not exist
@@ -73,7 +72,7 @@ from arkindex_worker.cache import (
73
72
  UUID("22222222-2222-2222-2222-222222222222"),
74
73
  ],
75
74
  ),
76
- ),
75
+ ],
77
76
  )
78
77
  def test_merge_databases(
79
78
  mock_databases, tmp_path, parents, expected_elements, expected_transcriptions
@@ -114,7 +113,7 @@ def test_merge_databases(
114
113
  ] == expected_transcriptions
115
114
 
116
115
 
117
- def test_merge_chunk(mock_databases, tmp_path, monkeypatch):
116
+ def test_merge_chunk(mock_databases, tmp_path):
118
117
  """
119
118
  Check the db merge algorithm support two parents
120
119
  and one of them has a chunk
@@ -155,7 +154,7 @@ def test_merge_chunk(mock_databases, tmp_path, monkeypatch):
155
154
 
156
155
 
157
156
  def test_merge_from_worker(
158
- responses, mock_base_worker_with_cache, mock_databases, tmp_path, monkeypatch
157
+ responses, mock_base_worker_with_cache, mock_databases, tmp_path
159
158
  ):
160
159
  """
161
160
  High level merge from the base worker
tests/test_utils.py CHANGED
@@ -1,4 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
1
  from pathlib import Path
3
2
 
4
3
  from arkindex_worker.utils import close_delete_file, extract_tar_zst_archive
@@ -1,27 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: arkindex-base-worker
3
- Version: 0.3.5rc6
4
- Summary: Base Worker to easily build Arkindex ML workflows
5
- Home-page: https://teklia.com
6
- Author: Teklia
7
- Author-email: contact@teklia.com
8
- Requires-Python: >=3.7
9
- Requires-Dist: arkindex-client ==1.0.14
10
- Requires-Dist: peewee ==3.17.0
11
- Requires-Dist: Pillow ==10.1.0
12
- Requires-Dist: pymdown-extensions ==10.3.1
13
- Requires-Dist: python-gitlab ==4.1.1
14
- Requires-Dist: python-gnupg ==0.5.1
15
- Requires-Dist: sh ==2.0.6
16
- Requires-Dist: shapely ==2.0.2
17
- Requires-Dist: tenacity ==8.2.3
18
- Requires-Dist: zstandard ==0.22.0
19
- Provides-Extra: docs
20
- Requires-Dist: black ==23.10.1 ; extra == 'docs'
21
- Requires-Dist: doc8 ==1.1.1 ; extra == 'docs'
22
- Requires-Dist: mkdocs ==1.5.3 ; extra == 'docs'
23
- Requires-Dist: mkdocs-material ==9.4.8 ; extra == 'docs'
24
- Requires-Dist: mkdocstrings ==0.23.0 ; extra == 'docs'
25
- Requires-Dist: mkdocstrings-python ==1.7.3 ; extra == 'docs'
26
- Requires-Dist: recommonmark ==0.7.1 ; extra == 'docs'
27
-
@@ -1,42 +0,0 @@
1
- arkindex_worker/__init__.py,sha256=_CYBbq_4ZP9DodY4ZSMNzdj-cT3eAwpQHU86nGzVFUw,186
2
- arkindex_worker/cache.py,sha256=JWYgF8UtFT5tm_V_NPbApnWUqNaRaxMZdDyzMi5i65A,11054
3
- arkindex_worker/git.py,sha256=lUr4in7ddOehPx1_oD5xyZ-h8LF-6DuscSPzgZr4EJ4,15338
4
- arkindex_worker/image.py,sha256=SZphvx7Cdc8vzLhBYeaJLKqlphH_jKqzLsX9ss0474U,14183
5
- arkindex_worker/models.py,sha256=eiW5fDGz0TW8ku7WnyWQr9CQFCxsbYDmiYPaBavw4YU,9471
6
- arkindex_worker/utils.py,sha256=289ykfOH_1zdgFaCvL2hZ8ZZNYMKYzmNOC6lJQi_SQk,6926
7
- arkindex_worker/worker/__init__.py,sha256=nsujyXaj3pj9T4KT3tFm1p2lMJFeToKRggDves6p8u4,19313
8
- arkindex_worker/worker/base.py,sha256=0DvOTcCatELwkhZS4C9jOLPkg8dLUlXuPWeifO7LR5E,19188
9
- arkindex_worker/worker/classification.py,sha256=rnodg2Twxfly9P9qeWRwqqdWERVY4MSPKvHLsvATyRg,10792
10
- arkindex_worker/worker/dataset.py,sha256=m_opGiSVDCbhCrK3vrs9TaZnssHgl_2x56G5h_BHVD8,2784
11
- arkindex_worker/worker/element.py,sha256=ZThSCT36QXXShQavfH4D9EZFk_v-gjqifZHFwu4zDR8,30875
12
- arkindex_worker/worker/entity.py,sha256=WCY9bPzxfKSLsE1WOyCF9UPtxpdFs_cCsG4EPf-1je4,13507
13
- arkindex_worker/worker/metadata.py,sha256=IVBHTde82tbPUhgRmZJWYeICWuUSHfaM0uSvp3Gs1y8,6449
14
- arkindex_worker/worker/task.py,sha256=FsLWh3unW5IZPn5Ze_3R6FuK5UYM6RG-xJAjITXM0Rc,1498
15
- arkindex_worker/worker/training.py,sha256=ss0JCjPd5qIa7evSZtOUA2iy8VdYChQim9mPy7dCT54,10211
16
- arkindex_worker/worker/transcription.py,sha256=KPqT_egO3zA4G8ua1oKlsKJPN_lTbF20okgyecDwEXc,18808
17
- arkindex_worker/worker/version.py,sha256=WypMzANWjIqj2_yPuwxGXH-nAfP2yE1gqATqtybr-RA,1460
18
- tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
- tests/conftest.py,sha256=rynMppqeQzPOLb35hIzAXOAI4X-UUAVTipWfCI3fusU,22345
20
- tests/test_base_worker.py,sha256=JydmbGZ-7_L8G7GJz2l1NjOf2BI1o07IJoLU94BuCoI,24780
21
- tests/test_cache.py,sha256=QYtMaMqKppWndrbkxNwJYpVemEYOH7X4e9mB6POVIXw,10437
22
- tests/test_dataset_worker.py,sha256=LFPdI-cHYnj9YVCSXxpmr655PfgfGVCYEs9Yeek5H2Q,27613
23
- tests/test_element.py,sha256=_Ve7U33b2JHDF0wYJUwdJzV_wW8q-Y-4eMaKDaRQ0W8,13205
24
- tests/test_git.py,sha256=2rX81uka7a1T0qzlqN70epvVuJh9Ia41L6iNRZfxNnY,14944
25
- tests/test_image.py,sha256=5_3EjP-Oe4NH1FFQXLDd7kyxQlRDXaVzpH8OQSPFBbM,15220
26
- tests/test_merge.py,sha256=n7wwlrOs5x_1cHlcDKBMr6KPTtya91HzI9pZrvvHbw8,8375
27
- tests/test_utils.py,sha256=4e8DsljBXq568YDA6ZQZvFmh3uudRTD4ira6o9Sy3WI,1260
28
- tests/test_elements_worker/__init__.py,sha256=dxec3bdwmoXRIK2jw4d1zYrzfvuG_82tE3IyK46ZsYc,203
29
- tests/test_elements_worker/test_classifications.py,sha256=hvRhf2nEr34SZSRpIxNy2EiufnMHcLIdIkWKfckN4YU,32051
30
- tests/test_elements_worker/test_cli.py,sha256=m0595219Y4SCL7UjuoVL0wxeUUjl_B0mq3OU_O_ybZk,2751
31
- tests/test_elements_worker/test_dataset.py,sha256=KaI08MjApZMoaUm0tF321KR6eHCDg0o0arPT_yyyi0Y,12075
32
- tests/test_elements_worker/test_elements.py,sha256=MtiVAVnBFgQ3_6Ia82OhaLngwaxP3cl7jKuJ7MN8r_k,75656
33
- tests/test_elements_worker/test_entities.py,sha256=sdsWPndrioqDlkpnsHZ8YwHZUyGEskvgfcFwOPjb0fI,33866
34
- tests/test_elements_worker/test_metadata.py,sha256=cI-jjB6WOkQGr52bgffwSyPo7Rg4m-HOMTfOOTqMHRQ,17813
35
- tests/test_elements_worker/test_task.py,sha256=5lagIl6w0xy_iMHGEBghRBMaBaH6n9swfdjZdDGDTJw,6270
36
- tests/test_elements_worker/test_training.py,sha256=D96h8rCvjyo_KJ7xScT5mdF1i97qaL1Fq6aiXRMeIdg,8292
37
- tests/test_elements_worker/test_transcriptions.py,sha256=DntYx0rCV2Og3gYxOuBu9-skHYruOBYvGUvOVz4FFiU,68746
38
- tests/test_elements_worker/test_worker.py,sha256=IRyB7mcsTyV7UsHVuP-P4ViFYaXFA3QgCh5hh7iuNdk,16364
39
- arkindex_base_worker-0.3.5rc6.dist-info/METADATA,sha256=-IK-w9fCdBt4pLGsJ2TNIP2Cv9dve8zUFMszGpH0PSs,960
40
- arkindex_base_worker-0.3.5rc6.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
41
- arkindex_base_worker-0.3.5rc6.dist-info/top_level.txt,sha256=TtagLI8LSv7GE7nG8MQqDFAJ5bNDPJn7Z5vizOgrWkA,22
42
- arkindex_base_worker-0.3.5rc6.dist-info/RECORD,,