ipulse-shared-core-ftredge 2.26__py3-none-any.whl → 2.28__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 ipulse-shared-core-ftredge might be problematic. Click here for more details.

@@ -1,5 +1,6 @@
1
1
  from .models import Organisation, UserAuth, UserProfile, UserStatus, UserProfileUpdate, pulse_enums
2
2
  from .utils_gcp import setup_gcp_logger_and_error_report, read_csv_from_gcs, read_json_from_gcs, write_csv_to_gcs, write_json_to_gcs
3
- from .utils_templates_and_schemas import create_bigquery_schema_from_json,update_check_with_schema_template, update_check_with_dict_template
3
+ from .utils_templates_and_schemas import create_bigquery_schema_from_json,update_check_with_schema_template
4
+ from .enums_common import NoticeSeverity
4
5
 
5
6
 
@@ -0,0 +1,27 @@
1
+ from enum import Enum
2
+
3
+ class NoticeSeverity(Enum):
4
+ """
5
+ Standardized logging levels for data engineering pipelines,
6
+ designed for easy analysis and identification of manual
7
+ intervention needs.
8
+ """
9
+ DEBUG = 100 # Detailed debug information (for development/troubleshooting)
10
+ INFO = 200 # Normal pipeline execution information
11
+ NOTICE = 300 # Events requiring attention, but not necessarily errors
12
+
13
+ # Warnings indicate potential issues that might require attention:
14
+ WARNING_NO_ACTION = 401 # Minor issue or Unexpected Behavior, no immediate action required (can be logged frequently)
15
+ WARNING_ACTION_RECOMMENDED = 402 # Action recommended to prevent potential future issues
16
+ WARNING_ACTION_REQUIRED = 403 # Action required, pipeline can likely continue
17
+
18
+ # Errors indicate a problem that disrupts normal pipeline execution:
19
+ ERROR_TRANSIENT_RETRY = 501 # Temporary error, automatic retry likely to succeed
20
+ ERROR_DATA_ISSUE_ISOLATED = 502 # Error likely caused by data issues, manual intervention likely needed
21
+ ERROR_DATA_ISSUE_WITH_DEPENDENCIES = 503 # Error likely in code/configuration, investigation required
22
+ ERROR_CONFIG_OR_CODE_ISSUE = 504 # Error likely in code/configuration, investigation required
23
+ ERROR_UNKNOWN_EXCEPTION = 505
24
+
25
+ # Critical errors indicate severe failures requiring immediate attention:
26
+ CRITICAL_SYSTEM_FAILURE = 601 # System-level failure (e.g., infrastructure), requires immediate action
27
+ CRITICAL_PIPELINE_FAILURE = 602 # Complete pipeline failure, requires investigation and potential rollback
@@ -1,5 +1,11 @@
1
- import datetime
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
2
7
  from google.cloud import bigquery
8
+ from . import NoticeSeverity
3
9
 
4
10
  def create_bigquery_schema_from_json(json_schema):
5
11
  schema = []
@@ -10,67 +16,66 @@ def create_bigquery_schema_from_json(json_schema):
10
16
  schema.append(bigquery.SchemaField(field["name"], field["type"], mode=field["mode"]))
11
17
  return schema
12
18
 
13
- def update_check_with_dict_template(template, updates, logger):
14
- template_dict = template.copy()
15
- filtered_updates = {k: v for k, v in updates.items() if k in template}
16
- template_dict.update(filtered_updates)
17
- # Log warnings for any fields in the updates that are not in the template
18
- extra_fields = set(updates.keys()) - set(template.keys())
19
- if extra_fields:
20
- logger.warning(f"Fields in the updates extra to the template config: {extra_fields}. You probably forgot to update the Template Config. Do so now.")
21
- return template_dict
22
19
 
23
20
  def update_check_with_schema_template(updates, schema, logger, dt_ts_to_str=True, check_max_length=True):
21
+
24
22
  """Ensure Update dict corresponds to the config schema, ensuring proper formats and lengths."""
25
23
  valid_updates = {}
26
- schema_dict = {field["name"]: field for field in schema}
27
24
 
