libentry 1.15__py3-none-any.whl → 1.17__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.
- libentry/api.py +4 -4
- libentry/service/flask.py +26 -1
- {libentry-1.15.dist-info → libentry-1.17.dist-info}/METADATA +1 -1
- {libentry-1.15.dist-info → libentry-1.17.dist-info}/RECORD +8 -8
- {libentry-1.15.dist-info → libentry-1.17.dist-info}/LICENSE +0 -0
- {libentry-1.15.dist-info → libentry-1.17.dist-info}/WHEEL +0 -0
- {libentry-1.15.dist-info → libentry-1.17.dist-info}/top_level.txt +0 -0
- {libentry-1.15.dist-info → libentry-1.17.dist-info}/zip-safe +0 -0
libentry/api.py
CHANGED
@@ -214,12 +214,12 @@ class APIClient:
|
|
214
214
|
|
215
215
|
def get(
|
216
216
|
self,
|
217
|
-
path: str,
|
217
|
+
path: Optional[str] = None, *,
|
218
218
|
num_trials: int = 5,
|
219
219
|
retry_factor: float = 2,
|
220
220
|
timeout: float = 15
|
221
221
|
):
|
222
|
-
full_url = urljoin(self.base_url, path)
|
222
|
+
full_url = urljoin(self.base_url, path)
|
223
223
|
response = self._request(
|
224
224
|
"get",
|
225
225
|
url=full_url,
|
@@ -242,7 +242,7 @@ class APIClient:
|
|
242
242
|
|
243
243
|
def post(
|
244
244
|
self,
|
245
|
-
path: str,
|
245
|
+
path: Optional[str] = None,
|
246
246
|
json_data: Optional[Mapping] = None, *,
|
247
247
|
stream: bool = False,
|
248
248
|
exhaust_stream: bool = False,
|
@@ -254,7 +254,7 @@ class APIClient:
|
|
254
254
|
chunk_suffix: str = None,
|
255
255
|
error_prefix: str = "ERROR: "
|
256
256
|
):
|
257
|
-
full_url = urljoin(self.base_url, path)
|
257
|
+
full_url = urljoin(self.base_url, path)
|
258
258
|
|
259
259
|
headers = {**self.headers}
|
260
260
|
headers["Accept"] = headers["Accept"] + f"; stream={int(stream)}"
|
libentry/service/flask.py
CHANGED
@@ -13,7 +13,6 @@ from types import GeneratorType
|
|
13
13
|
from typing import Any, Callable, Iterable, Optional, Type, Union
|
14
14
|
|
15
15
|
from flask import Flask, request
|
16
|
-
from gunicorn.app.base import BaseApplication
|
17
16
|
from pydantic import BaseModel, Field, create_model
|
18
17
|
|
19
18
|
from libentry import api, json
|
@@ -21,6 +20,26 @@ from libentry.api import APIInfo, list_api_info
|
|
21
20
|
from libentry.logging import logger
|
22
21
|
from libentry.schema import query_api
|
23
22
|
|
23
|
+
try:
|
24
|
+
from gunicorn.app.base import BaseApplication
|
25
|
+
except ImportError:
|
26
|
+
class BaseApplication:
|
27
|
+
|
28
|
+
def load(self) -> Flask:
|
29
|
+
pass
|
30
|
+
|
31
|
+
def run(self):
|
32
|
+
flask_server = self.load()
|
33
|
+
assert hasattr(self, "options")
|
34
|
+
bind = getattr(self, "options")["bind"]
|
35
|
+
pos = bind.rfind(":")
|
36
|
+
host = bind[:pos]
|
37
|
+
port = int(bind[pos + 1:])
|
38
|
+
logger.warn("Your system doesn't support gunicorn.")
|
39
|
+
logger.warn("Use Flask directly.")
|
40
|
+
logger.warn("Options like \"num_threads\", \"num_workers\" are ignored.")
|
41
|
+
return flask_server.run(host=host, port=port)
|
42
|
+
|
24
43
|
|
25
44
|
class JSONDumper:
|
26
45
|
|
@@ -261,6 +280,11 @@ class FlaskServer(Flask):
|
|
261
280
|
for fn, api_info in list_api_info(self):
|
262
281
|
method = api_info.method
|
263
282
|
path = api_info.path
|
283
|
+
|
284
|
+
if any(api_info.path == a.path for _, a in self.api_info_list):
|
285
|
+
logger.info(f"Use custom implementation of {path}.")
|
286
|
+
continue
|
287
|
+
|
264
288
|
if asyncio.iscoroutinefunction(fn):
|
265
289
|
logger.error(f"Async function \"{fn.__name__}\" is not supported.")
|
266
290
|
continue
|
@@ -368,3 +392,4 @@ def run_service(
|
|
368
392
|
for name, value in options.items():
|
369
393
|
logger.info(f"Option {name}: {value}")
|
370
394
|
GunicornApplication(service_type, service_config, options).run()
|
395
|
+
|
@@ -1,5 +1,5 @@
|
|
1
1
|
libentry/__init__.py,sha256=rDBip9M1Xb1N4wMKE1ni_DldrQbkRjp8DxPkTp3K2qo,170
|
2
|
-
libentry/api.py,sha256=
|
2
|
+
libentry/api.py,sha256=zvW4YugZ7k0wmVVFTnOYHgNqWQPf8zTTPYOnED-iUJM,10097
|
3
3
|
libentry/argparse.py,sha256=NxzXV-jBN51ReZsNs5aeyOfzwYQ5A5nJ95rWoa-FYCs,10415
|
4
4
|
libentry/dataclasses.py,sha256=AQV2PuxplJCwGZ5HKX72U-z-POUhTdy3XtpEK9KNIGQ,4541
|
5
5
|
libentry/executor.py,sha256=cTV0WxJi0nU1TP-cOwmeodN8DD6L1691M2HIQsJtGrU,6582
|
@@ -10,14 +10,14 @@ libentry/schema.py,sha256=BO7EE7i43Cb4xn_OLsBM-HDwWOT6V5fPs91Am3QqnNQ,8178
|
|
10
10
|
libentry/server.py,sha256=gYPoZXd0umlDYZf-6ZV0_vJadg3YQvnLDc6JFDJh9jc,1503
|
11
11
|
libentry/service/__init__.py,sha256=1oLL20yLB1GL9IbFiZD8OReDqiCpFr-yetIR6x1cNkI,23
|
12
12
|
libentry/service/common.py,sha256=OVaW2afgKA6YqstJmtnprBCqQEUZEWotZ6tHavmJJeU,42
|
13
|
-
libentry/service/flask.py,sha256=
|
13
|
+
libentry/service/flask.py,sha256=Alpsix01ROqI28k-dabD8wJlWAWs-ObNc1nJ-LxOXn4,13349
|
14
14
|
libentry/service/list.py,sha256=ElHWhTgShGOhaxMUEwVbMXos0NQKjHsODboiQ-3AMwE,1397
|
15
15
|
libentry/service/running.py,sha256=FrPJoJX6wYxcHIysoatAxhW3LajCCm0Gx6l7__6sULQ,5105
|
16
16
|
libentry/service/start.py,sha256=mZT7b9rVULvzy9GTZwxWnciCHgv9dbGN2JbxM60OMn4,1270
|
17
17
|
libentry/service/stop.py,sha256=wOpwZgrEJ7QirntfvibGq-XsTC6b3ELhzRW2zezh-0s,1187
|
18
|
-
libentry-1.
|
19
|
-
libentry-1.
|
20
|
-
libentry-1.
|
21
|
-
libentry-1.
|
22
|
-
libentry-1.
|
23
|
-
libentry-1.
|
18
|
+
libentry-1.17.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
19
|
+
libentry-1.17.dist-info/METADATA,sha256=6kVrTOffjfB4RzkedsLggG0DVy8la9fIx2c3iP7cuAw,791
|
20
|
+
libentry-1.17.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
21
|
+
libentry-1.17.dist-info/top_level.txt,sha256=u2uF6-X5fn2Erf9PYXOg_6tntPqTpyT-yzUZrltEd6I,9
|
22
|
+
libentry-1.17.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
23
|
+
libentry-1.17.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|