This release is a pre-release and may not be stable for production use.
✨Abstract✨ metrics
A lightweight framework for defining arbitrary business metrics as Python code.
Installation
pip install abstract-metrics
Basic Usage
- Install
- Subclass one of the metric types (e.g. ApplicationMetricBoolean)
- Add an optimistic
computemethod that returns your metric. - Register a runner with your metric and run it!
Example
Let's say you want to write a metric that checks if one of your applications follows your organizations application naming standards. We will use the ApplicationMetricBoolean type to do this. All metrics are formated as {subject}Metric{type}. In this case, our subject is an Application and our type is Boolean.
Because Applications are our subject, we need to subclass ApplicationMetricBoolean. This class has a few methods that we can use to help us compute our metric. The most important one is compute. This method is called by the runner and should return a the boolean value. Additionally, we should use the application property (via the Application wrapper) to store any context we need to compute this metric.
from metric import Application, ApplicationMetric
from metric.utils import MatrixRunner
from metric.types import OutputFormat
def main():
# Construct list of basic Application objects
apps = [Application(app) for app in ["myorg-sales-app", "sandbox-dinasour"]]
# Construct a list of our metrics
metrics = [AppNameCompliance]
# This will not only construct our Application Metrics but it will also execute
# them and print them to stdout as a table.
MatrixRunner(format=OutputFormat.OUTPUT_FORMAT_TABLE).run(apps, metrics)
class AppNameCompliance(ApplicationMetricBoolean):
r"""All Application names should start with 'myorg-'."""
def compute(self):
if self.application.name.startswith("myorg-"):
return True
return False
If we run this code, we'll get the following output:
Application AppNameCompliance
myorg-finance-app True
myorg-marketing-service True
myorg-sales-app True
sandbox-dinasour False
Metadata
Release files for abstract-metrics 0.1.0.dev5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| abstract_metrics-0.1.0.dev5.tar.gz | 4.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| abstract_metrics-0.1.0.dev5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.8 kB
Release files / abstract_metrics-0.1.0.dev5.tar.gz
| Download URL | abstract_metrics-0.1.0.dev5.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6553940b042de28af9de81806b097e42ef266d20c2686f910eed63e8eb08c2d3
|
|
BLAKE2b-256 checksum How to use checksums |
cf71ebfa962556c84b9f6f8d403e58904a6e63cdd83d587464c768e915010199
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.11.5 Linux/6.2.0-1011-azure
|
Release files / abstract_metrics-0.1.0.dev5-py3-none-any.whl
| Download URL | abstract_metrics-0.1.0.dev5-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fbf3486a8d8fc784c4d4bf0b9c821fc8e13afcc0bdaf67482d1203f38da11405
|
|
BLAKE2b-256 checksum How to use checksums |
0919f5bc5d4eba1943429f1d6f17274f5384b98a4b2586a5de6f07d6b1d2d005
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.11.5 Linux/6.2.0-1011-azure
|
Security for abstract-metrics 0.1.0.dev5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.