ul-api-utils 9.0.0a1__py3-none-any.whl → 9.0.0a2__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.
Potentially problematic release.
This version of ul-api-utils might be problematic. Click here for more details.
- ul_api_utils/api_resource/db_types.py +1 -1
- ul_api_utils/debug/stat.py +10 -10
- ul_api_utils/internal_api/internal_api.py +4 -5
- ul_api_utils/internal_api/internal_api_check_context.py +9 -9
- ul_api_utils/modules/api_sdk.py +5 -5
- ul_api_utils/utils/cached_per_request.py +3 -3
- {ul_api_utils-9.0.0a1.dist-info → ul_api_utils-9.0.0a2.dist-info}/METADATA +1 -1
- {ul_api_utils-9.0.0a1.dist-info → ul_api_utils-9.0.0a2.dist-info}/RECORD +12 -12
- {ul_api_utils-9.0.0a1.dist-info → ul_api_utils-9.0.0a2.dist-info}/LICENSE +0 -0
- {ul_api_utils-9.0.0a1.dist-info → ul_api_utils-9.0.0a2.dist-info}/WHEEL +0 -0
- {ul_api_utils-9.0.0a1.dist-info → ul_api_utils-9.0.0a2.dist-info}/entry_points.txt +0 -0
- {ul_api_utils-9.0.0a1.dist-info → ul_api_utils-9.0.0a2.dist-info}/top_level.txt +0 -0
|
@@ -2,7 +2,7 @@ from typing import Union, Dict, Any, Tuple, Optional, Iterable
|
|
|
2
2
|
|
|
3
3
|
from pydantic import BaseModel
|
|
4
4
|
from ul_db_utils.model.base_model import BaseModel as DbBaseModel
|
|
5
|
-
from flask_sqlalchemy import Model
|
|
5
|
+
from flask_sqlalchemy.model import Model
|
|
6
6
|
|
|
7
7
|
# TODO: remove DbBaseModel/Model from it BECAUSE IT loads sqlalchemy (>20mb of code)
|
|
8
8
|
TDictable = Union[Dict[str, Any], BaseModel, Tuple[Any, ...], DbBaseModel, Model]
|
ul_api_utils/debug/stat.py
CHANGED
|
@@ -6,7 +6,7 @@ from datetime import datetime
|
|
|
6
6
|
from enum import Enum, unique
|
|
7
7
|
from typing import List, Optional, NamedTuple, Dict, Any, Generator, Tuple
|
|
8
8
|
|
|
9
|
-
from flask import
|
|
9
|
+
from flask import g
|
|
10
10
|
|
|
11
11
|
from ul_api_utils.conf import APPLICATION_DEBUGGER_PIN
|
|
12
12
|
from ul_api_utils.const import REQUEST_HEADER__DEBUGGER
|
|
@@ -22,23 +22,23 @@ def time_now() -> float:
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
def mark_request_started() -> None:
|
|
25
|
-
|
|
25
|
+
g.debug_api_utils_request_started_at = time_now() # type: ignore
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
def get_request_started_at() -> float:
|
|
29
|
-
return getattr(
|
|
29
|
+
return getattr(g, 'debug_api_utils_request_started_at', 0.)
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
def add_request_stat(stat: 'ApiUtilCallStat') -> None:
|
|
33
33
|
try:
|
|
34
|
-
stats =
|
|
34
|
+
stats = g.debug_api_utils_request_stat # type: ignore
|
|
35
35
|
except AttributeError:
|
|
36
|
-
stats =
|
|
36
|
+
stats = g.debug_api_utils_request_stat = [] # type: ignore
|
|
37
37
|
stats.append(stat)
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
def get_request_stat() -> List['ApiUtilCallStat']:
|
|
41
|
-
return getattr(
|
|
41
|
+
return getattr(g, 'debug_api_utils_request_stat', [])
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
@unique
|
|
@@ -151,11 +151,11 @@ class ApiUtilCallStat(NamedTuple):
|
|
|
151
151
|
|
|
152
152
|
|
|
153
153
|
def collecting_enabled() -> bool:
|
|
154
|
-
return getattr(
|
|
154
|
+
return getattr(g, 'debug_api_utils_collect_stat', False)
|
|
155
155
|
|
|
156
156
|
|
|
157
157
|
def collecting_enable(enabled: bool) -> None:
|
|
158
|
-
|
|
158
|
+
g.debug_api_utils_collect_stat = enabled # type: ignore
|
|
159
159
|
|
|
160
160
|
|
|
161
161
|
def get_stats_request_headers() -> Dict[str, str]:
|
|
@@ -204,9 +204,9 @@ def get_stat(*, started_at: float, ended_at: float, code_spans: bool = True, spa
|
|
|
204
204
|
|
|
205
205
|
stats: List[ApiUtilCallStat] = list(get_request_stat())
|
|
206
206
|
|
|
207
|
-
from flask_sqlalchemy import
|
|
207
|
+
from flask_sqlalchemy.record_queries import get_recorded_queries
|
|
208
208
|
|
|
209
|
-
for q in
|
|
209
|
+
for q in get_recorded_queries():
|
|
210
210
|
ok = q.end_time is not None
|
|
211
211
|
|
|
212
212
|
try:
|
|
@@ -4,7 +4,7 @@ from json import dumps
|
|
|
4
4
|
from typing import Optional, Dict, Any, Tuple, Callable
|
|
5
5
|
|
|
6
6
|
import requests
|
|
7
|
-
from flask import
|
|
7
|
+
from flask import g
|
|
8
8
|
from werkzeug.datastructures import FileStorage
|
|
9
9
|
|
|
10
10
|
from ul_api_utils.const import REQUEST_HEADER__INTERNAL, RESPONSE_HEADER__AUTHORIZATION, RESPONSE_HEADER__CONTENT_TYPE, INTERNAL_API__DEFAULT_PATH_PREFIX, REQUEST_HEADER__ACCEPT, \
|
|
@@ -23,13 +23,12 @@ from ul_api_utils.utils.json_encoder import CustomJSONEncoder
|
|
|
23
23
|
|
|
24
24
|
def get_or_create_session(testing_mode: bool) -> requests.Session:
|
|
25
25
|
if testing_mode:
|
|
26
|
-
|
|
27
|
-
return requests.Session()
|
|
26
|
+
return requests.Session()
|
|
28
27
|
|
|
29
28
|
try:
|
|
30
|
-
return
|
|
29
|
+
return g.internal_api_requests_session # type: ignore
|
|
31
30
|
except AttributeError:
|
|
32
|
-
s =
|
|
31
|
+
s = g.internal_api_requests_session = requests.Session() # type: ignore
|
|
33
32
|
return s
|
|
34
33
|
|
|
35
34
|
|
|
@@ -2,7 +2,7 @@ import contextlib
|
|
|
2
2
|
from typing import Generator, Any, TYPE_CHECKING
|
|
3
3
|
from uuid import UUID
|
|
4
4
|
|
|
5
|
-
from flask import
|
|
5
|
+
from flask import g
|
|
6
6
|
|
|
7
7
|
from ul_api_utils.errors import NotCheckedResponseInternalApiError
|
|
8
8
|
|
|
@@ -12,13 +12,13 @@ if TYPE_CHECKING:
|
|
|
12
12
|
|
|
13
13
|
@contextlib.contextmanager
|
|
14
14
|
def internal_api_check_context() -> Generator[None, None, None]:
|
|
15
|
-
|
|
15
|
+
g._api_utils_internal_api_context = [] # type: ignore
|
|
16
16
|
|
|
17
17
|
try:
|
|
18
18
|
yield
|
|
19
19
|
|
|
20
20
|
invalid_resp = []
|
|
21
|
-
for resp in
|
|
21
|
+
for resp in g._api_utils_internal_api_context: # type: ignore
|
|
22
22
|
if not resp._internal_use__checked_once:
|
|
23
23
|
invalid_resp.append(resp)
|
|
24
24
|
|
|
@@ -28,15 +28,15 @@ def internal_api_check_context() -> Generator[None, None, None]:
|
|
|
28
28
|
f'internal api responses must be checked once at least :: [{info}]',
|
|
29
29
|
)
|
|
30
30
|
finally:
|
|
31
|
-
|
|
31
|
+
g._api_utils_internal_api_context.clear() # type: ignore
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
def internal_api_check_context_add_response(resp: 'InternalApiResponse[Any]') -> None:
|
|
35
|
-
if hasattr(
|
|
36
|
-
|
|
35
|
+
if hasattr(g, '_api_utils_internal_api_context'):
|
|
36
|
+
g._api_utils_internal_api_context.append(resp) # type: ignore
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
def internal_api_check_context_rm_response(id: UUID) -> None:
|
|
40
|
-
if hasattr(
|
|
41
|
-
prev =
|
|
42
|
-
|
|
40
|
+
if hasattr(g, '_api_utils_internal_api_context'):
|
|
41
|
+
prev = g._api_utils_internal_api_context # type: ignore
|
|
42
|
+
g._api_utils_internal_api_context = [r for r in prev if r.id != id] # type: ignore
|
ul_api_utils/modules/api_sdk.py
CHANGED
|
@@ -8,7 +8,7 @@ from base64 import b64decode
|
|
|
8
8
|
from datetime import datetime
|
|
9
9
|
from functools import wraps
|
|
10
10
|
from typing import List, Union, Callable, Tuple, Any, Optional, TypeVar, cast, Set, TYPE_CHECKING
|
|
11
|
-
from flask import Response, request, Flask, url_for as flask_url_for,
|
|
11
|
+
from flask import Response, request, Flask, url_for as flask_url_for, g
|
|
12
12
|
from pydantic import BaseModel
|
|
13
13
|
from redis.connection import parse_url
|
|
14
14
|
from ul_py_tool.utils.arg_files_glob import arg_files_print
|
|
@@ -63,15 +63,15 @@ logger = logging.getLogger(__name__)
|
|
|
63
63
|
|
|
64
64
|
|
|
65
65
|
def add_files_to_clean(files: Set[str]) -> None:
|
|
66
|
-
if hasattr(
|
|
66
|
+
if hasattr(g, '_api_utils_files_to_clean'):
|
|
67
67
|
for f in files:
|
|
68
|
-
|
|
68
|
+
g._api_utils_files_to_clean.add(f) # type: ignore
|
|
69
69
|
else:
|
|
70
|
-
|
|
70
|
+
g._api_utils_files_to_clean = files # type: ignore
|
|
71
71
|
|
|
72
72
|
|
|
73
73
|
def clean_files() -> None:
|
|
74
|
-
files: Set[str] = getattr(
|
|
74
|
+
files: Set[str] = getattr(g, '_api_utils_files_to_clean', set())
|
|
75
75
|
for f in files:
|
|
76
76
|
try:
|
|
77
77
|
os.unlink(f)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import functools
|
|
2
2
|
from typing import Callable, TypeVar, Any
|
|
3
3
|
|
|
4
|
-
from flask import
|
|
4
|
+
from flask import g
|
|
5
5
|
|
|
6
6
|
TFn = TypeVar("TFn", bound=Callable[..., Any])
|
|
7
7
|
|
|
@@ -13,11 +13,11 @@ def cached_per_request(key: str) -> Callable[[TFn], TFn]:
|
|
|
13
13
|
def wrapper(fn: Callable[[...], Any]) -> Any: # type: ignore
|
|
14
14
|
@functools.wraps(fn)
|
|
15
15
|
def wr(*args: Any, **kwargs: Any) -> Any:
|
|
16
|
-
cached_res = getattr(
|
|
16
|
+
cached_res = getattr(g, key, DEFAULT_OBJ)
|
|
17
17
|
if cached_res is not DEFAULT_OBJ:
|
|
18
18
|
return cached_res
|
|
19
19
|
res = fn(*args, **kwargs)
|
|
20
|
-
setattr(
|
|
20
|
+
setattr(g, key, res)
|
|
21
21
|
return res
|
|
22
22
|
return wr
|
|
23
23
|
return wrapper
|
|
@@ -34,7 +34,7 @@ ul_api_utils/api_resource/api_resource_type.py,sha256=mgjSQI3swGpgpLI6y35LYtFrdN
|
|
|
34
34
|
ul_api_utils/api_resource/api_response.py,sha256=bfnWo5GZUCzwJm8rDfzcpuYL4l63pBedJ0tTguP--qw,10069
|
|
35
35
|
ul_api_utils/api_resource/api_response_db.py,sha256=ucY6ANPlHZml7JAbvq-PL85z0bvERTjEJKvz-REPyok,888
|
|
36
36
|
ul_api_utils/api_resource/api_response_payload_alias.py,sha256=FoD0LhQGZ2T8A5-VKRX5ADyzSgm7_dd3qxU2BgCVXkA,587
|
|
37
|
-
ul_api_utils/api_resource/db_types.py,sha256=
|
|
37
|
+
ul_api_utils/api_resource/db_types.py,sha256=NxHBYetUogWZow7Vhd3e00Y3L62-dxjwRzJlXywYlV4,439
|
|
38
38
|
ul_api_utils/api_resource/signature_check.py,sha256=jahhr7ttYEUKen_Wp2Eh1__oxqu7ZDoYgw0diK9CFzc,1266
|
|
39
39
|
ul_api_utils/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
40
40
|
ul_api_utils/commands/cmd_enc_keys.py,sha256=HvwihTrLMqhQO_nYA8U0oowqrTKsmUGzseRofuSCO9k,8488
|
|
@@ -52,20 +52,20 @@ ul_api_utils/conf/ul-debugger-ui.js,sha256=bNwv6ntu8RjCrH33H5eTUtFXdBoMrgFt3P87u
|
|
|
52
52
|
ul_api_utils/debug/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
53
53
|
ul_api_utils/debug/debugger.py,sha256=eBsYJjBjvUT2yfr8YuJSNSOETVlbz8jAvTPvIKTUvoY,3716
|
|
54
54
|
ul_api_utils/debug/malloc.py,sha256=OvESxpn8sQMyAb64DxnYUAofRZdnJ1I199IUBWiIoa4,3274
|
|
55
|
-
ul_api_utils/debug/stat.py,sha256=
|
|
55
|
+
ul_api_utils/debug/stat.py,sha256=LNWhp1tGtLV8u-qmfa3Du_eFaedTB166w7gOhCzdzzQ,14480
|
|
56
56
|
ul_api_utils/encrypt/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
57
57
|
ul_api_utils/encrypt/encrypt_decrypt_abstract.py,sha256=V2lFKoBxUKO5AYvHWLYv-rTvYXiGDPj3nOkU1noebDI,334
|
|
58
58
|
ul_api_utils/encrypt/encrypt_decrypt_aes_xtea.py,sha256=Gj-X_CoYY2PPrczTcG9Ho_dgordsh9jKB_cVnVEE3XU,2356
|
|
59
59
|
ul_api_utils/internal_api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
60
|
-
ul_api_utils/internal_api/internal_api.py,sha256=
|
|
61
|
-
ul_api_utils/internal_api/internal_api_check_context.py,sha256=
|
|
60
|
+
ul_api_utils/internal_api/internal_api.py,sha256=0ye53z06naptIN2P3TKDc6fSGVrxyEZNelnED39hr2U,13959
|
|
61
|
+
ul_api_utils/internal_api/internal_api_check_context.py,sha256=OEDkI06wArjBNSjRSzARvEIPDhTzmfvYThgpvFJgUZU,1490
|
|
62
62
|
ul_api_utils/internal_api/internal_api_error.py,sha256=sdm3V2VLSfFVBmxaeo2Wy2wkhmxWTXGsCCR-u08ChMg,471
|
|
63
63
|
ul_api_utils/internal_api/internal_api_response.py,sha256=rNAqY82ezupcRSnWY1YO2T5QhwfOFrak0dp23shgUxY,11583
|
|
64
64
|
ul_api_utils/internal_api/__tests__/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
65
65
|
ul_api_utils/internal_api/__tests__/internal_api.py,sha256=X2iopeso6vryszeeA__lcqXQVtz3Nwt3ngH7M4OuN1U,1116
|
|
66
66
|
ul_api_utils/internal_api/__tests__/internal_api_content_type.py,sha256=mfiYPkzKtfZKFpi4RSnWAoCd6mRijr6sFsa2TF-s5t8,749
|
|
67
67
|
ul_api_utils/modules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
68
|
-
ul_api_utils/modules/api_sdk.py,sha256=
|
|
68
|
+
ul_api_utils/modules/api_sdk.py,sha256=0fA26r7165BN4kYtLoCLcBZC7xyt2gvoDKVcf7OQ-ho,26425
|
|
69
69
|
ul_api_utils/modules/api_sdk_config.py,sha256=ZUR48tIJeFlPJTSjyXzKfXaCKPtfqeaA0mlLX42SSFY,2137
|
|
70
70
|
ul_api_utils/modules/api_sdk_jwt.py,sha256=2XRfb0LxHUnldSL67S60v1uyoDpVPNaq4zofUtkeg88,15112
|
|
71
71
|
ul_api_utils/modules/intermediate_state.py,sha256=7ZZ3Sypbb8LaSfrVhaXaWRDnj8oyy26NUbmFK7vr-y4,1270
|
|
@@ -103,7 +103,7 @@ ul_api_utils/utils/api_path_version.py,sha256=gOwe0bcKs9ovwgh0XsSzih5rq5coL9rNZy
|
|
|
103
103
|
ul_api_utils/utils/api_request_info.py,sha256=vxfqs_6-HSd-0o_k8e9KFKWhLNXL0KUHvGB0_9g9bgE,100
|
|
104
104
|
ul_api_utils/utils/avro.py,sha256=-o1NEgn_hcae1C03Lq3q79bjeQn0OPf_HjI33D10DqI,5021
|
|
105
105
|
ul_api_utils/utils/broker_topics_message_count.py,sha256=CzTL8hZ4hS1TW-aboWLISd8HRCFO4-ha25XtHVXHYxA,1562
|
|
106
|
-
ul_api_utils/utils/cached_per_request.py,sha256=
|
|
106
|
+
ul_api_utils/utils/cached_per_request.py,sha256=8WSOOO0Ih4kj1NB3g_N9aZKvhuPhayNrPCZjRjE03v4,623
|
|
107
107
|
ul_api_utils/utils/colors.py,sha256=NbNlA5jBYvET9OMJgW0HdssrZN9l3sCA1pr-etBVzEU,732
|
|
108
108
|
ul_api_utils/utils/constants.py,sha256=Qx57-WOPlCnQn9KxinVLp2zGjyeyVYuHrAu99Ramn8o,219
|
|
109
109
|
ul_api_utils/utils/decode_base64.py,sha256=rqiD5Whzm2MPx-bk_4r4G4Pe4UUFyU_u-UAjZcXIIjU,398
|
|
@@ -148,9 +148,9 @@ ul_api_utils/validators/validate_empty_object.py,sha256=3Ck_iwyJE_M5e7l6s1i88aqb
|
|
|
148
148
|
ul_api_utils/validators/validate_uuid.py,sha256=EfvlRirv2EW0Z6w3s8E8rUa9GaI8qXZkBWhnPs8NFrA,257
|
|
149
149
|
ul_api_utils/validators/__tests__/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
150
150
|
ul_api_utils/validators/__tests__/test_custom_fields.py,sha256=20gLlnm1Ithsbbz3NIUXVAd92lW6YwVRSg_nETZhfaI,1442
|
|
151
|
-
ul_api_utils-9.0.
|
|
152
|
-
ul_api_utils-9.0.
|
|
153
|
-
ul_api_utils-9.0.
|
|
154
|
-
ul_api_utils-9.0.
|
|
155
|
-
ul_api_utils-9.0.
|
|
156
|
-
ul_api_utils-9.0.
|
|
151
|
+
ul_api_utils-9.0.0a2.dist-info/LICENSE,sha256=6Qo8OdcqI8aGrswJKJYhST-bYqxVQBQ3ujKdTSdq-80,1062
|
|
152
|
+
ul_api_utils-9.0.0a2.dist-info/METADATA,sha256=0dKlK__iEBPXqpkoGQI3TMWA4DLK_vCWs8P13qCwalc,14714
|
|
153
|
+
ul_api_utils-9.0.0a2.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
|
|
154
|
+
ul_api_utils-9.0.0a2.dist-info/entry_points.txt,sha256=8tL3ySHWTyJMuV1hx1fHfN8zumDVOCOm63w3StphkXg,53
|
|
155
|
+
ul_api_utils-9.0.0a2.dist-info/top_level.txt,sha256=1XsW8iOSFaH4LOzDcnNyxHpHrbKU3fSn-aIAxe04jmw,21
|
|
156
|
+
ul_api_utils-9.0.0a2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|