arkindex-client 1.0.9__tar.gz → 1.0.12__tar.gz
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-client-1.0.9 → arkindex-client-1.0.12}/PKG-INFO +4 -4
- arkindex-client-1.0.12/VERSION +1 -0
- {arkindex-client-1.0.9 → arkindex-client-1.0.12}/arkindex/client.py +34 -4
- {arkindex-client-1.0.9 → arkindex-client-1.0.12}/arkindex/pagination.py +19 -3
- {arkindex-client-1.0.9 → arkindex-client-1.0.12}/arkindex_client.egg-info/PKG-INFO +4 -4
- {arkindex-client-1.0.9 → arkindex-client-1.0.12}/arkindex_client.egg-info/requires.txt +1 -1
- {arkindex-client-1.0.9 → arkindex-client-1.0.12}/requirements.txt +1 -1
- {arkindex-client-1.0.9 → arkindex-client-1.0.12}/setup.py +3 -3
- arkindex-client-1.0.9/VERSION +0 -1
- {arkindex-client-1.0.9 → arkindex-client-1.0.12}/MANIFEST.in +0 -0
- {arkindex-client-1.0.9 → arkindex-client-1.0.12}/README.rst +0 -0
- {arkindex-client-1.0.9 → arkindex-client-1.0.12}/arkindex/__init__.py +0 -0
- {arkindex-client-1.0.9 → arkindex-client-1.0.12}/arkindex/auth.py +0 -0
- {arkindex-client-1.0.9 → arkindex-client-1.0.12}/arkindex/exceptions.py +0 -0
- {arkindex-client-1.0.9 → arkindex-client-1.0.12}/arkindex/mock.py +0 -0
- {arkindex-client-1.0.9 → arkindex-client-1.0.12}/arkindex/transports.py +0 -0
- {arkindex-client-1.0.9 → arkindex-client-1.0.12}/arkindex_client.egg-info/SOURCES.txt +0 -0
- {arkindex-client-1.0.9 → arkindex-client-1.0.12}/arkindex_client.egg-info/dependency_links.txt +0 -0
- {arkindex-client-1.0.9 → arkindex-client-1.0.12}/arkindex_client.egg-info/top_level.txt +0 -0
- {arkindex-client-1.0.9 → arkindex-client-1.0.12}/setup.cfg +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: arkindex-client
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.12
|
|
4
4
|
Summary: API client for the Arkindex project
|
|
5
|
-
Home-page: https://gitlab.com/arkindex/api-client
|
|
5
|
+
Home-page: https://gitlab.com/teklia/arkindex/api-client
|
|
6
6
|
Author: Teklia <contact@teklia.com>
|
|
7
7
|
License: MIT
|
|
8
8
|
Keywords: api client arkindex
|
|
@@ -12,12 +12,12 @@ Classifier: Natural Language :: English
|
|
|
12
12
|
Classifier: Intended Audience :: Science/Research
|
|
13
13
|
Classifier: Programming Language :: Python :: 3
|
|
14
14
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.6
|
|
16
15
|
Classifier: Programming Language :: Python :: 3.7
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
17
17
|
Classifier: Topic :: Scientific/Engineering :: Image Recognition
|
|
18
18
|
Classifier: Topic :: Text Processing :: Indexing
|
|
19
19
|
Classifier: Topic :: Text Processing :: Linguistic
|
|
20
|
-
Requires-Python: >=3.
|
|
20
|
+
Requires-Python: >=3.7
|
|
21
21
|
Description-Content-Type: text/x-rst
|
|
22
22
|
|
|
23
23
|
Arkindex API Client
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1.0.12
|
|
@@ -32,9 +32,18 @@ def options_from_env():
|
|
|
32
32
|
Get API client keyword arguments from environment variables.
|
|
33
33
|
"""
|
|
34
34
|
options = {}
|
|
35
|
-
|
|
35
|
+
# ARKINDEX_TASK_TOKEN takes priority over ARKINDEX_API_TOKEN
|
|
36
|
+
if "ARKINDEX_TASK_TOKEN" in os.environ:
|
|
37
|
+
options["auth_scheme"] = "Ponos"
|
|
38
|
+
options["token"] = os.environ.get("ARKINDEX_TASK_TOKEN")
|
|
39
|
+
elif "ARKINDEX_API_TOKEN" in os.environ:
|
|
40
|
+
options["auth_scheme"] = "Token"
|
|
36
41
|
options["token"] = os.environ.get("ARKINDEX_API_TOKEN")
|
|
37
42
|
|
|
43
|
+
# Allow overriding the default auth schemes
|
|
44
|
+
if "ARKINDEX_API_AUTH_SCHEME" in os.environ:
|
|
45
|
+
options["auth_scheme"] = os.environ.get("ARKINDEX_API_AUTH_SCHEME")
|
|
46
|
+
|
|
38
47
|
if "ARKINDEX_API_URL" in os.environ:
|
|
39
48
|
options["base_url"] = os.environ.get("ARKINDEX_API_URL")
|
|
40
49
|
|
|
@@ -63,6 +72,7 @@ class ArkindexClient(apistar.Client):
|
|
|
63
72
|
def __init__(
|
|
64
73
|
self,
|
|
65
74
|
token=None,
|
|
75
|
+
auth_scheme="Token",
|
|
66
76
|
base_url=DEFAULT_BASE_URL,
|
|
67
77
|
schema_url=None,
|
|
68
78
|
csrf_cookie=None,
|
|
@@ -139,7 +149,11 @@ class ArkindexClient(apistar.Client):
|
|
|
139
149
|
csrf_cookie = csrf_cookies.get(split_base_url.netloc) or "arkindex.csrf"
|
|
140
150
|
|
|
141
151
|
self.configure(
|
|
142
|
-
token=token,
|
|
152
|
+
token=token,
|
|
153
|
+
auth_scheme=auth_scheme,
|
|
154
|
+
base_url=base_url,
|
|
155
|
+
csrf_cookie=csrf_cookie,
|
|
156
|
+
sleep=sleep,
|
|
143
157
|
)
|
|
144
158
|
|
|
145
159
|
def __repr__(self):
|
|
@@ -151,12 +165,25 @@ class ArkindexClient(apistar.Client):
|
|
|
151
165
|
def init_transport(self, *args, **kwargs):
|
|
152
166
|
return ArkindexHTTPTransport(*args, **kwargs)
|
|
153
167
|
|
|
154
|
-
def configure(
|
|
168
|
+
def configure(
|
|
169
|
+
self,
|
|
170
|
+
token=None,
|
|
171
|
+
auth_scheme="Token",
|
|
172
|
+
base_url=None,
|
|
173
|
+
csrf_cookie=None,
|
|
174
|
+
sleep=None,
|
|
175
|
+
):
|
|
155
176
|
"""
|
|
156
177
|
Reconfigure the API client.
|
|
157
178
|
|
|
158
179
|
:param token: An API token to use. If omitted, access is restricted to public endpoints.
|
|
159
180
|
:type token: str or None
|
|
181
|
+
:param auth_scheme:
|
|
182
|
+
An authentication scheme to use. This is added in the HTTP header before the token:
|
|
183
|
+
``Authorization: [scheme] [token]``.
|
|
184
|
+
This should use ``Token`` to authenticate as a regular user and ``Ponos`` to authenticate as a Ponos task.
|
|
185
|
+
If omitted, this defaults to ``Token``.
|
|
186
|
+
:type auth_scheme: str or None
|
|
160
187
|
:param base_url: A custom base URL for the client. If omitted, defaults to the Arkindex main server.
|
|
161
188
|
:type base_url: str or None
|
|
162
189
|
:param csrf_cookie: Use a custom CSRF cookie name. Falls back to ``arkindex.csrf``.
|
|
@@ -167,7 +194,9 @@ class ArkindexClient(apistar.Client):
|
|
|
167
194
|
if not csrf_cookie:
|
|
168
195
|
csrf_cookie = "arkindex.csrf"
|
|
169
196
|
self.transport.session.auth = TokenSessionAuthentication(
|
|
170
|
-
token,
|
|
197
|
+
token,
|
|
198
|
+
csrf_cookie_name=csrf_cookie,
|
|
199
|
+
scheme=auth_scheme,
|
|
171
200
|
)
|
|
172
201
|
|
|
173
202
|
if not sleep or not isinstance(sleep, float) or sleep < 0:
|
|
@@ -200,6 +229,7 @@ class ArkindexClient(apistar.Client):
|
|
|
200
229
|
"""
|
|
201
230
|
resp = self.request("Login", body={"email": email, "password": password})
|
|
202
231
|
if "auth_token" in resp:
|
|
232
|
+
self.transport.session.auth.scheme = "Token"
|
|
203
233
|
self.transport.session.auth.token = resp["auth_token"]
|
|
204
234
|
return resp
|
|
205
235
|
|
|
@@ -81,6 +81,14 @@ class ResponsePaginator(Sized, Iterator):
|
|
|
81
81
|
), "allow_missing_data must be a boolean"
|
|
82
82
|
|
|
83
83
|
def _fetch_page(self):
|
|
84
|
+
"""
|
|
85
|
+
Retrieve the next page and store its results
|
|
86
|
+
|
|
87
|
+
Returns None in case of a failure
|
|
88
|
+
Returns True in case the page returned results
|
|
89
|
+
Returns False in case the page returned an empty result
|
|
90
|
+
Raises a StopIteration in case there are no pages left to iterate on
|
|
91
|
+
"""
|
|
84
92
|
# Filter out pages with no retries
|
|
85
93
|
# Transform as a list of tuples for simpler output
|
|
86
94
|
remaining = sorted([(m, v) for m, v in self.pages.items() if v > 0])
|
|
@@ -136,7 +144,7 @@ class ResponsePaginator(Sized, Iterator):
|
|
|
136
144
|
if self.count == 0:
|
|
137
145
|
# Pagination has retrieved 0 results
|
|
138
146
|
self.pages = {}
|
|
139
|
-
return
|
|
147
|
+
return False
|
|
140
148
|
self.pages_count = math.ceil(self.count / len(self.results))
|
|
141
149
|
logger.info(
|
|
142
150
|
f"Pagination will load a total of {self.pages_count} pages."
|
|
@@ -161,7 +169,7 @@ class ResponsePaginator(Sized, Iterator):
|
|
|
161
169
|
|
|
162
170
|
# Stop happy path here, we don't need to process errors
|
|
163
171
|
self.pages_loaded += 1
|
|
164
|
-
return
|
|
172
|
+
return True
|
|
165
173
|
|
|
166
174
|
except apistar.exceptions.ErrorResponse as e:
|
|
167
175
|
logger.warning(f"API Error {e.status_code} on pagination: {e.content}")
|
|
@@ -194,6 +202,9 @@ class ResponsePaginator(Sized, Iterator):
|
|
|
194
202
|
else:
|
|
195
203
|
raise Exception("Stopping pagination as data will be incomplete")
|
|
196
204
|
|
|
205
|
+
# No data could be fetch, return None
|
|
206
|
+
return None
|
|
207
|
+
|
|
197
208
|
def __iter__(self):
|
|
198
209
|
return self
|
|
199
210
|
|
|
@@ -216,7 +227,12 @@ class ResponsePaginator(Sized, Iterator):
|
|
|
216
227
|
def __len__(self):
|
|
217
228
|
# Handle calls to len when no requests have been made yet
|
|
218
229
|
if not self.pages_loaded and self.count is None:
|
|
219
|
-
|
|
230
|
+
# Continuously try to fetch a page until there are no retries left
|
|
231
|
+
while self._fetch_page() is None:
|
|
232
|
+
pass
|
|
233
|
+
# Count may be null in case of a StopIteration
|
|
234
|
+
if self.count is None:
|
|
235
|
+
raise Exception("An error occurred fetching items total count")
|
|
220
236
|
return self.count
|
|
221
237
|
|
|
222
238
|
def __repr__(self):
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: arkindex-client
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.12
|
|
4
4
|
Summary: API client for the Arkindex project
|
|
5
|
-
Home-page: https://gitlab.com/arkindex/api-client
|
|
5
|
+
Home-page: https://gitlab.com/teklia/arkindex/api-client
|
|
6
6
|
Author: Teklia <contact@teklia.com>
|
|
7
7
|
License: MIT
|
|
8
8
|
Keywords: api client arkindex
|
|
@@ -12,12 +12,12 @@ Classifier: Natural Language :: English
|
|
|
12
12
|
Classifier: Intended Audience :: Science/Research
|
|
13
13
|
Classifier: Programming Language :: Python :: 3
|
|
14
14
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.6
|
|
16
15
|
Classifier: Programming Language :: Python :: 3.7
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
17
17
|
Classifier: Topic :: Scientific/Engineering :: Image Recognition
|
|
18
18
|
Classifier: Topic :: Text Processing :: Indexing
|
|
19
19
|
Classifier: Topic :: Text Processing :: Linguistic
|
|
20
|
-
Requires-Python: >=3.
|
|
20
|
+
Requires-Python: >=3.7
|
|
21
21
|
Description-Content-Type: text/x-rst
|
|
22
22
|
|
|
23
23
|
Arkindex API Client
|
|
@@ -16,21 +16,21 @@ setup(
|
|
|
16
16
|
),
|
|
17
17
|
package_data={"": ["*.rst", "LICENSE", "README"], "arkindex": ["schema.yml"]},
|
|
18
18
|
install_requires=read_requirements("requirements.txt"),
|
|
19
|
-
python_requires=">=3.
|
|
19
|
+
python_requires=">=3.7",
|
|
20
20
|
license="MIT",
|
|
21
21
|
description="API client for the Arkindex project",
|
|
22
22
|
long_description=open("README.rst").read(),
|
|
23
23
|
long_description_content_type="text/x-rst",
|
|
24
24
|
keywords="api client arkindex",
|
|
25
|
-
url="https://gitlab.com/arkindex/api-client",
|
|
25
|
+
url="https://gitlab.com/teklia/arkindex/api-client",
|
|
26
26
|
classifiers=[
|
|
27
27
|
"License :: OSI Approved :: MIT License",
|
|
28
28
|
"Natural Language :: English",
|
|
29
29
|
"Intended Audience :: Science/Research",
|
|
30
30
|
"Programming Language :: Python :: 3",
|
|
31
31
|
"Programming Language :: Python :: 3 :: Only",
|
|
32
|
-
"Programming Language :: Python :: 3.6",
|
|
33
32
|
"Programming Language :: Python :: 3.7",
|
|
33
|
+
"Programming Language :: Python :: 3.8",
|
|
34
34
|
"Topic :: Scientific/Engineering :: Image Recognition",
|
|
35
35
|
"Topic :: Text Processing :: Indexing",
|
|
36
36
|
"Topic :: Text Processing :: Linguistic",
|
arkindex-client-1.0.9/VERSION
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
1.0.9
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{arkindex-client-1.0.9 → arkindex-client-1.0.12}/arkindex_client.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|