ul-api-utils 8.1.3__py3-none-any.whl → 8.1.4__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.

example/workers/worker.py CHANGED
@@ -1,6 +1,6 @@
1
- from unipipeline.message.uni_message import UniMessage
2
- from unipipeline.worker.uni_worker import UniWorker
3
- from unipipeline.worker.uni_worker_consumer_message import UniWorkerConsumerMessage
1
+ from ul_unipipeline.message.uni_message import UniMessage
2
+ from ul_unipipeline.worker.uni_worker import UniWorker
3
+ from ul_unipipeline.worker.uni_worker_consumer_message import UniWorkerConsumerMessage
4
4
 
5
5
  from ul_api_utils.modules.worker_context import WorkerContext
6
6
  from ul_api_utils.modules.worker_sdk import WorkerSdk
@@ -4,9 +4,9 @@ from datetime import datetime
4
4
  from typing import TypeVar, Callable, Any, Union, Dict, Optional, Tuple, TYPE_CHECKING
5
5
 
6
6
  from flask import Flask
7
- from unipipeline.message.uni_message import UniMessage
8
- from unipipeline.worker.uni_worker import UniWorker
9
- from unipipeline.worker.uni_worker_consumer_message import UniWorkerConsumerMessage
7
+ from ul_unipipeline.message.uni_message import UniMessage
8
+ from ul_unipipeline.worker.uni_worker import UniWorker
9
+ from ul_unipipeline.worker.uni_worker_consumer_message import UniWorkerConsumerMessage
10
10
 
11
11
  from ul_api_utils.conf import APPLICATION_START_DT
12
12
  from ul_api_utils.modules.intermediate_state import try_init, try_configure
@@ -4,8 +4,8 @@ from typing import List, Callable, Any, Optional, Dict, TYPE_CHECKING, Tuple, Na
4
4
 
5
5
  from pydantic import model_validator, ConfigDict, Field, BaseModel, PositiveInt, TypeAdapter
6
6
  from sqlalchemy.sql import text
7
- from unipipeline.errors import UniError
8
- from unipipeline.modules.uni import Uni
7
+ from ul_unipipeline.errors import UniError
8
+ from ul_unipipeline.modules.uni import Uni
9
9
 
10
10
  from ul_api_utils.api_resource.api_response import JsonApiResponsePayload
11
11
  from ul_api_utils.errors import Client4XXInternalApiError, Server5XXInternalApiError
@@ -1,7 +1,7 @@
1
1
  from typing import NamedTuple, List, Optional
2
2
 
3
- from unipipeline.errors import UniError
4
- from unipipeline.modules.uni import Uni
3
+ from ul_unipipeline.errors import UniError
4
+ from ul_unipipeline.modules.uni import Uni
5
5
 
6
6
 
7
7
  class DataStreamStats(NamedTuple):
@@ -1,12 +1,16 @@
1
1
  import csv
2
- from typing import TypeVar, Generic, List, Union, Generator, Callable, Annotated, Any
2
+ from typing import TypeVar, Generic, List, Union, Generator, Callable, Annotated, Any, get_args
3
+ from uuid import UUID
3
4
 
4
- from pydantic import ValidationError, Field, StringConstraints
5
- from pydantic.v1.fields import ModelField
5
+ from pydantic import ValidationError, Field, StringConstraints, TypeAdapter
6
+ from pydantic_core.core_schema import ValidationInfo
6
7
 
7
8
  from ul_api_utils.const import CRON_EXPRESSION_VALIDATION_REGEX, MIN_UTC_OFFSET_SECONDS, MAX_UTC_OFFSET_SECONDS
8
9
 
9
10
  NotEmptyListAnnotation = Annotated[list[Any], Field(min_length=1)]
