boto3-assist 0.1.9__py3-none-any.whl → 0.1.11__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.
@@ -15,12 +15,19 @@ class ConnectionTracker:
15
15
  """
16
16
 
17
17
  def __init__(self, service_name: str) -> None:
18
- self.__stack_trace_env_var: str = "ISSUE_STACK_TRACE"
18
+ self.__stack_trace_env_var: str = "BOTO3_ASSIST_CONNECTION_STACK_TRACE"
19
19
  self.__connection_couter: int = 0
20
20
  self.__service_name: str = service_name
21
- self.__issue_stack_trace: bool = (
22
- os.getenv(f"{self.__stack_trace_env_var}", "false") == "true"
23
- )
21
+ self.__issue_stack_trace: bool | None = None
22
+
23
+ @property
24
+ def issue_stack_trace(self) -> bool:
25
+ """Returns True if the stack trace should be issued"""
26
+ if self.__issue_stack_trace is None:
27
+ self.__issue_stack_trace = (
28
+ os.getenv(self.__stack_trace_env_var, "").lower() == "true"
29
+ )
30
+ return self.__issue_stack_trace
24
31
 
25
32
  def increment_connection(self) -> None:
26
33
  """Increments the connection counter"""
@@ -32,11 +39,17 @@ class ConnectionTracker:
32
39
  if self.__service_name:
33
40
  service_message = f"Your {self.__service_name} service has more than one connection.\n"
34
41
 
35
- if not self.__issue_stack_trace:
42
+ if not self.issue_stack_trace:
36
43
  stack_trace_message = (
37
44
  f"\nTo add addtional information to the log and determine where additional connections are being created"
38
45
  f", set the environment variable {self.__stack_trace_env_var} to true.\n"
39
46
  )
47
+ else:
48
+ stack_trace_message = (
49
+ f"\nStack Trace Enabeld with {self.__stack_trace_env_var}"
50
+ "\n".join(traceback.format_stack())
51
+ )
52
+
40
53
  self.__log_warning(
41
54
  f"{service_message}"
42
55
  f"Your dynamodb connection count is {self.connection_count}. "
@@ -48,12 +61,6 @@ class ConnectionTracker:
48
61
  f"{stack_trace_message}"
49
62
  )
50
63
 
51
- # do a stack trace
52
- if self.__issue_stack_trace:
53
- print("Stack Trace")
54
- traceback.print_stack()
55
- print("")
56
-
57
64
  def decrement_connection(self) -> None:
58
65
  """Decrements the connection counter"""
59
66
  self.__connection_couter -= 1
@@ -4,43 +4,14 @@ Maintainers: Eric Wilson
4
4
  MIT License. See Project Root for the license information.
5
5
  """
6
6
 
7
+ from boto3_assist.connection_tracker import ConnectionTracker
7
8
 
8
- class DynamoDBConnectionTracker:
9
+
10
+ class DynamoDBConnectionTracker(ConnectionTracker):
9
11
  """
10
12
  Tracks DynamoDB Connection Requests.
11
13
  Useful in for performance tuning and debugging.
12
14
  """
13
15
 
14
16
  def __init__(self) -> None:
15
- self.__connection_couter: int = 0
16
-
17
- def increment_connection(self) -> None:
18
- """Increments the connection counter"""
19
- self.__connection_couter += 1
20
-
21
- if self.connection_count > 1:
22
- self.__log_warning(
23
- f"Your dynamodb connection count is {self.connection_count}. "
24
- "Under most circumstances you should be able to use the same connection "
25
- "vs. creating a new one. Connections are expensive in terms of time / latency. "
26
- "If you are seeing perforance issues, check how and where you are creating your "
27
- "connections. You should be able to pass the .db connection to your other objects "
28
- "and reuse your dynamodb boto connections."
29
- )
30
-
31
- def decrement_connection(self) -> None:
32
- """Decrements the connection counter"""
33
- self.__connection_couter -= 1
34
-
35
- @property
36
- def connection_count(self) -> int:
37
- """Returns the current connection count"""
38
- return self.__connection_couter
39
-
40
- def reset(self) -> None:
41
- """Resets the connection counter"""
42
- self.__connection_couter = 0
43
-
44
- def __log_warning(self, message: str) -> None:
45
- """Logs a warning message"""
46
- print(f"Warning: {message}")
17
+ super().__init__("DynamoDB")
@@ -80,6 +80,10 @@ class DynamoDBModelBase:
80
80
  """Gets the auto generate projections"""
81
81
  return self.__auto_generate_projections
82
82
 
83
+ @auto_generate_projections.setter
84
+ def auto_generate_projections(self, value: bool):
85
+ self.__auto_generate_projections = value
86
+
83
87
  @projection_expression.setter
84
88
  def projection_expression(self, value: str | None):
85
89
  self.__projection_expression = value
boto3_assist/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = '0.1.9'
1
+ __version__ = '0.1.11'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: boto3_assist
3
- Version: 0.1.9
3
+ Version: 0.1.11
4
4
  Summary: Additional boto3 wrappers to make your life a little easier
5
5
  Author-email: Eric Wilson <boto3-assist@geekcafe.com>
6
6
  License-File: LICENSE-EXPLAINED.txt
@@ -1,16 +1,16 @@
1
1
  boto3_assist/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  boto3_assist/boto3session.py,sha256=J20E2lkqJOaey4Ohi-xRe2xABj7QsA8DrggzK29-5es,6415
