arkindex-base-worker 0.5.1b4__py3-none-any.whl → 0.5.1b5__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: arkindex-base-worker
3
- Version: 0.5.1b4
3
+ Version: 0.5.1b5
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,11 +1,11 @@
1
- arkindex_base_worker-0.5.1b4.dist-info/licenses/LICENSE,sha256=NVshRi1efwVezMfW7xXYLrdDr2Li1AfwfGOd5WuH1kQ,1063
1
+ arkindex_base_worker-0.5.1b5.dist-info/licenses/LICENSE,sha256=NVshRi1efwVezMfW7xXYLrdDr2Li1AfwfGOd5WuH1kQ,1063
2
2
  arkindex_worker/__init__.py,sha256=Sdt5KXn8EgURb2MurYVrUWaHbH3iFA1XLRo0Lc5AJ44,250
3
3
  arkindex_worker/cache.py,sha256=x1d1oVF297ItLoZnPkZQoEefa39ZigrwRoHC_6az94k,10731
4
4
  arkindex_worker/image.py,sha256=GvIpW7LNSalVw3Obt9nySDWnW7-NbC0__SWREEQqVCk,20696
5
5
  arkindex_worker/models.py,sha256=bPQzGZNs5a6z6DEcygsa8T33VOqPlMUbwKzHqlKzwbw,9923
6
6
  arkindex_worker/utils.py,sha256=MbbJT8oh8DMHHR-vidFeXdUH0TSXGWm7ZDGWzrRXoEY,9933
7
7
  arkindex_worker/worker/__init__.py,sha256=SzD0s1_m6gMV02EUF-NeciqZdVPA4dpXI84tSj-g494,17869
8
- arkindex_worker/worker/base.py,sha256=fbRJ5vDON3DfSQfwxFqto85HY8Dw2_YgOmnm5cxbQ2g,21725
8
+ arkindex_worker/worker/base.py,sha256=-ASOgLzemHOAz7EnPZ9hT6wON_9GJ7uadxx7oZLgUD4,22149
9
9
  arkindex_worker/worker/classification.py,sha256=qvykymkgd4nGywHCxL8obo4egstoGsmWNS4Ztc1qNWQ,11024
10
10
  arkindex_worker/worker/corpus.py,sha256=MeIMod7jkWyX0frtD0a37rhumnMV3p9ZOC1xwAoXrAA,2291
11
11
  arkindex_worker/worker/dataset.py,sha256=tVaPx43vaH-KTtx4w5V06e26ha8XPfiJTRzBXlu928Y,5273
@@ -21,8 +21,8 @@ examples/standalone/python/worker.py,sha256=Zr4s4pHvgexEjlkixLFYZp1UuwMLeoTxjyNG
21
21
  examples/tooled/python/worker.py,sha256=kIYlHLsO5UpwX4XtERRq4tf2qTsvqKK30C-w8t0yyhA,1821
22
22
  hooks/pre_gen_project.py,sha256=xQJERv3vv9VzIqcBHI281eeWLWREXUF4mMw7PvJHHXM,269
23
23
  tests/__init__.py,sha256=DG--S6IpGl399rzSAjDdHL76CkOIeZIjajCcyUSDhOQ,241
24
- tests/conftest.py,sha256=OaajGB0FS0Jh3rFhL8a3HdaN84XzIxNbRORvzI5W2ns,24928
25
- tests/test_base_worker.py,sha256=3YjhjxSWVjEWFYS8m8pYYoaVAhHFkJLNTs0QPQIkBDM,32651
24
+ tests/conftest.py,sha256=Tp7YFK17NATwF2yAcBwi0QFNyKSXtLS0VhZ-zZngsQI,24343
25
+ tests/test_base_worker.py,sha256=lwS4X3atS2ktEKd1XdogmN3mbzq-tO206-k_0EDITlw,29302
26
26
  tests/test_cache.py,sha256=nnEFfAAqtYHk2ymOwN0spXJd8nrRiwp3voj0tOmIbQ8,10407
27
27
  tests/test_dataset_worker.py,sha256=iDJM2C4PfQNH0r4_QqSWoPt8BcM0geUUdODtWY0Z9PA,22412
28
28
  tests/test_element.py,sha256=2G9M15TLxQRmvrWM9Kw2ucnElh4kSv_oF_5FYwwAxTY,13181
@@ -55,7 +55,7 @@ worker-demo/tests/conftest.py,sha256=XzNMNeg6pmABUAH8jN6eZTlZSFGLYjS3-DTXjiRN6Yc
55
55
  worker-demo/tests/test_worker.py,sha256=3DLd4NRK4bfyatG5P_PK4k9P9tJHx9XQq5_ryFEEFVg,304