11
+ NotEmptyListStrAnnotation = Annotated[list[str], Field(min_length=1)]
12
+ NotEmptyListIntAnnotation = Annotated[list[int], Field(min_length=1)]
13
+ NotEmptyListUUIDAnnotation = Annotated[list[UUID], Field(min_length=1)]
10
14
  CronScheduleAnnotation = Annotated[str, StringConstraints(pattern=CRON_EXPRESSION_VALIDATION_REGEX)]
11
15
  WhiteSpaceStrippedStrAnnotation = Annotated[str, StringConstraints(strip_whitespace=True)]
12
16
  UTCOffsetSecondsAnnotation = Annotated[int, Field(ge=MIN_UTC_OFFSET_SECONDS, le=MAX_UTC_OFFSET_SECONDS)]
@@ -42,24 +46,31 @@ class QueryParamsSeparatedList(Generic[QueryParamsSeparatedListValueType]):
42
46
  return f'QueryParamsSeparatedList({super().__repr__()})'
43
47
 
44
48
  @classmethod
45
- def __get_validators__(cls) -> Generator[Callable[[Union[List[str], str], ModelField], Union[List[QueryParamsSeparatedListValueType], List[str]]], None, None]:
49
+ def __get_validators__(cls) -> Generator[Callable[[Union[List[str], str], ValidationInfo], List[QueryParamsSeparatedListValueType]], None, None]:
46
50
  yield cls.validate
47
51
 
48
52
  @classmethod
49
- def validate(cls, query_param: Union[List[str], str], field: ModelField) -> Union[List[QueryParamsSeparatedListValueType], List[str]]:
50
- if not isinstance(query_param, List):
53
+ def validate(cls, query_param: Union[List[str], str], info: ValidationInfo) -> List[QueryParamsSeparatedListValueType]:
54
+ """
55
+ Validate and convert the query parameter string into a list of the specified type.
56
+ """
57
+ if not isinstance(query_param, list):
51
58
  query_param = [query_param]
59
+
52
60
  reader = csv.reader(query_param, skipinitialspace=True)
53
61
  splitted = next(reader)
54
- if not field.sub_fields:
55
- return splitted
56
- list_item = field.sub_fields[0] # retrieving info about data type of the list
62
+
63
+ adapter = TypeAdapter(get_args(cls)[0])
64
+
65
+ validated_items = []
57
66
  errors = []
67
+
58
68
  for value in splitted:
59
- validated_list_item, error = list_item.validate(value, {}, loc="separated query param")
60
- if error:
61
- errors.append(error)
69
+ try:
70
+ validated_items.append(adapter.validate_python(value))
71
+ except ValidationError as e:
72
+ errors.append(e)
62
73
  if errors:
63
- raise ValidationError(errors, cls)
64
- # Validation passed without errors, modify string to a list and cast the right type for every element
65
- return [list_item.type_(value) for value in splitted]
74
+ raise ValidationError(errors)
75
+
76
+ return validated_items
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ul-api-utils
3
- Version: 8.1.3
3
+ Version: 8.1.4
4
4
  Summary: Python api utils
5
5
  Author: Unic-lab
6
6
  Author-email:
@@ -16,7 +16,7 @@ Classifier: Programming Language :: Python :: 3.9
16
16
  Classifier: Operating System :: OS Independent
17
17
  Description-Content-Type: text/markdown
18
18
  License-File: LICENSE
19
- Requires-Dist: ul-unipipeline (>=2.0.0)
19
+ Requires-Dist: ul-unipipeline (==2.0.5)
20
20
  Requires-Dist: jinja2 (==3.1.2)
21
21
  Requires-Dist: flask (==2.1.3)
22
22
  Requires-Dist: flask-wtf (==1.0.1)
@@ -15,7 +15,7 @@ example/sockets/on_json.py,sha256=sTh0Pqu5iITmnRRjc6-rns1VFlEN_xo33_4lUF5VzNk,20
15
15
  example/sockets/on_message.py,sha256=6jmiW4qy9Zs6T9CRTCZrBGCBTuK1xUtsYWJ9zozl8XI,234