28
- for field_name, value in updates.items():
29
- if field_name in schema_dict:
30
- field_type = schema_dict[field_name]["type"]
25
+ # Process updates to conform to the schema
26
+ for field in schema:
27
+ field_name = field["name"]
28
+ field_type = field["type"]
29
+ mode = field["mode"]
30
+
31
+ if field_name in updates:
32
+ value = updates[field_name]
31
33
 
34
+ # Handle date and timestamp formatting
32
35
  if dt_ts_to_str:
33
36
  if field_type == "DATE":
34
37
  value = handle_date_fields(field_name, value, logger)
35
38
  elif field_type == "TIMESTAMP":
36
39
  value = handle_timestamp_fields(field_name, value, logger)
37
40
 
38
- if check_max_length and "max_length" in schema_dict[field_name]:
39
- value = check_and_truncate_length(field_name, value, schema_dict[field_name]["max_length"], logger)
41
+ # Check and handle max length restriction
42
+ if check_max_length and "max_length" in field:
43
+ value = check_and_truncate_length(field_name, value, field["max_length"], logger)
40
44
 
41
- # Set the value in the template dictionary based on the field type
42
- if field_type == "STRING" and not isinstance(value, str):
43
- logger.warning(f"Field {field_name} expected to be a string but got {type(value).__name__}.")
44
- value = str(value)
45
- elif field_type == "INT64" and not isinstance(value, int):
46
- logger.warning(f"Field {field_name} expected to be an int but got {type(value).__name__}.")
47
- try:
48
- value = int(value)
49
- except ValueError:
50
- logger.warning(f"Cannot convert value {value} of field {field_name} to int.")
51
- value = None
52
- elif field_type == "FLOAT64" and not isinstance(value, float):
53
- logger.warning(f"Field {field_name} expected to be a float but got {type(value).__name__}.")
54
- try:
55
- value = float(value)
56
- except ValueError:
57
- logger.warning(f"Cannot convert value {value} of field {field_name} to float.")
58
- value = None
59
- elif field_type == "BOOL" and not isinstance(value, bool):
60
- logger.warning(f"Field {field_name} expected to be a bool but got {type(value).__name__}.")
61
- value = bool(value)
62
-
63
- valid_updates[field_name] = value
64
- else:
65
- logger.warning(f"Field {field_name} not in schema template, it will be ignored.You probably forgot to update the Schema Config. Do so now. "
66
- "And assess the manual work required to fix missed data.")
67
-
68
- # Check for missing REQUIRED fields
69
- for field in schema:
70
- if field["mode"] == "REQUIRED" and field["name"] not in valid_updates:
71
- logger.warning(f"Required field '{field['name']}' is missing in the updates.")
45
+ # Validate and convert types
46
+ if field_type == "STRING":
47
+ if not isinstance(value, str):
48
+ logger.warning(f"Field {field_name} expected to be a string but got {type(value).__name__}.")
49
+ value = str(value)
50
+ elif field_type == "INT64":
51
+ if not isinstance(value, int):
52
+ logger.warning(f"Field {field_name} expected to be an int but got {type(value).__name__}.")
53
+ try:
54
+ value = int(value)
55
+ except ValueError:
56
+ logger.warning(f"Cannot convert value {value} of field {field_name} to int.")
57
+ continue
58
+ elif field_type == "FLOAT64":
59
+ if not isinstance(value, float):
60
+ logger.warning(f"Field {field_name} expected to be a float but got {type(value).__name__}.")
61
+ try:
62
+ value = float(value)
63
+ except ValueError:
64
+ logger.warning(f"Cannot convert value {value} of field {field_name} to float.")
65
+ continue
66
+ elif field_type == "BOOL":
67
+ if not isinstance(value, bool):
68
+ logger.warning(f"Field {field_name} expected to be a bool but got {type(value).__name__}.")
69
+ value = bool(value)
70
+
71
+ # Only add to the dictionary if value is not None or the field is required
72
+ if value is not None or mode == "REQUIRED":
73
+ valid_updates[field_name] = value
74
+
75
+ elif mode == "REQUIRED":
76
+ logger.warning(f"Required field '{field_name}' is missing in the updates.")
72
77
 
73
- return valid_updates
78
+ return valid_updates
74
79
 
75
80
 
76
81
  def check_updates_formatting(updates, schema, logger, dt_ts_to_str, check_max_length):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ipulse_shared_core_ftredge