3
- boto3_assist/connection_tracker.py,sha256=WYRdDSozJlxbFY_oYQAlGRpDgFWsF_nAiN7CIzh_yVo,2637
4
- boto3_assist/version.py,sha256=2uYVJ4eLF8kKOzfX6k2Go3u7xIwcGSuemAueAoXn-5o,22
3
+ boto3_assist/connection_tracker.py,sha256=4_Ul7ttSrY9SqBGy9yYukB01XGe1puatFiZDDbQVfp4,2950
4
+ boto3_assist/version.py,sha256=pcQGPRp7RzLI5LdLr7oqGpfTXVf4n0nfR49AeX_SD8g,23
5
5
  boto3_assist/dynamodb/dynamodb.py,sha256=vV0HvFCESnVK6BcAfcrWsMsNxIIsctvDX_3xdzOVCT0,14623
6
6
  boto3_assist/dynamodb/dynamodb_connection.py,sha256=JMCmWOsMzy45rikGl3Z2xqlG2vUTEKSYqi6dpsfJ750,4418
7
- boto3_assist/dynamodb/dynamodb_connection_tracker.py,sha256=nTNQ99sIidDoLMhMbBju2umgLmcttsmnvmd_DMy_J9M,1582
7
+ boto3_assist/dynamodb/dynamodb_connection_tracker.py,sha256=0BWHRfi5_vjkJLuCSX6sYwvA6wc7BSYCQnGrzbhfyKA,404
8
8
  boto3_assist/dynamodb/dynamodb_helpers.py,sha256=ajpTJ5bJOm9PDgE2Zx9p2zkTRFV4xswqJRS81SOTn1s,12198
9
9
  boto3_assist/dynamodb/dynamodb_importer.py,sha256=nCKsyRQeMqDSf0Q5mQ_X_oVIg4PRnu0hcUzZnBli610,3471
10
10
  boto3_assist/dynamodb/dynamodb_index.py,sha256=LRQgSci222s-pU-JXgnaAoOa71ABX9h3uJPeCVPl1GE,6315
11
11
  boto3_assist/dynamodb/dynamodb_iservice.py,sha256=2AuaKxt7DUZbB-GpBBtPtPMpAlgZkumkAldm8vy7-sg,701
12
12
  boto3_assist/dynamodb/dynamodb_key.py,sha256=X3I3gUPx2T858vjRDi9SN8qn8ez5UJUo0vZiKBeeUWg,1776
13
- boto3_assist/dynamodb/dynamodb_model_base.py,sha256=5JRecZC9Cz8iJ5BZ4b2XhTEMclZB7pAnknrBNzZ3JS4,13350
13
+ boto3_assist/dynamodb/dynamodb_model_base.py,sha256=x4jrH10-uooeQfdKhWQ6htXhA95bvCBET8jKrM7TQD0,13492
14
14
  boto3_assist/dynamodb/dynamodb_model_base_interfaces.py,sha256=yT4zDRI8vP15WVOHnCvY3FsEy_QSIta5-bnUby70Xow,747
15
15
  boto3_assist/dynamodb/dynamodb_reindexer.py,sha256=_I-W7Ply-82fRHnhsRZuquRYxEIXubuWGq7E7B4Pa7I,6204
16
16
  boto3_assist/dynamodb/dynamodb_reserved_words.py,sha256=iiud7ijpER5MgKHIP_NIgkDmHVy_57VRQzNHRipv0as,1786
@@ -25,8 +25,8 @@ boto3_assist/utilities/datetime_utility.py,sha256=TbqGQkJDTahqvaZAIV550nhYnW1Bsq
25
25
  boto3_assist/utilities/logging_utility.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
26
  boto3_assist/utilities/serialization_utility.py,sha256=s_QQRIhtwIE7xN5nU13mNk2wtWyErBX_Sg7n0gbHj-M,4308
27
27
  boto3_assist/utilities/string_utility.py,sha256=w8l063UT3GE48tuJopETyZrjG4CgAzWkyDWMAYMg5Og,7432
28
- boto3_assist-0.1.9.dist-info/METADATA,sha256=T9Z7AqJ3YXzOGdHxwdyccfyiCNf4sE7ZfiV6KZiXbFA,1804
29
- boto3_assist-0.1.9.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
30
- boto3_assist-0.1.9.dist-info/licenses/LICENSE-EXPLAINED.txt,sha256=WFREvTpfTjPjDHpOLADxJpCKpIla3Ht87RUUGii4ODU,606
31
- boto3_assist-0.1.9.dist-info/licenses/LICENSE.txt,sha256=PXDhFWS5L5aOTkVhNvoitHKbAkgxqMI2uUPQyrnXGiI,1105
32
- boto3_assist-0.1.9.dist-info/RECORD,,
28
+ boto3_assist-0.1.11.dist-info/METADATA,sha256=3xXuCYMVn4pX-A3lliPIVxY2WXs_2udRMVIe-2c2lg4,1805
29
+ boto3_assist-0.1.11.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
30
+ boto3_assist-0.1.11.dist-info/licenses/LICENSE-EXPLAINED.txt,sha256=WFREvTpfTjPjDHpOLADxJpCKpIla3Ht87RUUGii4ODU,606
31
+ boto3_assist-0.1.11.dist-info/licenses/LICENSE.txt,sha256=PXDhFWS5L5aOTkVhNvoitHKbAkgxqMI2uUPQyrnXGiI,1105
32
+ boto3_assist-0.1.11.dist-info/RECORD,,