Skip to content

Commit 6af9f91

Browse files
committed
chore: remove models from deprecated code
1 parent d00b926 commit 6af9f91

File tree

7 files changed

+37
-58
lines changed

7 files changed

+37
-58
lines changed

aws_lambda_powertools/helper/__init__.py

-2
This file was deleted.
+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Logging utility
22
"""
3-
from ..helper.models import MetricUnit
43
from .logger import Logger
54

6-
__all__ = ["MetricUnit", "Logger"]
5+
__all__ = ["Logger"]
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,15 @@
1-
"""Collection of classes as models and builder functions
2-
that provide classes as data representation for
3-
key data used in more than one place.
4-
"""
5-
6-
from enum import Enum
7-
8-
91
class LambdaContextModel:
102
"""A handful of Lambda Runtime Context fields
113
124
Full Lambda Context object: https://docs.aws.amazon.com/lambda/latest/dg/python-context-object.html
135
14-
NOTE
15-
----
16-
17-
Originally, memory_size is `int` but we cast to `str` in this model
18-
due to aws_lambda_logging library use of `%` during formatting
19-
Ref: https://gitlab.com/hadrien/aws_lambda_logging/blob/master/aws_lambda_logging.py#L47
20-
216
Parameters
227
----------
238
function_name: str
249
Lambda function name, by default "UNDEFINED"
2510
e.g. "test"
26-
function_memory_size: str
27-
Lambda function memory in MB, by default "UNDEFINED"
28-
e.g. "128"
29-
casting from int to str due to aws_lambda_logging using `%` when enumerating fields
11+
function_memory_size: int
12+
Lambda function memory in MB, by default 128
3013
function_arn: str
3114
Lambda function ARN, by default "UNDEFINED"
3215
e.g. "arn:aws:lambda:eu-west-1:809313241:function:test"
@@ -38,7 +21,7 @@ class LambdaContextModel:
3821
def __init__(
3922
self,
4023
function_name: str = "UNDEFINED",
41-
function_memory_size: str = "UNDEFINED",
24+
function_memory_size: int = 128,
4225
function_arn: str = "UNDEFINED",
4326
function_request_id: str = "UNDEFINED",
4427
):
@@ -70,32 +53,3 @@ def build_lambda_context_model(context: object) -> LambdaContextModel:
7053
}
7154

7255
return LambdaContextModel(**context)
73-
74-
75-
class MetricUnit(Enum):
76-
Seconds = "Seconds"
77-
Microseconds = "Microseconds"
78-
Milliseconds = "Milliseconds"
79-
Bytes = "Bytes"
80-
Kilobytes = "Kilobytes"
81-
Megabytes = "Megabytes"
82-
Gigabytes = "Gigabytes"
83-
Terabytes = "Terabytes"
84-
Bits = "Bits"
85-
Kilobits = "Kilobits"
86-
Megabits = "Megabits"
87-
Gigabits = "Gigabits"
88-
Terabits = "Terabits"
89-
Percent = "Percent"
90-
Count = "Count"
91-
BytesPerSecond = "Bytes/Second"
92-
KilobytesPerSecond = "Kilobytes/Second"
93-
MegabytesPerSecond = "Megabytes/Second"
94-
GigabytesPerSecond = "Gigabytes/Second"
95-
TerabytesPerSecond = "Terabytes/Second"
96-
BitsPerSecond = "Bits/Second"
97-
KilobitsPerSecond = "Kilobits/Second"
98-
MegabitsPerSecond = "Megabits/Second"
99-
GigabitsPerSecond = "Gigabits/Second"
100-
TerabitsPerSecond = "Terabits/Second"
101-
CountPerSecond = "Count/Second"

aws_lambda_powertools/logging/logger.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
from distutils.util import strtobool
99
from typing import Any, Callable, Dict, Union
1010

11-
from ..helper.models import build_lambda_context_model
1211
from .exceptions import InvalidLoggerSamplingRateError
12+
from .lambda_context import build_lambda_context_model
1313

1414
logger = logging.getLogger(__name__)
1515

aws_lambda_powertools/metrics/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""CloudWatch Embedded Metric Format utility
22
"""
3-
from ..helper.models import MetricUnit
3+
from .base import MetricUnit
44
from .exceptions import MetricUnitError, MetricValueError, SchemaValidationError
55
from .metric import single_metric
66
from .metrics import Metrics

aws_lambda_powertools/metrics/base.py

+30-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
import numbers
55
import os
66
import pathlib
7+
from enum import Enum
78
from typing import Dict, List, Union
89

910
import fastjsonschema
1011

11-
from ..helper.models import MetricUnit
1212
from .exceptions import MetricUnitError, MetricValueError, SchemaValidationError
1313

1414
logger = logging.getLogger(__name__)
@@ -20,6 +20,35 @@
2020
MAX_METRICS = 100
2121

2222

23+
class MetricUnit(Enum):
24+
Seconds = "Seconds"
25+
Microseconds = "Microseconds"
26+
Milliseconds = "Milliseconds"
27+
Bytes = "Bytes"
28+
Kilobytes = "Kilobytes"
29+
Megabytes = "Megabytes"
30+
Gigabytes = "Gigabytes"
31+
Terabytes = "Terabytes"
32+
Bits = "Bits"
33+
Kilobits = "Kilobits"
34+
Megabits = "Megabits"
35+
Gigabits = "Gigabits"
36+
Terabits = "Terabits"
37+
Percent = "Percent"
38+
Count = "Count"
39+
BytesPerSecond = "Bytes/Second"
40+
KilobytesPerSecond = "Kilobytes/Second"
41+
MegabytesPerSecond = "Megabytes/Second"
42+
GigabytesPerSecond = "Gigabytes/Second"
43+
TerabytesPerSecond = "Terabytes/Second"
44+
BitsPerSecond = "Bits/Second"
45+
KilobitsPerSecond = "Kilobits/Second"
46+
MegabitsPerSecond = "Megabits/Second"
47+
GigabitsPerSecond = "Gigabits/Second"
48+
TerabitsPerSecond = "Terabits/Second"
49+
CountPerSecond = "Count/Second"
50+
51+
2352
class MetricManager:
2453
"""Base class for metric functionality (namespace, metric, dimension, serialization)
2554

aws_lambda_powertools/metrics/metric.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
from contextlib import contextmanager
44
from typing import Dict
55

6-
from ..helper.models import MetricUnit
7-
from .base import MetricManager
6+
from .base import MetricManager, MetricUnit
87

98
logger = logging.getLogger(__name__)
109

0 commit comments

Comments
 (0)