16
16
  example/sockets/on_open.py,sha256=1xfgVqoTuOPxHyBC_rFuj60096gjgbg6rNfCvUqUN8A,405
17
17
  example/workers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
- example/workers/worker.py,sha256=Bb0JZPWJ8X51iCo6tlQ3umpqjS1kL3oy-FW9MtWH7aA,969
18
+ example/workers/worker.py,sha256=Y3z485VPQ7Ot_yFsK6cD4muB_HBzGUO3tf2id-dDRdA,978
19
19
  ul_api_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  ul_api_utils/conf.py,sha256=zLWsA0TTmekzxYrs5PbeqEkeylaNC_gIui3CGM9aZew,3487
21
21
  ul_api_utils/const.py,sha256=pzY-zRznCJjZ0mFlte6XEsQQCU7EydN2WweEsVHSE7k,2563
@@ -70,7 +70,7 @@ ul_api_utils/modules/api_sdk_config.py,sha256=ZUR48tIJeFlPJTSjyXzKfXaCKPtfqeaA0m
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
72
72
  ul_api_utils/modules/worker_context.py,sha256=jGjopeuYuTtIDmsrqK7TcbTD-E81t8OWvWS1JpTC6b0,802
73
- ul_api_utils/modules/worker_sdk.py,sha256=4jObKYGAvZNrH0HWl3Wi7TXkNtlbC5PjkkrMLwDU17s,5144
73
+ ul_api_utils/modules/worker_sdk.py,sha256=WNJ45LyxeTOJcogcL-t_P7rBVZprJKOmiVEAo-1fU3s,5153
74
74
  ul_api_utils/modules/worker_sdk_config.py,sha256=7y-J1yHtoHQuRZyye--pY85yaJXKL6Vh9hODQHMESyU,308
75
75
  ul_api_utils/modules/__tests__/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
76
76
  ul_api_utils/modules/__tests__/test_api_sdk_jwt.py,sha256=9JJTtva2z4pjvTWQqo_0EOvzf4wBgvq0G77jM0SC3Bg,10719
@@ -84,7 +84,7 @@ ul_api_utils/resources/socketio.py,sha256=oeQdULtBnslyMJkeqfZMWxtK6efLFX1LrfA2cB
84
84
  ul_api_utils/resources/swagger.py,sha256=fK8S9X4YCSqe_weCzV_BcMPoL_NR073BsGUzn2ImbHI,5391
85
85
  ul_api_utils/resources/health_check/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
86
86
  ul_api_utils/resources/health_check/const.py,sha256=QzVZP_ZKmVKleUACiOGjzP-v54FD7tEN6NEF4Jb50Ow,78
87
- ul_api_utils/resources/health_check/health_check.py,sha256=rfbvwfsWaQgj-DP_En_-wPEYZdPq2K4-5wz6rjZG0oU,18478
87
+ ul_api_utils/resources/health_check/health_check.py,sha256=PDE5h6aznw56h0gY50Q7hFhCPsiWnq4Ro1A1G6XUQD4,18484
88
88
  ul_api_utils/resources/health_check/health_check_template.py,sha256=Qih-sVoFVoVxfmDYBTzwlNSicCr7zNelUJLJMnM-C_Q,2572
89
89
  ul_api_utils/resources/health_check/resource.py,sha256=SPd9kMzBOVhFZgMVfV26bDpZya3BmwxTfOR4MZ2dL4o,4199
90
90
  ul_api_utils/resources/web_forms/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -102,7 +102,7 @@ ul_api_utils/utils/api_pagination.py,sha256=dXCrDcZ3dNu3gKP2XExp7EUoOKaOgzO-6JOd