3
- Version: 2.26
3
+ Version: 2.28
4
4
  Summary: Shared Core models and Logger util for the Pulse platform project. Using AI for financial advisory and investment management.
5
5
  Home-page: https://github.com/TheFutureEdge/ipulse_shared_core
6
6
  Author: Russlan Ramdowar
@@ -1,6 +1,7 @@
1
- ipulse_shared_core_ftredge/__init__.py,sha256=OzKQDJcK-xsfy4j1ldBhoMCsdRHq0vPUsyVUOiTCROY,376
1
+ ipulse_shared_core_ftredge/__init__.py,sha256=gJQzYYV1NyehTS6ZPtzaGv6-ihRXaxaew7dBNxM4V1g,384
2
+ ipulse_shared_core_ftredge/enums_common.py,sha256=abs_PFWpd79ZikFEWbwidPN4bKjcDq5qFsvYgupLQMo,1601
2
3
  ipulse_shared_core_ftredge/utils_gcp.py,sha256=E8TvZ05fTjNr-VQXxSZNCiqT9PwPhtqeKOifIGhb2sg,6289
3
- ipulse_shared_core_ftredge/utils_templates_and_schemas.py,sha256=iRUA_0IFrKHIiqnaRirNDrhlz9Jf-IdXISNqsHgwlHI,6227
4
+ ipulse_shared_core_ftredge/utils_templates_and_schemas.py,sha256=rYk547qbiRx7Q5a5pcb29lkwSArjS_F9Hf1JkX05mBU,5861
4
5
  ipulse_shared_core_ftredge/models/__init__.py,sha256=gE22Gzhil0RYQa7YLtdtT44_AsWqklcDfRtgLAQc1dI,200
5
6
  ipulse_shared_core_ftredge/models/audit_log_firestore.py,sha256=5AwO6NHuOncq65n400eqM8QPrS2EGGaP3Z_6l2rxdBE,261
6
7
  ipulse_shared_core_ftredge/models/organisation.py,sha256=4f1ATEWh5WT-CDJBLEZUhUwyl3V06ogRkteZAqW_nko,2953
@@ -12,8 +13,8 @@ ipulse_shared_core_ftredge/models/user_profile_update.py,sha256=oKK0XsQDKkgDvjFP
12
13
  ipulse_shared_core_ftredge/models/user_status.py,sha256=8TyRd8tBK9_xb0MPKbI5pn9-lX7ovKbeiuWYYPtIOiw,3202
13
14
  ipulse_shared_core_ftredge/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
15
  ipulse_shared_core_ftredge/tests/test.py,sha256=0lS8HP5Quo_BqNoscU40qOH9aJRaa1Pfam5VUBmdld8,682
15
- ipulse_shared_core_ftredge-2.26.dist-info/LICENCE,sha256=YBtYAXNqCCOo9Mr2hfkbSPAM9CeAr2j1VZBSwQTrNwE,1060
16
- ipulse_shared_core_ftredge-2.26.dist-info/METADATA,sha256=Cch9ylDzsq944x_iIaECNM9d0Vengx9PCPsYgmE5FEk,561
17
- ipulse_shared_core_ftredge-2.26.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
18
- ipulse_shared_core_ftredge-2.26.dist-info/top_level.txt,sha256=8sgYrptpexkA_6_HyGvho26cVFH9kmtGvaK8tHbsGHk,27
19
- ipulse_shared_core_ftredge-2.26.dist-info/RECORD,,
16
+ ipulse_shared_core_ftredge-2.28.dist-info/LICENCE,sha256=YBtYAXNqCCOo9Mr2hfkbSPAM9CeAr2j1VZBSwQTrNwE,1060
17
+ ipulse_shared_core_ftredge-2.28.dist-info/METADATA,sha256=YqkikZJUwwzn1QwAU2f1Sk5rJPG30TxsSTF4yLQp-iU,561
18
+ ipulse_shared_core_ftredge-2.28.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
19
+ ipulse_shared_core_ftredge-2.28.dist-info/top_level.txt,sha256=8sgYrptpexkA_6_HyGvho26cVFH9kmtGvaK8tHbsGHk,27
20
+ ipulse_shared_core_ftredge-2.28.dist-info/RECORD,,