sapiopycommons 2025.10.16a785__py3-none-any.whl → 2025.10.20a789__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 sapiopycommons might be problematic. Click here for more details.
- sapiopycommons/ai/request_validation.py +37 -29
- {sapiopycommons-2025.10.16a785.dist-info → sapiopycommons-2025.10.20a789.dist-info}/METADATA +1 -1
- {sapiopycommons-2025.10.16a785.dist-info → sapiopycommons-2025.10.20a789.dist-info}/RECORD +5 -5
- {sapiopycommons-2025.10.16a785.dist-info → sapiopycommons-2025.10.20a789.dist-info}/WHEEL +0 -0
- {sapiopycommons-2025.10.16a785.dist-info → sapiopycommons-2025.10.20a789.dist-info}/licenses/LICENSE +0 -0
|
@@ -34,20 +34,19 @@ class BinaryValidation(InputValidation):
|
|
|
34
34
|
"""
|
|
35
35
|
A class representing a validation requirement for a binary input.
|
|
36
36
|
"""
|
|
37
|
-
func: Callable[[
|
|
37
|
+
func: Callable[[bytes], list[str]] | None
|
|
38
38
|
|
|
39
39
|
def __init__(self, index: int, max_entries: int | None = None,
|
|
40
40
|
allow_empty_input: bool = False, allow_empty_entries: bool = False,
|
|
41
|
-
func: Callable[[
|
|
41
|
+
func: Callable[[bytes], list[str]] | None = None):
|
|
42
42
|
"""
|
|
43
43
|
:param index: The index of the input to validate.
|
|
44
44
|
:param max_entries: The maximum number of entries allowed for this input. If None, then there is no limit.
|
|
45
45
|
:param allow_empty_input: If true, then the input can be completely empty.
|
|
46
46
|
:param allow_empty_entries: If true, then individual entries in the input can be empty
|
|
47
|
-
:param func: An optional function to run on each entry in the input. The function should take the
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
entry are empty.
|
|
47
|
+
:param func: An optional function to run on each entry in the input. The function should take the entry as an
|
|
48
|
+
argument, and return a list of error messages if the entry is not valid. If the entry is valid, the function
|
|
49
|
+
should return an empty list. This function will not be called if the input or entry are empty.
|
|
51
50
|
"""
|
|
52
51
|
super().__init__(index, max_entries, allow_empty_input, allow_empty_entries)
|
|
53
52
|
self.func = func
|
|
@@ -59,12 +58,12 @@ class CsvValidation(InputValidation):
|
|
|
59
58
|
"""
|
|
60
59
|
required_headers: list[str] | None = None
|
|
61
60
|
|
|
62
|
-
func: Callable[[
|
|
61
|
+
func: Callable[[dict[str, Any]], list[str]] | None
|
|
63
62
|
|
|
64
63
|
def __init__(self, index: int, max_entries: int | None = None,
|
|
65
64
|
allow_empty_input: bool = False, allow_empty_entries: bool = False,
|
|
66
65
|
required_headers: list[str] | None = None,
|
|
67
|
-
func: Callable[[
|
|
66
|
+
func: Callable[[dict[str, Any]], list[str]] | None = None):
|
|
68
67
|
"""
|
|
69
68
|
:param index: The index of the input to validate.
|
|
70
69
|
:param max_entries: The maximum number of entries allowed for this input. If None, then there is no limit.
|
|
@@ -72,10 +71,9 @@ class CsvValidation(InputValidation):
|
|
|
72
71
|
:param allow_empty_entries: If true, then individual entries in the input can be empty.
|
|
73
72
|
:param required_headers: A list of headers that must be present in the CSV input. If None, then no header
|
|
74
73
|
validation will be performed.
|
|
75
|
-
:param func: An optional function to run on each entry in the input. The function should take the
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
entry are empty.
|
|
74
|
+
:param func: An optional function to run on each entry in the input. The function should take the entry as an
|
|
75
|
+
argument, and return a list of error messages if the entry is not valid. If the entry is valid, the function
|
|
76
|
+
should return an empty list. This function will not be called if the input or entry are empty.
|
|
79
77
|
"""
|
|
80
78
|
super().__init__(index, max_entries, allow_empty_input, allow_empty_entries)
|
|
81
79
|
self.required_headers = required_headers
|
|
@@ -88,12 +86,12 @@ class JsonValidation(InputValidation):
|
|
|
88
86
|
"""
|
|
89
87
|
json_requirements: dict[str, JsonKeyValidation]
|
|
90
88
|
|
|
91
|
-
func: Callable[[
|
|
89
|
+
func: Callable[[dict[str, Any]], list[str]] | None
|
|
92
90
|
|
|
93
91
|
def __init__(self, index: int, max_entries: int | None = None,
|
|
94
92
|
allow_empty_input: bool = False, allow_empty_entries: bool = False,
|
|
95
93
|
json_requirements: list[JsonKeyValidation] | None = None,
|
|
96
|
-
func: Callable[[
|
|
94
|
+
func: Callable[[dict[str, Any]], list[str]] | None = None):
|
|
97
95
|
"""
|
|
98
96
|
:param index: The index of the input to validate.
|
|
99
97
|
:param max_entries: The maximum number of entries allowed for this input. If None, then there is no limit.
|
|
@@ -102,10 +100,9 @@ class JsonValidation(InputValidation):
|
|
|
102
100
|
:param json_requirements: A list of JSON requirements to validate for JSON inputs. Each requirement
|
|
103
101
|
specifies a key to validate, the expected type of the value for that key, and any nested requirements
|
|
104
102
|
for that key. Only applicable to JSON inputs.
|
|
105
|
-
:param func: An optional function to run on each entry in the input. The function should take the
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
entry are empty.
|
|
103
|
+
:param func: An optional function to run on each entry in the input. The function should take the entry as an
|
|
104
|
+
argument, and return a list of error messages if the entry is not valid. If the entry is valid, the function
|
|
105
|
+
should return an empty list. This function will not be called if the input or entry are empty.
|
|
109
106
|
"""
|
|
110
107
|
super().__init__(index, max_entries, allow_empty_input, allow_empty_entries)
|
|
111
108
|
self.json_requirements = {}
|
|
@@ -185,12 +182,12 @@ class TextValidation(InputValidation):
|
|
|
185
182
|
disallowed_characters: str | None = None
|
|
186
183
|
regex: str | None = None
|
|
187
184
|
|
|
188
|
-
func: Callable[[
|
|
185
|
+
func: Callable[[str], list[str]] | None = None
|
|
189
186
|
|
|
190
187
|
def __init__(self, index: int, max_entries: int | None = None,
|
|
191
188
|
allow_empty_input: bool = False, allow_empty_entries: bool = False, flatten: bool = False,
|
|
192
189
|
disallow_characters: str | None = None, regex: str | None = None,
|
|
193
|
-
func: Callable[[
|
|
190
|
+
func: Callable[[str], list[str]] | None = None):
|
|
194
191
|
"""
|
|
195
192
|
:param index: The index of the input to validate.
|
|
196
193
|
:param max_entries: The maximum number of entries allowed for this input. If None, then there is no limit.
|
|
@@ -202,11 +199,10 @@ class TextValidation(InputValidation):
|
|
|
202
199
|
empty.
|
|
203
200
|
:param regex: An optional regular expression that each entry in the input must fully match. If None, then no
|
|
204
201
|
regex validation will be performed. This parameter will not be used if the input or entry are empty.
|
|
205
|
-
:param func: An optional function to run on each entry in the input. The function should take the
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
passes the regex, etc.).
|
|
202
|
+
:param func: An optional function to run on each entry in the input. The function should take the entry as an
|
|
203
|
+
arguments, and return a list of error messages if the entry is not valid. If the entry is valid, the
|
|
204
|
+
function should return an empty list. The function will only be called if the entry passes those previous
|
|
205
|
+
checks (e.g. not empty, doesn't include disallowed characters, passes the regex, etc.).
|
|
210
206
|
"""
|
|
211
207
|
super().__init__(index, max_entries, allow_empty_input, allow_empty_entries)
|
|
212
208
|
self.flatten = flatten
|
|
@@ -302,7 +298,10 @@ class InputValidator:
|
|
|
302
298
|
if not r.allow_empty_entries:
|
|
303
299
|
errors.append(f"Entry {i} of input {index} is empty or contains only whitespace.")
|
|
304
300
|
elif r.func:
|
|
305
|
-
|
|
301
|
+
func_errors: list[str] = r.func(entry)
|
|
302
|
+
if func_errors:
|
|
303
|
+
for error in func_errors:
|
|
304
|
+
errors.append(f"Error in entry {i} of input {index}: {error}")
|
|
306
305
|
return errors
|
|
307
306
|
|
|
308
307
|
def validate_input_csv(self, index: int, r: CsvValidation) -> list[str]:
|
|
@@ -335,7 +334,10 @@ class InputValidator:
|
|
|
335
334
|
if not r.allow_empty_entries:
|
|
336
335
|
errors.append(f"Entry {i} of input {index} is empty or contains only whitespace.")
|
|
337
336
|
elif r.func:
|
|
338
|
-
|
|
337
|
+
func_errors: list[str] = r.func(entry)
|
|
338
|
+
if func_errors:
|
|
339
|
+
for error in func_errors:
|
|
340
|
+
errors.append(f"Error in entry {i} of input {index}: {error}")
|
|
339
341
|
return errors
|
|
340
342
|
|
|
341
343
|
def validate_input_json(self, index: int, r: JsonValidation) -> list[str]:
|
|
@@ -360,7 +362,10 @@ class InputValidator:
|
|
|
360
362
|
if not r.allow_empty_entries:
|
|
361
363
|
errors.append(f"Entry {i} of input {index} is empty.")
|
|
362
364
|
elif r.func:
|
|
363
|
-
|
|
365
|
+
func_errors: list[str] = r.func(entry)
|
|
366
|
+
if func_errors:
|
|
367
|
+
for error in func_errors:
|
|
368
|
+
errors.append(f"Error in entry {i} of input {index}: {error}")
|
|
364
369
|
|
|
365
370
|
for key, rk in r.json_requirements.items():
|
|
366
371
|
for i, entry in enumerate(input_json):
|
|
@@ -462,7 +467,10 @@ class InputValidator:
|
|
|
462
467
|
errors.append(f"Entry {i} of input {index} does not fully match the expected regex format "
|
|
463
468
|
f"{r.regex}.")
|
|
464
469
|
elif r.func:
|
|
465
|
-
|
|
470
|
+
func_errors: list[str] = r.func(entry)
|
|
471
|
+
if func_errors:
|
|
472
|
+
for error in func_errors:
|
|
473
|
+
errors.append(f"Error in entry {i} of input {index}: {error}")
|
|
466
474
|
if errors and r.flatten:
|
|
467
475
|
errors.append(f"Note that input flattening is enabled for input {index}, which may increase the number "
|
|
468
476
|
f"of entries reported in the above errors. Flattening splits each entry on newlines, removes "
|
{sapiopycommons-2025.10.16a785.dist-info → sapiopycommons-2025.10.20a789.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: sapiopycommons
|
|
3
|
-
Version: 2025.10.
|
|
3
|
+
Version: 2025.10.20a789
|
|
4
4
|
Summary: Official Sapio Python API Utilities Package
|
|
5
5
|
Project-URL: Homepage, https://github.com/sapiosciences
|
|
6
6
|
Author-email: Jonathan Steck <jsteck@sapiosciences.com>, Yechen Qiao <yqiao@sapiosciences.com>
|
|
@@ -4,7 +4,7 @@ sapiopycommons/ai/agent_service_base.py,sha256=eTJunFQoxLc0risWiQIkQK946XpHzSFO3
|
|
|
4
4
|
sapiopycommons/ai/converter_service_base.py,sha256=HiUXmwqv1STgyQeF9_eTFXzjIFXp5-NJ7sEhMpV3aAU,6351
|
|
5
5
|
sapiopycommons/ai/external_credentials.py,sha256=ki_xIH4J843b_sSwEa8YHr8vW9erVv-jowZJXSgPQs8,4347
|
|
6
6
|
sapiopycommons/ai/protobuf_utils.py,sha256=cBjbxoFAwU02kNUxEce95WnMU2CMuDD-qFaeWgvQJMQ,24599
|
|
7
|
-
sapiopycommons/ai/request_validation.py,sha256=
|
|
7
|
+
sapiopycommons/ai/request_validation.py,sha256=dsCZXWDSHLm7pGywArB_GRymXxo1l-eGMn6veUwSg20,25641
|
|
8
8
|
sapiopycommons/ai/server.py,sha256=gutSskn_Fenq1uz0DDMvjx4QVFiKt2WVEP3-01a69eU,6384
|
|
9
9
|
sapiopycommons/ai/test_client.py,sha256=IRZ-8prhg7XMDmN9aC1MQr5mSkMgfT37aLsOy-VB-MU,20495
|
|
10
10
|
sapiopycommons/ai/protoapi/externalcredentials/external_credentials_pb2.py,sha256=mEonoj6Iq-AyvO4m3YsPYu85aZfD1E0a0cL8B9yPfEo,2481
|
|
@@ -106,7 +106,7 @@ sapiopycommons/webhook/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3
|
|
|
106
106
|
sapiopycommons/webhook/webhook_context.py,sha256=D793uLsb1691SalaPnBUk3rOSxn_hYLhdvkaIxjNXss,1909
|
|
107
107
|
sapiopycommons/webhook/webhook_handlers.py,sha256=7o_wXOruhT9auNh8OfhJAh4WhhiPKij67FMBSpGPICc,39939
|
|
108
108
|
sapiopycommons/webhook/webservice_handlers.py,sha256=cvW6Mk_110BzYqkbk63Kg7jWrltBCDALOlkJRu8h4VQ,14300
|
|
109
|
-
sapiopycommons-2025.10.
|
|
110
|
-
sapiopycommons-2025.10.
|
|
111
|
-
sapiopycommons-2025.10.
|
|
112
|
-
sapiopycommons-2025.10.
|
|
109
|
+
sapiopycommons-2025.10.20a789.dist-info/METADATA,sha256=LW1ECHFl-cG6BPslNdeFfIGKFHCxPgtivYUg9mqsnSQ,3143
|
|
110
|
+
sapiopycommons-2025.10.20a789.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
|
111
|
+
sapiopycommons-2025.10.20a789.dist-info/licenses/LICENSE,sha256=HyVuytGSiAUQ6ErWBHTqt1iSGHhLmlC8fO7jTCuR8dU,16725
|
|
112
|
+
sapiopycommons-2025.10.20a789.dist-info/RECORD,,
|
|
File without changes
|
{sapiopycommons-2025.10.16a785.dist-info → sapiopycommons-2025.10.20a789.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|