102
102
  ul_api_utils/utils/api_path_version.py,sha256=gOwe0bcKs9ovwgh0XsSzih5rq5coL9rNZy8iyeB-xJc,1965
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
- ul_api_utils/utils/broker_topics_message_count.py,sha256=WC3CLK8mSFsCEFoW4BD2scy30mlSoAr8qnu3vrYJpD4,1556
105
+ ul_api_utils/utils/broker_topics_message_count.py,sha256=CzTL8hZ4hS1TW-aboWLISd8HRCFO4-ha25XtHVXHYxA,1562
106
106
  ul_api_utils/utils/cached_per_request.py,sha256=tOcTs0MJUm597fyKFGcJLaUZGtPKcf8s6XE_t9fSQqs,670
107
107
  ul_api_utils/utils/colors.py,sha256=NbNlA5jBYvET9OMJgW0HdssrZN9l3sCA1pr-etBVzEU,732
108
108
  ul_api_utils/utils/constants.py,sha256=Qx57-WOPlCnQn9KxinVLp2zGjyeyVYuHrAu99Ramn8o,219
@@ -143,14 +143,14 @@ ul_api_utils/utils/memory_db/errors.py,sha256=Bw1O1Y_WTCeCRNgb9iwrGT1fst6iHORhrN
143
143
  ul_api_utils/utils/memory_db/repository.py,sha256=xOnxEJyApGTglqjQ5fPKcEV5rHEkvKwcgrUfW4zJbHg,3754
144
144
  ul_api_utils/utils/memory_db/__tests__/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
145
145
  ul_api_utils/validators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
146
- ul_api_utils/validators/custom_fields.py,sha256=-l5l5GnK9s24CvI5el-T-qDFq-fkiQ7ciebq98nljn0,3180
146
+ ul_api_utils/validators/custom_fields.py,sha256=xsngUv3mjYVc-l54b6gkAfGR0ceI8A1wIvTf1qvELso,3325
147
147
  ul_api_utils/validators/validate_empty_object.py,sha256=3Ck_iwyJE_M5e7l6s1i88aqb73zIt06uaLrMG2PAb0A,299
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=QLZ7DFta01Z7DOK9Z5Iq4uf_CmvDkVReis-GAl_QN48,1447
151
- ul_api_utils-8.1.3.dist-info/LICENSE,sha256=6Qo8OdcqI8aGrswJKJYhST-bYqxVQBQ3ujKdTSdq-80,1062
152
- ul_api_utils-8.1.3.dist-info/METADATA,sha256=mRYlYhMUmR_LNOeYztDK0ge0mEdCA-s1Uu8bFL56yaQ,14747
153
- ul_api_utils-8.1.3.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
154
- ul_api_utils-8.1.3.dist-info/entry_points.txt,sha256=8tL3ySHWTyJMuV1hx1fHfN8zumDVOCOm63w3StphkXg,53
155
- ul_api_utils-8.1.3.dist-info/top_level.txt,sha256=1XsW8iOSFaH4LOzDcnNyxHpHrbKU3fSn-aIAxe04jmw,21
156
- ul_api_utils-8.1.3.dist-info/RECORD,,
151
+ ul_api_utils-8.1.4.dist-info/LICENSE,sha256=6Qo8OdcqI8aGrswJKJYhST-bYqxVQBQ3ujKdTSdq-80,1062
152
+ ul_api_utils-8.1.4.dist-info/METADATA,sha256=sx41EGjC1dKnitnRqQk4UrpfeiNFTCrBszugOPnD_hQ,14747
153
+ ul_api_utils-8.1.4.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
154
+ ul_api_utils-8.1.4.dist-info/entry_points.txt,sha256=8tL3ySHWTyJMuV1hx1fHfN8zumDVOCOm63w3StphkXg,53
155
+ ul_api_utils-8.1.4.dist-info/top_level.txt,sha256=1XsW8iOSFaH4LOzDcnNyxHpHrbKU3fSn-aIAxe04jmw,21
156
+ ul_api_utils-8.1.4.dist-info/RECORD,,