56
56
  worker-demo/worker_demo/__init__.py,sha256=2BPomV8ZMNf3YXJgloatKeHQCE6QOkwmsHGkO6MkQuM,125
57
57
  worker-demo/worker_demo/worker.py,sha256=Rt-DjWa5iBP08k58NDZMfeyPuFbtNcbX6nc5jFX7GNo,440
58
- arkindex_base_worker-0.5.1b4.dist-info/METADATA,sha256=hLR30IODhVUqKVq_4qXv_AcNswb0afCA-2Nce13UPno,3137
59
- arkindex_base_worker-0.5.1b4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
60
- arkindex_base_worker-0.5.1b4.dist-info/top_level.txt,sha256=-vNjP2VfROx0j83mdi9aIqRZ88eoJjxeWz-R_gPgyXU,49
61
- arkindex_base_worker-0.5.1b4.dist-info/RECORD,,
58
+ arkindex_base_worker-0.5.1b5.dist-info/METADATA,sha256=pVX35tc38qCuTCXwhXS2veoEJpTMJ3KWh3a1CUZQ3yg,3137
59
+ arkindex_base_worker-0.5.1b5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
60
+ arkindex_base_worker-0.5.1b5.dist-info/top_level.txt,sha256=-vNjP2VfROx0j83mdi9aIqRZ88eoJjxeWz-R_gPgyXU,49
61
+ arkindex_base_worker-0.5.1b5.dist-info/RECORD,,
@@ -265,6 +265,11 @@ class BaseWorker:
265
265
  if not item["secret"]:
266
266
  return (item["key"], item["value"])
267
267
 
268
+ # The secret may not be picked by the user
269
+ if item["value"] is None:
270
+ logger.info(f"Skipping optional secret {item['key']}")
271
+ return (item["key"], None)
272
+
268
273
  # Load secret, only available in Arkindex EE
269
274
  try:
270
275
  secret = self.load_secret(Path(item["value"]))
@@ -276,6 +281,19 @@ class BaseWorker:
276
281
 
277
282
  return (item["key"], secret)
278
283
 
284
+ # Load model version configuration when available
285
+ # Workers will use model version ID and details to download the model
286
+ model_version = worker_run.get("model_version")
287
+ if model_version:
288
+ logger.info("Loaded model version configuration from WorkerRun")
289
+ self.model_configuration.update(model_version["configuration"])
290
+
291
+ # Set model_version ID as worker attribute
292
+ self.model_version_id = model_version["id"]
293
+
294
+ # Set model details as worker attribute
295
+ self.model_details = model_version["model"]
296
+
279
297
  # Load worker run information
280
298
  try:
281
299
  config = self.api_client.request(
@@ -295,6 +313,9 @@ class BaseWorker:
295
313
  }
296
314
  logger.info("Using modern configuration")
297
315
 
316
+ # Reset the model configuration to make sure workers rely on the single new source
317
+ self.model_configuration = {}
318
+
298
319
  return # Stop here once we have modern configuration
299
320
 
300
321
  except ErrorResponse as e:
@@ -303,18 +324,6 @@ class BaseWorker:
303
324
  logger.info("Modern configuration is not available")
304
325
 
305
326
  # Use old-style configuration with local merge
306
- # Load model version configuration when available
307
- model_version = worker_run.get("model_version")
308
- if model_version:
309
- logger.info("Loaded model version configuration from WorkerRun")
310
- self.model_configuration.update(model_version["configuration"])
311
-
312
- # Set model_version ID as worker attribute
313
- self.model_version_id = model_version["id"]
314
-
315
- # Set model details as worker attribute
316
- self.model_details = model_version["model"]
317
-
318
327
  # Retrieve initial configuration from API
319
328
  self.config = worker_version["configuration"].get("configuration", {})
320
329
  if "user_configuration" in worker_version["configuration"]:
tests/conftest.py CHANGED
@@ -103,12 +103,6 @@ def _mock_worker_run_api(responses):
103
103
  payload = {
104
104
  "id": "56785678-5678-5678-5678-567856785678",
105
105
  "parents": [],
106
- "worker": {
107
- "id": "deadbeef-1234-5678-1234-worker",
108
- "name": "Fake worker",
109
- "slug": "fake_worker",
110
- "type": "classifier",
111
- },
112
106
  "worker_version": {
113
107
  "id": "12341234-1234-1234-1234-123412341234",
114
108
  "configuration": {
@@ -180,12 +174,6 @@ def _mock_worker_run_no_revision_api(responses):
180
174
  payload = {
181
175
  "id": "56785678-5678-5678-5678-567856785678",
182
176
  "parents": [],
183
- "worker": {
184
- "id": "deadbeef-1234-5678-1234-worker",
185
- "name": "Fake worker",
186
- "slug": "fake_worker",
187
- "type": "classifier",
188
- },
189
177
  "worker_version": {
190
178
  "id": "12341234-1234-1234-1234-123412341234",
191
179
  "configuration": {
@@ -355,12 +343,6 @@ def mock_elements_worker_consume_wa(monkeypatch, responses, mock_elements_worker
355
343
  json={
356
344
  "id": "56785678-5678-5678-5678-567856785678",
357
345
  "parents": [],
358
- "worker": {
359
- "id": "deadbeef-1234-5678-1234-worker",
360
- "name": "Fake worker",
361
- "slug": "fake_worker",
362
- "type": "classifier",
363
- },
364
346
  "worker_version": {
365
347
  "id": "12341234-1234-1234-1234-123412341234",
366
348
  "configuration": {
tests/test_base_worker.py CHANGED
@@ -13,6 +13,29 @@ from arkindex_worker.worker import BaseWorker, ElementsWorker
13
13
  from arkindex_worker.worker.base import ExtrasDirNotFoundError
14
14
  from tests import CORPUS_ID, FIXTURES_DIR
15
15
 
16
+ SIMPLE_PAYLOAD = {
17
+ "id": "56785678-5678-5678-5678-567856785678",
18
+ "parents": [],
19
+ "worker_version": {
20
+ "id": "12341234-1234-1234-1234-123412341234",
21
+ "worker": {
22
+ "id": "deadbeef-1234-5678-1234-worker",
23
+ "name": "Fake worker",
24
+ "slug": "fake_worker",
25
+ "type": "classifier",
26
+ },
27
+ "revision": {"hash": "deadbeef1234"},
28
+ "configuration": {"configuration": {}},
29
+ },
30
+ "configuration": None,
31
+ "model_version": None,
32
+ "process": {
33
+ "id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeffff",
34
+ "corpus": CORPUS_ID,
35
+ },
36
+ "summary": "Worker Fake worker @ 123412",
37
+ }
38
+
16
39
 
17
40
  def test_init_default_local_share():
18
41
  worker = BaseWorker()
@@ -149,38 +172,13 @@ def test_configure_worker_run(mocker, responses, caplog):
149
172
 
150
173
  worker = BaseWorker()
151
174
  mocker.patch.object(sys, "argv", ["worker"])
152
- user_configuration = {
153
- "id": "bbbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb",
154
- "name": "BBB",
155
- "configuration": {"a": "b"},
156
- }
157
175
  payload = {
158
- "id": "56785678-5678-5678-5678-567856785678",
159
- "parents": [],
160
- "worker": {
161
- "id": "deadbeef-1234-5678-1234-worker",
162
- "name": "Fake worker",
163
- "slug": "fake_worker",
164
- "type": "classifier",
165
- },
166
- "worker_version": {
167
- "id": "12341234-1234-1234-1234-123412341234",
168
- "worker": {
169
- "id": "deadbeef-1234-5678-1234-worker",
170
- "name": "Fake worker",
171
- "slug": "fake_worker",
172
- "type": "classifier",
173
- },
174
- "revision": {"hash": "deadbeef1234"},
175
- "configuration": {"configuration": {}},
176
- },
177
- "configuration": user_configuration,
178
- "model_version": None,
179
- "process": {
180
- "id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeffff",
181
- "corpus": CORPUS_ID,
176
+ **SIMPLE_PAYLOAD,
177
+ "configuration": {
178
+ "id": "bbbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb",
179
+ "name": "BBB",
180
+ "configuration": {"a": "b"},
182
181
  },
183
- "summary": "Worker Fake worker @ 123412",
184
182
  }
185
183
 
186
184
  responses.add(
@@ -262,8 +260,7 @@ def test_configure_user_configuration_defaults(mocker, responses):
262
260
  worker.args = worker.parser.parse_args()
263
261
 
264
262
  payload = {
265
- "id": "56785678-5678-5678-5678-567856785678",
266
- "parents": [],
263
+ **SIMPLE_PAYLOAD,
267
264
  "worker_version": {
268
265
  "id": "12341234-1234-1234-1234-123412341234",
269
266
  "worker": {
@@ -293,12 +290,6 @@ def test_configure_user_configuration_defaults(mocker, responses):
293
290
  "param_5": True,
294
291
  },
295
292
  },
296
- "model_version": None,
297
- "process": {
298
- "id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeffff",
299
- "corpus": CORPUS_ID,
300
- },
301
- "summary": "Worker Fake worker @ 123412",
302
293
  }
303
294
  responses.add(
304
295
  responses.GET,
@@ -340,30 +331,12 @@ def test_configure_user_config_debug(mocker, responses, debug):
340
331
  mocker.patch.object(sys, "argv", ["worker"])
341
332
  assert logger.level == logging.NOTSET
342
333
  payload = {
343
- "id": "56785678-5678-5678-5678-567856785678",
344
- "parents": [],
345
- "worker_version": {
346
- "id": "12341234-1234-1234-1234-123412341234",
347
- "worker": {
348
- "id": "deadbeef-1234-5678-1234-worker",
349
- "name": "Fake worker",
350
- "slug": "fake_worker",
351
- "type": "classifier",
352
- },
353
- "revision": {"hash": "deadbeef1234"},
354
- "configuration": {"configuration": {}},
355
- },
356
- "model_version": None,
334
+ **SIMPLE_PAYLOAD,
357
335
  "configuration": {
358
336
  "id": "af0daaf4-983e-4703-a7ed-a10f146d6684",
359
337
  "name": "BBB",
360
338
  "configuration": {"debug": debug},
361
339
  },
362
- "process": {
363
- "id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeffff",
364
- "corpus": CORPUS_ID,
365
- },
366
- "summary": "Worker Fake worker @ 123412",
367
340
  }
368
341
  responses.add(
369
342
  responses.GET,
@@ -393,32 +366,8 @@ def test_configure_worker_run_missing_conf(mocker, responses):
393
366
  mocker.patch.object(sys, "argv", ["worker"])
394
367
 
395
368
  payload = {
396
- "id": "56785678-5678-5678-5678-567856785678",
397
- "parents": [],
398
- "worker": {
399
- "id": "deadbeef-1234-5678-1234-worker",
400
- "name": "Fake worker",
401
- "slug": "fake_worker",
402
- "type": "classifier",
403
- },
404
- "worker_version": {
405
- "id": "12341234-1234-1234-1234-123412341234",
406
- "worker": {
407
- "id": "deadbeef-1234-5678-1234-worker",
408
- "name": "Fake worker",
409
- "slug": "fake_worker",
410
- "type": "classifier",
411
- },
412
- "revision": {"hash": "deadbeef1234"},
413
- "configuration": {"configuration": {}},
414
- },
415
- "model_version": None,
369
+ **SIMPLE_PAYLOAD,
416
370
  "configuration": {"id": "bbbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb", "name": "BBB"},
417
- "process": {
418
- "id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeffff",
419
- "corpus": CORPUS_ID,
420
- },
421
- "summary": "Worker Fake worker @ 123412",
422
371
  }
423
372
  responses.add(
424
373
  responses.GET,
@@ -446,28 +395,7 @@ def test_configure_worker_run_no_worker_run_conf(mocker, responses):
446
395
  worker = BaseWorker()
447
396
  mocker.patch.object(sys, "argv", ["worker"])
448
397
 
449
- payload = {
450
- "id": "56785678-5678-5678-5678-567856785678",
451
- "parents": [],
452
- "worker_version": {
453
- "id": "12341234-1234-1234-1234-123412341234",
454
- "worker": {
455
- "id": "deadbeef-1234-5678-1234-worker",
456
- "name": "Fake worker",
457
- "slug": "fake_worker",
458
- "type": "classifier",
459
- },
460
- "revision": {"hash": "deadbeef1234"},
461
- "configuration": {},
462
- },
463
- "model_version": None,
464
- "configuration": None,
465
- "process": {
466
- "id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeffff",
467
- "corpus": CORPUS_ID,
468
- },
469
- "summary": "Worker Fake worker @ 123412",
470
- }
398
+ payload = SIMPLE_PAYLOAD
471
399
  responses.add(
472
400
  responses.GET,
473
401
  "http://testserver/api/v1/process/workers/56785678-5678-5678-5678-567856785678/",
@@ -491,20 +419,7 @@ def test_configure_load_model_configuration(mocker, responses):
491
419
  worker = BaseWorker()
492
420
  mocker.patch.object(sys, "argv", ["worker"])
493
421
  payload = {
494
- "id": "56785678-5678-5678-5678-567856785678",
495
- "parents": [],
496
- "worker_version": {
497
- "id": "12341234-1234-1234-1234-123412341234",
498
- "worker": {
499
- "id": "deadbeef-1234-5678-1234-worker",
500
- "name": "Fake worker",
501
- "slug": "fake_worker",
502
- "type": "classifier",
503
- },
504
- "revision": {"hash": "deadbeef1234"},
505
- "configuration": {"configuration": {}},
506
- },
507
- "configuration": None,
422
+ **SIMPLE_PAYLOAD,
508
423
  "model_version": {
509
424
  "id": "12341234-1234-1234-1234-123412341234",
510
425
  "model": {
@@ -517,11 +432,6 @@ def test_configure_load_model_configuration(mocker, responses):
517
432
  "param3": None,
518
433
  },
519
434
  },
520
- "process": {
521
- "id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeffff",
522
- "corpus": CORPUS_ID,
523
- },
524
- "summary": "Worker Fake worker @ 123412",
525
435
  }
526
436
 
527
437
  responses.add(