arkindex-base-worker 0.3.6rc4__py3-none-any.whl → 0.3.7__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 (41) hide show
  1. arkindex_base_worker-0.3.7.dist-info/LICENSE +21 -0
  2. arkindex_base_worker-0.3.7.dist-info/METADATA +77 -0
  3. arkindex_base_worker-0.3.7.dist-info/RECORD +47 -0
  4. {arkindex_base_worker-0.3.6rc4.dist-info → arkindex_base_worker-0.3.7.dist-info}/WHEEL +1 -1
  5. {arkindex_base_worker-0.3.6rc4.dist-info → arkindex_base_worker-0.3.7.dist-info}/top_level.txt +2 -0
  6. arkindex_worker/cache.py +14 -0
  7. arkindex_worker/image.py +29 -19
  8. arkindex_worker/models.py +14 -2
  9. arkindex_worker/utils.py +17 -3
  10. arkindex_worker/worker/__init__.py +122 -125
  11. arkindex_worker/worker/base.py +24 -24
  12. arkindex_worker/worker/classification.py +18 -25
  13. arkindex_worker/worker/dataset.py +24 -18
  14. arkindex_worker/worker/element.py +100 -19
  15. arkindex_worker/worker/entity.py +35 -4
  16. arkindex_worker/worker/metadata.py +21 -11
  17. arkindex_worker/worker/training.py +13 -0
  18. arkindex_worker/worker/transcription.py +45 -5
  19. arkindex_worker/worker/version.py +22 -0
  20. hooks/pre_gen_project.py +3 -0
  21. tests/conftest.py +16 -8
  22. tests/test_base_worker.py +0 -6
  23. tests/test_dataset_worker.py +291 -409
  24. tests/test_elements_worker/test_classifications.py +365 -539
  25. tests/test_elements_worker/test_cli.py +1 -1
  26. tests/test_elements_worker/test_dataset.py +97 -116
  27. tests/test_elements_worker/test_elements.py +354 -76
  28. tests/test_elements_worker/test_entities.py +22 -2
  29. tests/test_elements_worker/test_metadata.py +53 -27
  30. tests/test_elements_worker/test_training.py +35 -0
  31. tests/test_elements_worker/test_transcriptions.py +149 -16
  32. tests/test_elements_worker/test_worker.py +19 -6
  33. tests/test_image.py +37 -0
  34. tests/test_utils.py +23 -1
  35. worker-demo/tests/__init__.py +0 -0
  36. worker-demo/tests/conftest.py +32 -0
  37. worker-demo/tests/test_worker.py +12 -0
  38. worker-demo/worker_demo/__init__.py +6 -0
  39. worker-demo/worker_demo/worker.py +19 -0
  40. arkindex_base_worker-0.3.6rc4.dist-info/METADATA +0 -47
  41. arkindex_base_worker-0.3.6rc4.dist-info/RECORD +0 -40
