arkindex-client 1.0.16__py3-none-any.whl → 1.1.0__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.
@@ -0,0 +1,27 @@
1
+ Metadata-Version: 2.1
2
+ Name: arkindex-client
3
+ Version: 1.1.0
4
+ Summary: API client for the Arkindex project
5
+ Home-page: https://gitlab.teklia.com/arkindex/api-client
6
+ Author: Teklia <contact@teklia.com>
7
+ License: AGPL-v3
8
+ Keywords: api client arkindex
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Natural Language :: English
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Topic :: Scientific/Engineering :: Image Recognition
19
+ Classifier: Topic :: Text Processing :: Indexing
20
+ Classifier: Topic :: Text Processing :: Linguistic
21
+ Requires-Python: >=3.8
22
+ License-File: LICENSE
23
+ Requires-Dist: requests~=2.28
24
+ Requires-Dist: tenacity==8.2.3
25
+ Requires-Dist: typesystem==0.2.5
26
+
27
+ Documentation is available at https://api.arkindex.org
@@ -0,0 +1,23 @@
1
+ apistar/__init__.py,sha256=mX65SD-MGA1ZynGKkqh7zEONxAIMsPktTaAXeh69Kwc,231
2
+ apistar/exceptions.py,sha256=yzjDlUB5o0xaORBabqTXmf4ckYjNHz1ceV8ECg3jDek,328
3
+ arkindex/__init__.py,sha256=OBw25Nwe6r1AN3a36-8lnUcDy3nkDIiebBgYNK2Zo9o,99
4
+ arkindex/auth.py,sha256=OeuzFeCQ8FAt0kqPECjsEz-Ki9__-y69z5sAuyTZ28c,1550
5
+ arkindex/compat.py,sha256=Kjxu--QoF8sBxKOvXMtNcDQ0XK7MLc_2C8Q2knll4Lk,805
6
+ arkindex/document.py,sha256=SUmzvuJpeHlRC4ozqnqsPFpzZ9_Yb9p6vxIZpMjMCSA,6783
7
+ arkindex/exceptions.py,sha256=hDxbgC7uAD8wbTQS1DaEJZ25Nun41Io8Y0BiwrZ1ZSM,2016
8
+ arkindex/mock.py,sha256=olYBFCkLQuuf9gGu7wlmZiLFMQknGGi8evS531RjjUE,2755
9
+ arkindex/pagination.py,sha256=c6dG_OkQDG00ZfGUbHuZxu-UvOpmYf7dJP1ZaUaha1Y,9008
10
+ arkindex/client/__init__.py,sha256=g_G_bSfMbduYzpi9iURTn0cYLV4nMulDR8rD7x-DLyc,142
11
+ arkindex/client/base.py,sha256=vlR5HjaNQ_LzIP_FAzaZbhJSh7VzD9mXc0T8C5FB8EU,3400
12
+ arkindex/client/client.py,sha256=lfHyicizHDxdymPA1hl0kJj7vdrudVvbE2Ei3qtZqQM,12019
13
+ arkindex/client/decoders.py,sha256=F_uBGOrh1BFnZzuW0MTjwm8wAArbybPsrIVol_2vYN0,7886
14
+ arkindex/client/transports.py,sha256=482CHa-8S5p190Z4cX6TiCWgz99enfloT7FCNuS02yY,4055
15
+ arkindex/schema/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
+ arkindex/schema/jsonschema.py,sha256=sJ0OlkowXoE4FnA3r9_QdOmLlDP46K7YPPQm58NkfMo,2572
17
+ arkindex/schema/openapi.py,sha256=bwVAEjdHNUf9iRPVdbQwruivs4GAwbe0db1KkLNKa80,17603
18
+ arkindex/schema/validator.py,sha256=N2sda7vxfivw68VuyX-MfmUlrXjf_LEHNg6OCKc1mjQ,1926
19
+ arkindex_client-1.1.0.dist-info/LICENSE,sha256=s7yDHdG8liSj2PiaVwRi9G5wR1qDXSPmhPJPgWbrkWU,34504
20
+ arkindex_client-1.1.0.dist-info/METADATA,sha256=fBQLOlFiDD82lQgDdFhyPHeiHmnrAhPWQA2MwrnP8A0,1051
21
+ arkindex_client-1.1.0.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
22
+ arkindex_client-1.1.0.dist-info/top_level.txt,sha256=ALyF0lTPpxOheUGmSVwEhgI6eMYwm_9Eu37G-RwGBRM,17
23
+ arkindex_client-1.1.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.2)
2
+ Generator: bdist_wheel (0.44.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
arkindex/transports.py DELETED
@@ -1,14 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- from apistar.client.transports import HTTPTransport
3
-
4
-
5
- class ArkindexHTTPTransport(HTTPTransport):
6
- def __init__(self, verify=True, *args, **kwargs):
7
- super().__init__(*args, **kwargs)
8
- self.verify = verify
9
-
10
- def get_request_options(self, *args, **kwargs):
11
- options = super().get_request_options(*args, **kwargs)
12
- options["timeout"] = (30, 60)
13
- options["verify"] = self.verify
14
- return options
@@ -1,225 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: arkindex-client
3
- Version: 1.0.16
4
- Summary: API client for the Arkindex project
5
- Home-page: https://gitlab.teklia.com/arkindex/api-client
6
- Author: Teklia <contact@teklia.com>
7
- License: MIT
8
- Keywords: api client arkindex
9
- Platform: UNKNOWN
10
- Classifier: License :: OSI Approved :: MIT License
11
- Classifier: Natural Language :: English
12
- Classifier: Intended Audience :: Science/Research
13
- Classifier: Programming Language :: Python :: 3
14
- Classifier: Programming Language :: Python :: 3 :: Only
15
- Classifier: Programming Language :: Python :: 3.7
16
- Classifier: Programming Language :: Python :: 3.8
17
- Classifier: Topic :: Scientific/Engineering :: Image Recognition
18
- Classifier: Topic :: Text Processing :: Indexing
19
- Classifier: Topic :: Text Processing :: Linguistic
20
- Requires-Python: >=3.7
21
- Description-Content-Type: text/x-rst
22
- Requires-Dist: apistar ==0.7.2
23
- Requires-Dist: requests ~=2.28
24
- Requires-Dist: tenacity ==8.2.3
25
- Requires-Dist: typesystem ==0.2.5
26
-
27
- Arkindex API Client
28
- ===================
29
-
30
- ``arkindex-client`` provides an API client to interact with Arkindex servers.
31
-
32
- .. contents::
33
- :depth: 2
34
- :local:
35
- :backlinks: none
36
-
37
- Setup
38
- -----
39
-
40
- Install the client using ``pip``::
41
-
42
- pip install arkindex-client
43
-
44
- Usage
45
- -----
46
-
47
- To create a client and login using an email/password combo,
48
- use the ``ArkindexClient.login`` helper method:
49
-
50
- .. code:: python
51
-
52
- from arkindex import ArkindexClient
53
- cli = ArkindexClient()
54
- cli.login('EMAIL', 'PASSWORD')
55
-
56
- This helper method will save the authentication token in your API client, so
57
- that it is reused in later API requests.
58
-
59
- If you already have an API token, you can create your client like so:
60
-
61
- .. code:: python
62
-
63
- from arkindex import ArkindexClient
64
- cli = ArkindexClient('YOUR_TOKEN')
65
-
66
- Making requests
67
- ^^^^^^^^^^^^^^^
68
-
69
- To perform a simple API request, you can use the ``request()`` method. The method
70
- takes an operation ID as a name and the operation's parameters as keyword arguments.
71
-
72
- You can open ``https://your.arkindex/api-docs/`` to access the API documentation,
73
- which will describe the available API endpoints, including their operation ID and
74
- parameters.
75
-
76
- .. code:: python
77
-
78
- corpus = cli.request('RetrieveCorpus', id='...')
79
-
80
- The result will be a Python ``dict`` containing the result of the API request.
81
- If the request returns an error, an ``apistar.exceptions.ErrorResponse`` will
82
- be raised.
83
-
84
- Dealing with pagination
85
- ^^^^^^^^^^^^^^^^^^^^^^^
86
-
87
- The Arkindex client adds another helper method for paginated endpoints that
88
- deals with pagination for you: ``ArkindexClient.paginate``. This method
89
- returns a ``ResponsePaginator`` instance, which is a classic Python
90
- iterator that does not perform any actual requests until absolutely needed:
91
- that is, until the next page must be loaded.
92
-
93
- .. code:: python
94
-
95
- for element in cli.paginate('ListElements', corpus=corpus['id']):
96
- print(element['name'])
97
-
98
- **Warning:** Using ``list`` on a ``ResponsePaginator`` may load dozens
99
- of pages at once and cause a big load on the server. You can use ``len`` to
100
- get the total item count before spamming a server.
101
-
102
- A call to ``paginate`` may produce hundreds of sub-requests depending on the size
103
- of the dataset you're requesting. To accommodate with large datasets, and support
104
- network or performance issues, ``paginate`` supports a ``retries`` parameter to
105
- specify the number of sub-request it's able to run for each page in the dataset.
106
- By default, the method will retry 5 times per page.
107
-
108
- You may want to allow ``paginate`` to fail on some pages, for really big datasets
109
- (errors happen). In this case, you should use the optional boolean parameter
110
- ``allow_missing_data`` (set to ``False`` by default).
111
-
112
- Here is an example of pagination on a large dataset, allowing data loss, lowering
113
- retries and listing the missed pages:
114
-
115
- .. code:: python
116
-
117
- elements = cli.paginate(
118
- 'ListProcessElements',
119
- id='XXX',
120
- retries=3,
121
- allow_missing_data=True,
122
- )
123
- for element in elements:
124
- print(element['id'])
125
-
126
- print("Missing pages: {elements.missing}")
127
-
128
-
129
-
130
- Using another server
131
- ^^^^^^^^^^^^^^^^^^^^
132
-
133
- By default, the API client is set to point to the main Arkindex server at
134
- https://arkindex.teklia.com. If you need or want to use this API client on
135
- another server, you can use the ``base_url`` keyword argument when setting up
136
- your API client:
137
-
138
- .. code:: python
139
-
140
- cli = ArkindexClient(base_url='https://somewhere')
141
-
142
- Handling errors
143
- ^^^^^^^^^^^^^^^
144
-
145
- APIStar_, the underlying API client we use, does most of the error handling.
146
- It will raise two types of exceptions:
147
-
148
- ``apistar.exceptions.ErrorResponse``
149
- The request resulted in a HTTP 4xx or 5xx response from the server.
150
- ``apistar.exceptions.ClientError``
151
- Any error that prevents the client from making the request or fetching
152
- the response: invalid endpoint names or URLs, unsupported content types,
153
- or unknown request parameters. See the exception messages for more info.
154
-
155
- Since this API client retrieves the endpoints description from the server
156
- using the base URL, errors can occur during the retrieval and parsing of the
157
- API schema. If this happens, an ``arkindex.exceptions.SchemaError`` exception
158
- will be raised.
159
-
160
- You can handle HTTP errors and fetch more information about them using the
161
- exception's attributes:
162
-
163
- .. code:: python
164
-
165
- from apistar.exceptions import ErrorResponse
166
- try:
167
- # cli.request ...
168
- except ErrorResponse as e:
169
- print(e.title) # "400 Bad Request"
170
- print(e.status_code) # 400
171
- print(e.content) # Any kind of response body the server might give
172
-
173
- Note that by default, using ``repr()`` or ``str()`` on APIStar exceptions will
174
- not give any useful messages; a fix in APIStar is waiting to be merged. In
175
- the meantime, you can use Teklia's `APIStar fork`_::
176
-
177
- pip install git+https://gitlab.teklia.com/arkindex/apistar.git
178
-
179
- This will provide support for ``repr()`` and ``str()``, which will also
180
- enhance error messages on unhandled exceptions.
181
-
182
- Examples
183
- --------
184
-
185
- Print all folders
186
- ^^^^^^^^^^^^^^^^^
187
-
188
- .. code:: python
189
-
190
- for folder in cli.paginate('ListElements', folder=True):
191
- print(folder['name'])
192
-
193
- Download full logs for each Ponos task in a workflow
194
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
195
-
196
- .. code:: python
197
-
198
- workflow = cli.request('RetrieveWorkflow', id='...')
199
- for task in workflow['tasks']:
200
- with open(task['id'] + '.txt', 'w') as f:
201
- f.write(cli.request('RetrieveTaskLog', id=task['id']))
202
-
203
- .. _APIStar: http://docs.apistar.com/
204
- .. _APIStar fork: https://gitlab.teklia.com/arkindex/apistar
205
-
206
- Linting
207
- -------
208
-
209
- We use `pre-commit <https://pre-commit.com/>`_ with `black <https://github.com/psf/black>`_ to automatically format the Python source code of this project.
210
-
211
- To be efficient, you should run pre-commit before committing (hence the name...).
212
-
213
- To do that, run once :
214
-
215
- .. code:: shell
216
-
217
- pip install pre-commit
218
- pre-commit install
219
-
220
- The linting workflow will now run on modified files before committing, and will fix issues for you.
221
-
222
- If you want to run the full workflow on all the files: `pre-commit run -a`.
223
-
224
-
225
-
@@ -1,11 +0,0 @@
1
- arkindex/__init__.py,sha256=OBw25Nwe6r1AN3a36-8lnUcDy3nkDIiebBgYNK2Zo9o,99
2
- arkindex/auth.py,sha256=O45HgpsblBqNJr9nRALU14wZgCGcmCgcGjAoD0zAyrg,1073
3
- arkindex/client.py,sha256=SLFJzZI31y3UAufyUBdDiUgh7_IwRK0ItRwOSgCZflU,11984
4
- arkindex/exceptions.py,sha256=3jzuuXgsPA28qH7GMwPVQisWCvitAQtYiQ5uKxzFQ_M,155
5
- arkindex/mock.py,sha256=hWU8EKfvVBAQ8VVI4Rgic809GLLDoh8Nvuvih54luKQ,2762
6
- arkindex/pagination.py,sha256=tIt3ecD44UcuxT3mV7gtwvqoqdeAICaq5okr1z4_xgo,8954
7
- arkindex/transports.py,sha256=RmQ9fXdnLd6PizifyVI5E7QTIj3MU6Xua76jp87TKpM,464
8
- arkindex_client-1.0.16.dist-info/METADATA,sha256=noYxsy3dMHgo0Ob_bmU3qT0c_KBAap7hW6CDz-AuEIE,7059
9
- arkindex_client-1.0.16.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
10
- arkindex_client-1.0.16.dist-info/top_level.txt,sha256=iP1TxDW_jSDQA4FIcahBFXiDcZXqam2a_gFVnDbR3c4,9
11
- arkindex_client-1.0.16.dist-info/RECORD,,