bw-essentials-core 0.0.2__py3-none-any.whl → 0.0.5__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 bw-essentials-core might be problematic. Click here for more details.

@@ -30,6 +30,7 @@ class Notifications:
30
30
  alert (bool, optional): If True, it's treated as an error; otherwise as a log. Defaults to False.
31
31
  trace (str, optional): Optional traceback or detailed error string.
32
32
  request_id (str, optional): Optional correlation ID for tracing logs.
33
+ webhook_url(str, Optional): Optional webhook url for teams channel.
33
34
  """
34
35
 
35
36
  def __init__(self,
@@ -38,7 +39,8 @@ class Notifications:
38
39
  message=None,
39
40
  alert=False,
40
41
  trace=None,
41
- request_id=None):
42
+ request_id=None,
43
+ webhook_url=None):
42
44
  self.message = message
43
45
  self.title = title
44
46
  self.summary = summary
@@ -47,14 +49,15 @@ class Notifications:
47
49
  self.request_id = request_id
48
50
  self.notify_on_teams = self._get_env_var("NOTIFY_ON_TEAMS")
49
51
  self.notify_on_calls = self._get_env_var("NOTIFY_ON_CALLS")
50
- self.webhook_url = self._get_env_var("TEAMS_WEBHOOK_URL")
52
+ self.webhook_url = self._get_env_var("TEAMS_WEBHOOK_URL", webhook_url)
51
53
  self.zenduty_url = self._get_env_var("ZENDUTY_URL")
52
54
  self.api_timeout = self._get_env_var("API_TIMEOUT")
53
55
 
54
- def _get_env_var(self, key: str) -> str:
56
+ def _get_env_var(self, key: str, webhook_url: str = None) -> str:
55
57
  """
56
58
  Fetch a required variable from bw_config.py located in the root directory.
57
-
59
+ Args:
60
+ webhook_url(Optional[str]): Optional Teams webhook url at the time of initialisation.
58
61
  Raises:
59
62
  FileNotFoundError: If bw_config.py is not found.
60
63
  AttributeError: If the requested key is not defined in the config.
@@ -62,6 +65,9 @@ class Notifications:
62
65
  Returns:
63
66
  str: The value of the config variable.
64
67
  """
68
+ if webhook_url:
69
+ return webhook_url
70
+
65
71
  config_path = os.path.join(os.getcwd(), "bw_config.py")
66
72
 
67
73
  if not os.path.exists(config_path):
@@ -74,7 +80,8 @@ class Notifications:
74
80
  spec.loader.exec_module(bw_config)
75
81
 
76
82
  if not hasattr(bw_config, key):
77
- raise AttributeError(f"`{key}` not found in bw_config.py. Please define it in the config.")
83
+ raise AttributeError(f"`{key}` not found in bw_config.py. Please either define it in the config or"
84
+ f"pass it during Notifications init")
78
85
 
79
86
  return getattr(bw_config, key)
80
87
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bw-essentials-core
3
- Version: 0.0.2
3
+ Version: 0.0.5
4
4
  Summary: Reusable utilities for S3, email, Data Loch, Microsoft Teams Notifications and more.
5
5
  Author: InvestorAI
6
6
  Author-email: support+tech@investorai.in
@@ -177,7 +177,8 @@ from bw_essentials.notifications import Notifications
177
177
  notifier = Notifications(
178
178
  title="BW Alerts",
179
179
  summary="Pipeline Failure",
180
- message="Daily data sync failed."
180
+ message="Daily data sync failed.",
181
+ webhook_url="https://sample.webhook.url"
181
182
  )
182
183
  ```
183
184
 
@@ -7,7 +7,7 @@ bw_essentials/email_client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
7
7
  bw_essentials/email_client/email_client.py,sha256=_LzDWUJUkNTSn3C5v0-jjW-Ls537xt493lkcD4noQXY,9116
8
8
  bw_essentials/notifications/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  bw_essentials/notifications/teams_notification_schemas.py,sha256=FvZ8FyIwku4-0uweDn9gpaIJW_AIsNoqV1hB6lQ4OPI,6398
10
- bw_essentials/notifications/teams_notifications.py,sha256=tgDSOoAeNlhIq2ZJGTzf99bMEBajXe0rdCb9JJkm0ss,6913
10
+ bw_essentials/notifications/teams_notifications.py,sha256=1tkS3tTJQZ5ByMwK2WXpFgQn7-TobYYOncOj81NBySY,7308
11
11
  bw_essentials/s3_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  bw_essentials/s3_utils/s3_utils.py,sha256=wzjVrTX22_8PMX86svKFYGMZwgjBHbOaeEsxO-lR7BY,12922
13
13
  bw_essentials/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -19,7 +19,7 @@ bw_essentials/services/model_portfolio_reporting.py,sha256=iOtm4gyfU8P7C0R1gp6gU
19
19
  bw_essentials/services/trade_placement.py,sha256=PrzeU2XXC9HF1IQ1dMDM_ZHxmC491sOl-JbA6GWPwII,20772
20
20
  bw_essentials/services/user_portfolio.py,sha256=_5M6yPfQt4MXedINBawEoPkb_o7IGzxPeHkvZkoQm8k,16191
21
21
  bw_essentials/services/user_portfolio_reporting.py,sha256=QaZzcw912Uos5ZafEaxLXDmCyetTFiVX3at3cTAv6MA,6003
22
- bw_essentials_core-0.0.2.dist-info/METADATA,sha256=zfhOuMNvqEl__S5fMibh28S25CawsBvVsGZosyGviUM,7455
23
- bw_essentials_core-0.0.2.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
24
- bw_essentials_core-0.0.2.dist-info/top_level.txt,sha256=gDc5T_y5snwKGXDQUusEus-FEt0RFwG644Yn_58wQOQ,14
25
- bw_essentials_core-0.0.2.dist-info/RECORD,,
22
+ bw_essentials_core-0.0.5.dist-info/METADATA,sha256=WtgpSGCxi7tU-t0XHN_eoexCEWYwSvWTNZ5cyhuev6A,7501
23
+ bw_essentials_core-0.0.5.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
24
+ bw_essentials_core-0.0.5.dist-info/top_level.txt,sha256=gDc5T_y5snwKGXDQUusEus-FEt0RFwG644Yn_58wQOQ,14
25
+ bw_essentials_core-0.0.5.dist-info/RECORD,,