@@ -0,0 +1,32 @@
1
+ import os
2
+
3
+ import pytest
4
+
5
+ from arkindex.mock import MockApiClient
6
+ from arkindex_worker.worker.base import BaseWorker
7
+
8
+
9
+ @pytest.fixture(autouse=True)
10
+ def _setup_environment(responses, monkeypatch) -> None:
11
+ """Setup needed environment variables"""
12
+
13
+ # Allow accessing remote API schemas
14
+ # defaulting to the prod environment
15
+ schema_url = os.environ.get(
16
+ "ARKINDEX_API_SCHEMA_URL",
17
+ "https://demo.arkindex.org/api/v1/openapi/?format=openapi-json",
18
+ )
19
+ responses.add_passthru(schema_url)
20
+
21
+ # Set schema url in environment
22
+ os.environ["ARKINDEX_API_SCHEMA_URL"] = schema_url
23
+ # Setup a fake worker run ID
24
+ os.environ["ARKINDEX_WORKER_RUN_ID"] = "1234-demo"
25
+ # Setup a fake corpus ID
26
+ os.environ["ARKINDEX_CORPUS_ID"] = "1234-corpus-id"
27
+
28
+ # Setup a mock api client instead of using a real one
29
+ def mock_setup_api_client(self):
30
+ self.api_client = MockApiClient()
31
+
32
+ monkeypatch.setattr(BaseWorker, "setup_api_client", mock_setup_api_client)
@@ -0,0 +1,12 @@
1
+ import importlib
2
+
3
+
4
+ def test_dummy():
5
+ assert True
6
+
7
+
8
+ def test_import():
9
+ """Import our newly created module, through importlib to avoid parsing issues"""
10
+ worker = importlib.import_module("worker_demo.worker")
11
+ assert hasattr(worker, "Demo")
12
+ assert hasattr(worker.Demo, "process_element")
@@ -0,0 +1,6 @@
1
+ import logging
2
+
3
+ logging.basicConfig(
4
+ level=logging.INFO,
5
+ format="%(asctime)s %(levelname)s/%(name)s: %(message)s",
6
+ )
@@ -0,0 +1,19 @@
1
+ from logging import Logger, getLogger
2
+
3
+ from arkindex_worker.models import Element
4
+ from arkindex_worker.worker import ElementsWorker
5
+
6
+ logger: Logger = getLogger(__name__)
7
+
8
+
9
+ class Demo(ElementsWorker):
10
+ def process_element(self, element: Element) -> None:
11
+ logger.info(f"Demo processing element ({element.id})")
12
+
13
+
14
+ def main() -> None:
15
+ Demo(description="Demo ML worker for Arkindex").run()
16
+
17
+
18
+ if __name__ == "__main__":
19
+ main()
@@ -1,47 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: arkindex-base-worker
3
- Version: 0.3.6rc4
4
- Summary: Base Worker to easily build Arkindex ML workflows
5
- Author-email: Teklia <contact@teklia.com>
6
- Maintainer-email: Teklia <contact@teklia.com>
7
- Project-URL: Homepage, https://workers.arkindex.org
8
- Project-URL: Documentation, https://workers.arkindex.org
9
- Project-URL: Repository, https://gitlab.teklia.com/workers/base-worker
10
- Project-URL: Bug Tracker, https://gitlab.teklia.com/workers/base-worker/issues
11
- Project-URL: Authors, https://teklia.com
12
- Keywords: python
13
- Classifier: Development Status :: 5 - Production/Stable
14
- Classifier: License :: OSI Approved :: MIT License
15
- Classifier: Programming Language :: Python :: 3 :: Only
16
- Classifier: Programming Language :: Python :: 3.10
17
- Classifier: Programming Language :: Python :: 3.11
18
- Classifier: Topic :: Text Processing :: Linguistic
19
- Requires-Python: >=3.10
20
- Description-Content-Type: text/markdown
21
- Requires-Dist: arkindex-client ==1.0.14
22
- Requires-Dist: peewee ==3.17.0
23
- Requires-Dist: Pillow ==10.1.0
24
- Requires-Dist: pymdown-extensions ==10.3.1
25
- Requires-Dist: python-gnupg ==0.5.1
26
- Requires-Dist: shapely ==2.0.2
27
- Requires-Dist: tenacity ==8.2.3
28
- Requires-Dist: zstandard ==0.22.0
29
- Provides-Extra: docs
30
- Requires-Dist: black ==23.11.0 ; extra == 'docs'
31
- Requires-Dist: doc8 ==1.1.1 ; extra == 'docs'
32
- Requires-Dist: mkdocs ==1.5.3 ; extra == 'docs'
33
- Requires-Dist: mkdocs-material ==9.4.8 ; extra == 'docs'
34
- Requires-Dist: mkdocstrings ==0.23.0 ; extra == 'docs'
35
- Requires-Dist: mkdocstrings-python ==1.7.3 ; extra == 'docs'
36
- Requires-Dist: recommonmark ==0.7.1 ; extra == 'docs'
37
-
38
- # Arkindex base Worker
39
-
40
- An easy to use Python 3 high level API client, to build ML tasks.
41
-
42
- ## Create a new worker using our template
43
-
44
- ```
45
- pip install --user cookiecutter
46
- cookiecutter git@gitlab.teklia.com:workers/base-worker.git
47
- ```
@@ -1,40 +0,0 @@
1
- arkindex_worker/__init__.py,sha256=OlgCtTC9MaWeejviY0a3iQpALcRQGMVArFVVYwTF6I8,162
2
- arkindex_worker/cache.py,sha256=ZbXJo-O24W8x6nbS0IJm32Tas9CKLaHBBeyQyvF-Nyo,10903
3
- arkindex_worker/image.py,sha256=uwfUE9hy0Iw-e3vU7OHmLSqouxbznWq08SykXmPD1Cs,14107
4
- arkindex_worker/models.py,sha256=DVrZPIurSiOoHvj3t_Szwd0j1t6pnwBx_dqwhNakzN0,9528
5
- arkindex_worker/utils.py,sha256=_lC1-RYvNWXEkK-AuF4_FraoggP1tYPdalNFSj4jDb4,6885
6
- arkindex_worker/worker/__init__.py,sha256=Iun6jhuakKdCGKjQtgqDWEpWO1HrxK34RoxdzE5gcRs,19322
7
- arkindex_worker/worker/base.py,sha256=4eG4v4vejvFv9UtTRhxEZkXEBVzlFd3rILHK8lt-mbc,19397
8
- arkindex_worker/worker/classification.py,sha256=CoMIj7SFFlt90W1r5FQmsB80qK9Zfltcm3k-37FSHA0,10693
9
- arkindex_worker/worker/dataset.py,sha256=LRZU_KkOuCRkxlkdqw1PHYnu1zmoQfm_OiY8Sqt6mi0,2754
10
- arkindex_worker/worker/element.py,sha256=5z6yAO2jKCF4U7Tz2cGdFX34Zxdo0gBWkU-ciIZ69bQ,30705
11
- arkindex_worker/worker/entity.py,sha256=l0gCoeaoUBFU7pv2iC4pHkSQVjiIur4M15P7Mg_WlaA,13601
12
- arkindex_worker/worker/metadata.py,sha256=PnzyHkPyb-mtgItzRi4s-_f0dsEOM3ak8F_bFoqp3O0,6225
13
- arkindex_worker/worker/task.py,sha256=cz3wJNPgogZv1lm_3lm7WScitQtYQtL6H6I7Xokq208,1475
14
- arkindex_worker/worker/training.py,sha256=rhg4TPFo0ignnCkgbekUYmNXX8u2iZGyeM1VCs1R5kI,10140
15
- arkindex_worker/worker/transcription.py,sha256=OCjgajaPcX7CPHG1fT4nZccfp6bG6Mqdz3POPc9_iYQ,18765
16
- arkindex_worker/worker/version.py,sha256=uL-OrwuFZB8TNU6ePmdKIL3g3e-GE2tqHEWBRpXu-FU,1428
17
- tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
- tests/conftest.py,sha256=BEeyspbvxwSpFvQ1taj8ysnu7wAE3d7pWUDMmmKC5Ho,21837
19
- tests/test_base_worker.py,sha256=AF1pjvNckN80LVyLJ4ILXJ122fEnWtztK7ZncVDI_Ms,24976
20
- tests/test_cache.py,sha256=ii0gyr0DrG7ChEs7pmT8hMdSguAOAcCze4bRMiFQxuk,10640
21
- tests/test_dataset_worker.py,sha256=XxBCLRroCIq97P37_qWc9I7QiyE3zUL7fLAw1J_BI7E,27703
22
- tests/test_element.py,sha256=2G9M15TLxQRmvrWM9Kw2ucnElh4kSv_oF_5FYwwAxTY,13181
23
- tests/test_image.py,sha256=nIT0NhmuHtD9I1rcMSvqSfjQqvTE5Ko8tAQGLIkm_zo,15232
24
- tests/test_merge.py,sha256=Q4zCbtZbe0wBfqE56gvAD06c6pDuhqnjKaioFqIgAQw,8331
25
- tests/test_utils.py,sha256=pFXegcBvIuy1tJDDSgQtCbC_tRaoLjd2055R5lu3hS0,1236
26
- tests/test_elements_worker/__init__.py,sha256=Fh4nkbbyJSMv_VtjQxnWrOqTnxXaaWI8S9WU0VrzCHs,179
27
- tests/test_elements_worker/test_classifications.py,sha256=0_6vryoQc2-s3CQWANsEvajkyC3aub34cxb3r97pRsk,32027
28
- tests/test_elements_worker/test_cli.py,sha256=DdCRKobesehL61c5QwaZOZCde7bsTlmeSN2iosQ5_2s,2873
29
- tests/test_elements_worker/test_dataset.py,sha256=ElDPrYTTt8KzaZ_Xf5uslUD6_kiGZybntO10uqCquLo,12063
30
- tests/test_elements_worker/test_elements.py,sha256=F7azXQBNec4QLH62uXaGgAgg82GEz0q98pYXH3Sh640,75761
31
- tests/test_elements_worker/test_entities.py,sha256=ZOFB3ckKJvNG2kIPUX_kz_378k3uQrJmvYHpR_xiVuo,33789
32
- tests/test_elements_worker/test_metadata.py,sha256=c3kXPYRXVPDnGim28Ncg5YO4I0ejh3qyi7dBvbSYxMU,17739
33
- tests/test_elements_worker/test_task.py,sha256=FCpxE9UpouKXgjGvWgNHEai_Hiy2d1YmqRG-_v2s27s,6312
34
- tests/test_elements_worker/test_training.py,sha256=WeG-cDuJ-YhPgfKH47TtXBxyargtLuk7c8tsik2WnL8,8414
35
- tests/test_elements_worker/test_transcriptions.py,sha256=6UWGriQVwEORunJYW11mGcD16voZGFY41i_NIdXuqnI,68750
36
- tests/test_elements_worker/test_worker.py,sha256=zD8sY5yZFhuUr1txVX8z7bSgW4I2jNuzH5i1TM3qkZI,16491
37
- arkindex_base_worker-0.3.6rc4.dist-info/METADATA,sha256=5ug8gbQxLwb87ArFDtHn32bekEexXmiTEysRPA3UKio,1814
38
- arkindex_base_worker-0.3.6rc4.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
39
- arkindex_base_worker-0.3.6rc4.dist-info/top_level.txt,sha256=TtagLI8LSv7GE7nG8MQqDFAJ5bNDPJn7Z5vizOgrWkA,22
40
- arkindex_base_worker-0.3.6rc4.dist-info/RECORD,,