Utils
utils
DeferredError
DeferredError(exception)
Stores an exception and raises it at a later time if this object is accessed in any way.
Useful to allow soft-dependencies on imports, so that the ImportError can be raised again later if code actually relies on the missing library. Lifted from https://github.com/aws/sagemaker-python-sdk/blob/e626647692d136155d72cf5b100043af41ab6c43/src/sagemaker/utils.py#L788
Example::
try:
import obscurelib
except ImportError as e:
logger.warning("Failed to import obscurelib. Obscure features will not work.")
obscurelib = DeferredError(e)
Source code in llmeter/utils.py
26 27 28 29 30 31 32 33 | |
__getattr__
__getattr__(name)
Called by Python interpreter before using any method or property on the object.
So this will short-circuit essentially any access to this object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the attribute being accessed |
required |
Source code in llmeter/utils.py
35 36 37 38 39 40 41 42 43 | |
now_utc
now_utc()
Returns the current UTC datetime.
Returns:
| Name | Type | Description |
|---|---|---|
datetime |
datetime
|
Current UTC datetime object |
Source code in llmeter/utils.py
86 87 88 89 90 91 92 | |
summary_stats_from_list
summary_stats_from_list(data, percentiles=(50, 90, 99))
Calculate summary statistics for a sequence of numbers in pure Python
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Sequence[int | float]
|
Sequence of numbers |
required |
percentiles
|
Sequence[int]
|
Integer percentiles from 1-99 |
(50, 90, 99)
|
Returns:
stats: Dictionary of descriptive statistics including "average" (the arithmetic mean of the
input data), and the requested percentiles in format "p50", "p90", "p99", etc.
Source code in llmeter/utils.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |