ipulse-shared-core-ftredge 2.57__py3-none-any.whl → 3.2.1__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.
- ipulse_shared_core_ftredge/__init__.py +3 -20
- ipulse_shared_core_ftredge/models/__init__.py +0 -1
- ipulse_shared_core_ftredge/models/organisation.py +61 -55
- ipulse_shared_core_ftredge/models/resource_catalog_item.py +97 -171
- {ipulse_shared_core_ftredge-2.57.dist-info → ipulse_shared_core_ftredge-3.2.1.dist-info}/METADATA +5 -7
- ipulse_shared_core_ftredge-3.2.1.dist-info/RECORD +13 -0
- {ipulse_shared_core_ftredge-2.57.dist-info → ipulse_shared_core_ftredge-3.2.1.dist-info}/WHEEL +1 -1
- ipulse_shared_core_ftredge/enums/__init__.py +0 -29
- ipulse_shared_core_ftredge/enums/enums_common_utils.py +0 -177
- ipulse_shared_core_ftredge/enums/enums_data_eng.py +0 -44
- ipulse_shared_core_ftredge/enums/enums_module_fincore.py +0 -58
- ipulse_shared_core_ftredge/enums/enums_modules.py +0 -33
- ipulse_shared_core_ftredge/models/audit_log_firestore.py +0 -12
- ipulse_shared_core_ftredge/models/pulse_enums.py +0 -196
- ipulse_shared_core_ftredge/utils_custom_logs.py +0 -201
- ipulse_shared_core_ftredge/utils_gcp.py +0 -314
- ipulse_shared_core_ftredge/utils_gcp_for_pipelines.py +0 -201
- ipulse_shared_core_ftredge/utils_pipelinemon.py +0 -362
- ipulse_shared_core_ftredge/utils_templates_and_schemas.py +0 -153
- ipulse_shared_core_ftredge-2.57.dist-info/RECORD +0 -25
- {ipulse_shared_core_ftredge-2.57.dist-info → ipulse_shared_core_ftredge-3.2.1.dist-info}/LICENCE +0 -0
- {ipulse_shared_core_ftredge-2.57.dist-info → ipulse_shared_core_ftredge-3.2.1.dist-info}/top_level.txt +0 -0
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
# pylint: disable=missing-module-docstring
|
|
2
|
-
# pylint: disable=missing-function-docstring
|
|
3
|
-
# pylint: disable=logging-fstring-interpolation
|
|
4
|
-
# pylint: disable=line-too-long
|
|
5
|
-
|
|
6
|
-
import datetime
|
|
7
|
-
from google.cloud import bigquery
|
|
8
|
-
from ipulse_shared_core_ftredge.enums.enums_common_utils import LogLevel
|
|
9
|
-
from ipulse_shared_core_ftredge.utils_custom_logs import ContextLog
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
def create_bigquery_schema_from_json(json_schema):
|
|
13
|
-
schema = []
|
|
14
|
-
for field in json_schema:
|
|
15
|
-
if "max_length" in field:
|
|
16
|
-
schema.append(bigquery.SchemaField(field["name"], field["type"], mode=field["mode"], max_length=field["max_length"]))
|
|
17
|
-
else:
|
|
18
|
-
schema.append(bigquery.SchemaField(field["name"], field["type"], mode=field["mode"]))
|
|
19
|
-
return schema
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
def check_format_against_schema_template(data_to_check, schema, dt_ts_to_str=True, check_max_length=True):
|
|
23
|
-
"""Ensure Update dict corresponds to the config schema, ensuring proper formats and lengths."""
|
|
24
|
-
checked_data = {}
|
|
25
|
-
warnings_or_error = [] # Group warnings and errors for a given run
|
|
26
|
-
|
|
27
|
-
try:
|
|
28
|
-
# Process updates to conform to the schema
|
|
29
|
-
for field in schema:
|
|
30
|
-
field_name = field["name"]
|
|
31
|
-
field_type = field["type"]
|
|
32
|
-
mode = field["mode"]
|
|
33
|
-
|
|
34
|
-
# Initialize notice to None at the start of each field processing
|
|
35
|
-
warning = None
|
|
36
|
-
|
|
37
|
-
if field_name in data_to_check:
|
|
38
|
-
value = data_to_check[field_name]
|
|
39
|
-
|
|
40
|
-
# Handle date and timestamp formatting
|
|
41
|
-
if field_type == "DATE":
|
|
42
|
-
value, warning = handle_date_fields(field_name, value, dt_ts_to_str)
|
|
43
|
-
elif field_type == "TIMESTAMP":
|
|
44
|
-
value, warning = handle_timestamp_fields(field_name, value, dt_ts_to_str)
|
|
45
|
-
elif field_type in ["STRING", "INT64", "FLOAT64", "BOOL"]:
|
|
46
|
-
value, warning = handle_type_conversion(field_type, field_name, value)
|
|
47
|
-
|
|
48
|
-
if warning:
|
|
49
|
-
warnings_or_error.append(warning)
|
|
50
|
-
|
|
51
|
-
# Check and handle max length restriction
|
|
52
|
-
if check_max_length and "max_length" in field:
|
|
53
|
-
value, warning = check_and_truncate_length(field_name, value, field["max_length"])
|
|
54
|
-
if warning:
|
|
55
|
-
warnings_or_error.append(warning)
|
|
56
|
-
|
|
57
|
-
# Only add to the dictionary if value is not None or the field is required
|
|
58
|
-
if value is not None or mode == "REQUIRED":
|
|
59
|
-
checked_data[field_name] = value
|
|
60
|
-
|
|
61
|
-
elif mode == "REQUIRED":
|
|
62
|
-
warnings_or_error.append(ContextLog(level=LogLevel.WARNING,
|
|
63
|
-
subject=field_name,
|
|
64
|
-
description=f"Required field '{field_name}' is missing in the updates."))
|
|
65
|
-
|
|
66
|
-
except Exception as e:
|
|
67
|
-
warnings_or_error.append(ContextLog(level=LogLevel.ERROR_EXCEPTION,
|
|
68
|
-
subject=data_to_check,
|
|
69
|
-
description=f"An error occurred during update check: {str(e)}"))
|
|
70
|
-
|
|
71
|
-
return checked_data, warnings_or_error
|
|
72
|
-
|
|
73
|
-
def handle_date_fields(field_name, value, dt_ts_to_str):
|
|
74
|
-
"""Handles date fields, ensuring they are in the correct format and optionally converts them to string."""
|
|
75
|
-
if isinstance(value, datetime.date):
|
|
76
|
-
if dt_ts_to_str:
|
|
77
|
-
return value.strftime("%Y-%m-%d"), None
|
|
78
|
-
return value, None
|
|
79
|
-
elif isinstance(value, str):
|
|
80
|
-
try:
|
|
81
|
-
parsed_date = datetime.datetime.strptime(value, "%Y-%m-%d").date()
|
|
82
|
-
if dt_ts_to_str:
|
|
83
|
-
return value, None
|
|
84
|
-
return parsed_date, None
|
|
85
|
-
except ValueError:
|
|
86
|
-
return None, ContextLog(level=LogLevel.WARNING_FIX_REQUIRED,
|
|
87
|
-
subject=field_name,
|
|
88
|
-
description=f"Expected a DATE in YYYY-MM-DD format but got {value}.")
|
|
89
|
-
else:
|
|
90
|
-
return None, ContextLog(level=LogLevel.WARNING_FIX_REQUIRED,
|
|
91
|
-
subject=field_name,
|
|
92
|
-
description= f"Expected a DATE or YYYY-MM-DD str format but got {value} of type {type(value).__name__}.")
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
def handle_timestamp_fields(field_name, value, dt_ts_to_str):
|
|
96
|
-
"""Handles timestamp fields, ensuring they are in the correct format and optionally converts them to ISO format string."""
|
|
97
|
-
if isinstance(value, datetime.datetime):
|
|
98
|
-
if dt_ts_to_str:
|
|
99
|
-
return value.isoformat(), None
|
|
100
|
-
return value, None
|
|
101
|
-
elif isinstance(value, str):
|
|
102
|
-
try:
|
|
103
|
-
parsed_datetime = datetime.datetime.fromisoformat(value)
|
|
104
|
-
if dt_ts_to_str:
|
|
105
|
-
return value, None
|
|
106
|
-
return parsed_datetime, None
|
|
107
|
-
except ValueError:
|
|
108
|
-
return None, ContextLog(level=LogLevel.WARNING_FIX_REQUIRED,
|
|
109
|
-
subject=field_name,
|
|
110
|
-
description= f"Expected ISO format TIMESTAMP but got {value}.")
|
|
111
|
-
else:
|
|
112
|
-
return None, ContextLog(level=LogLevel.WARNING_FIX_REQUIRED,
|
|
113
|
-
subject=field_name,
|
|
114
|
-
description= f"Expected ISO format TIMESTAMP but got {value} of type {type(value).__name__}.")
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
def check_and_truncate_length(field_name, value, max_length):
|
|
118
|
-
"""Checks and truncates the length of string fields if they exceed the max length."""
|
|
119
|
-
if isinstance(value, str) and len(value) > max_length:
|
|
120
|
-
return value[:max_length], ContextLog(level=LogLevel.WARNING_FIX_RECOMMENDED,
|
|
121
|
-
subject= field_name,
|
|
122
|
-
description= f"Field exceeds max length: {len(value)}/{max_length}. Truncating.")
|
|
123
|
-
|
|
124
|
-
return value, None
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
def handle_type_conversion(field_type, field_name, value):
|
|
129
|
-
if field_type == "STRING" and not isinstance(value, str):
|
|
130
|
-
return str(value), ContextLog(level=LogLevel.WARNING_REVIEW_RECOMMENDED,
|
|
131
|
-
subject=field_name,
|
|
132
|
-
description= f"Expected STRING but got {value} of type {type(value).__name__}.")
|
|
133
|
-
|
|
134
|
-
if field_type == "INT64" and not isinstance(value, int):
|
|
135
|
-
try:
|
|
136
|
-
return int(value), None
|
|
137
|
-
except ValueError:
|
|
138
|
-
return None, ContextLog(level=LogLevel.WARNING_FIX_REQUIRED,
|
|
139
|
-
subject= field_name,
|
|
140
|
-
description=f"Expected INTEGER, but got {value} of type {type(value).__name__}.")
|
|
141
|
-
if field_type == "FLOAT64" and not isinstance(value, float):
|
|
142
|
-
try:
|
|
143
|
-
return float(value), None
|
|
144
|
-
except ValueError:
|
|
145
|
-
return None, ContextLog(level=LogLevel.WARNING_FIX_REQUIRED,
|
|
146
|
-
subject=field_name,
|
|
147
|
-
description=f"Expected FLOAT, but got {value} of type {type(value).__name__}.")
|
|
148
|
-
if field_type == "BOOL" and not isinstance(value, bool):
|
|
149
|
-
return bool(value), ContextLog(level=LogLevel.WARNING_REVIEW_RECOMMENDED,
|
|
150
|
-
subject=field_name,
|
|
151
|
-
description=f"Expected BOOL, but got {value}. Converting as {bool(value)}.")
|
|
152
|
-
|
|
153
|
-
return value, None
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
ipulse_shared_core_ftredge/__init__.py,sha256=QHWbeWYQgs314BKxQDzG7_P2mdnryC1Zqc3xvw8OfnM,987
|
|
2
|
-
ipulse_shared_core_ftredge/utils_custom_logs.py,sha256=OJ6STEL7GER-s3x03cKcsYtZ4jKhndPOAJXT1oiAY2M,8183
|
|
3
|
-
ipulse_shared_core_ftredge/utils_gcp.py,sha256=xI0iOxSjGQ75ECFlmPirOB8Cz8qjqYNabfRLEg0cE8o,14142
|
|
4
|
-
ipulse_shared_core_ftredge/utils_gcp_for_pipelines.py,sha256=rO7KD8JUmit0NwKoepKmBX8MlcQ8GzDhUfAyp6OWAw0,11816
|
|
5
|
-
ipulse_shared_core_ftredge/utils_pipelinemon.py,sha256=KRDJW0fqF6sfqsxL8YKH378qpXnOzpZ3C53VAkMoT10,15011
|
|
6
|
-
ipulse_shared_core_ftredge/utils_templates_and_schemas.py,sha256=vi8hBU95_N-Znfs-FClBNCFMKvJYBOdBwZm2pgBZ7BQ,7433
|
|
7
|
-
ipulse_shared_core_ftredge/enums/__init__.py,sha256=MRmvcrFhbGZbww759KCledFe6BpOArmnCQ18mb_F8Fg,932
|
|
8
|
-
ipulse_shared_core_ftredge/enums/enums_common_utils.py,sha256=VdOipu5YNVO4TcQMXy7UkCjSnBfUzutEkgfFFsnsp7k,6922
|
|
9
|
-
ipulse_shared_core_ftredge/enums/enums_data_eng.py,sha256=7w3Jjmw84Wq22Bb5Qs09Z82Bdf-j8nhRiQJfw60_g80,1903
|
|
10
|
-
ipulse_shared_core_ftredge/enums/enums_module_fincore.py,sha256=W1TkSLu3ryLf_aif2VcKsFznWz0igeMUR_buoGEG6w8,1406
|
|
11
|
-
ipulse_shared_core_ftredge/enums/enums_modules.py,sha256=AyXUoNmR75DZLaEHi3snV6LngR25LeZRqzrLDaAupbY,1244
|
|
12
|
-
ipulse_shared_core_ftredge/models/__init__.py,sha256=gE22Gzhil0RYQa7YLtdtT44_AsWqklcDfRtgLAQc1dI,200
|
|
13
|
-
ipulse_shared_core_ftredge/models/audit_log_firestore.py,sha256=5AwO6NHuOncq65n400eqM8QPrS2EGGaP3Z_6l2rxdBE,261
|
|
14
|
-
ipulse_shared_core_ftredge/models/organisation.py,sha256=4f1ATEWh5WT-CDJBLEZUhUwyl3V06ogRkteZAqW_nko,2953
|
|
15
|
-
ipulse_shared_core_ftredge/models/pulse_enums.py,sha256=YJhtvoX6Dk3_SyJUD8vVDSRIzWy5n0I0AOwe19fmDT8,4851
|
|
16
|
-
ipulse_shared_core_ftredge/models/resource_catalog_item.py,sha256=PxeRvI8fe8KOiHr6NW2Jz_yocyLId09PW8QyTZxjHAA,9809
|
|
17
|
-
ipulse_shared_core_ftredge/models/user_auth.py,sha256=35HNN7ZW4ZELCqaJrAtoSsVLFAZ1KL2S_VmuzbcEMm4,119
|
|
18
|
-
ipulse_shared_core_ftredge/models/user_profile.py,sha256=D3BB9D6XEv7IVZgsURgf0hWmUZW5rms3uiBXS0ZGLeE,1927
|
|
19
|
-
ipulse_shared_core_ftredge/models/user_profile_update.py,sha256=oKK0XsQDKkgDvjFPhX2XlqEqlKLBQ4AkvPHXEuZbFMY,1712
|
|
20
|
-
ipulse_shared_core_ftredge/models/user_status.py,sha256=8TyRd8tBK9_xb0MPKbI5pn9-lX7ovKbeiuWYYPtIOiw,3202
|
|
21
|
-
ipulse_shared_core_ftredge-2.57.dist-info/LICENCE,sha256=YBtYAXNqCCOo9Mr2hfkbSPAM9CeAr2j1VZBSwQTrNwE,1060
|
|
22
|
-
ipulse_shared_core_ftredge-2.57.dist-info/METADATA,sha256=OFCR8U5m0OwnbR9hyIqSwOWW40QmwDfz1WqnWSVnBxg,561
|
|
23
|
-
ipulse_shared_core_ftredge-2.57.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
|
|
24
|
-
ipulse_shared_core_ftredge-2.57.dist-info/top_level.txt,sha256=8sgYrptpexkA_6_HyGvho26cVFH9kmtGvaK8tHbsGHk,27
|
|
25
|
-
ipulse_shared_core_ftredge-2.57.dist-info/RECORD,,
|
{ipulse_shared_core_ftredge-2.57.dist-info → ipulse_shared_core_ftredge-3.2.1.dist-info}/LICENCE
RENAMED
|
File without changes
|
|
File without changes
|