Mansa - a FinOps friendly linter
FinOps is an operational framework and cultural practice that enhances the business value derived from cloud technology. It promotes data-driven decision-making in a timely manner and fosters financial responsibility. It gets achieved through collaboration among engineering, finance, and business teams.
FinOps is a discipline that combines financial management principles with cloud engineering and operations to provide organizations with a better understanding of their cloud spending. It also helps them make informed decisions on how to allocate and manage their cloud costs. The goal of FinOps isn't to save money, but to maximize revenue or business value through the cloud. It helps to enable organizations to control cloud spending while maintaining the level of performance, reliability, and security needed to support their business operations.
All of the cloud service providers also allow for the use of tags which can be applied as metadata to most individual resources, and which then appear in the detailed billing reports providing cost and usage data when turned on by the user. Tagging is an essential pre-requirement for FinOps implementation.
Mansa is a lintin tool used internally at B2-Impact to enforce cost-tagging at build time as part of our standard CI-CD pipelines for Azure Machine Learning Resources.
Why Mansa?
Usually IOps teams deploy their infrastructure using terraform/bicep/cdk languages. However in most of the cases the IOps teams are only in charge of deploying the infrastructure "container" that an application will use. In the case of Machine Learning this situation is even more common as the recursive experimental nature of AI applications makes quite common the fact that we do not know which deployment configuration will be best during the development phase.
Besides a lot of MLOps processes as creation of ML pipelines, compute clusters, job launching, inference endpoints etc... are invoked via python SDKs and not terraform code.
Because of that we decided to create Mansa. Mansa scans all your python code in search of classes that accept the tags arguments, currently these classes are configurable with a config.toml file as we have not been able to come up with a better method that is as simple as this.
Mansa also looks that the tags contains a certain key-value pairs with allowed values. Currently this is hardcoded in the code but we plan to make this configurable via a section in the config.toml file.
Why this name?
Mansa Musa was the 9th Mansa of the Mali Empire, he was one of the richest people in history. According to some research [1] he was so rich that he was generating inflation wherever he went. His wealth was not measurable and therefore neither his spending. We took inspiration of his story for the naming of this package as we believe that is important to keep track of cost and we do not want to contribute to the cloud cost inflation phenomena.
Usage guide
Just run:
mansa --directory .
mansa --file mypythonfile.py
If you want to use your custom config.toml file you can use:
mansa --directory . --config myfile.toml
mansa --file mypythonfile.py --config myfile.toml
Build Instructions
-
Install uv via the official installer:
curl -LsSf https://astral.sh/uv/install.sh | sh
-
Clone this repository with:
git clone https://github.com/b2impact/mansa.git
-
Install dependencies and build the package:
uv pip install -e ".[dev]"
-
Generate the lock file if it does not exist:
uv pip compile pyproject.toml -o uv.lock
Development guidelines
As usual, we stick to TBD, Create your own branch according to the following guidelines:
-
{type_of_branch}/{namefirstlettersurnamefirstlettersurnamesecondletter}/{change_name}
-
Being type of branch:
-
feat (of feature).
-
bugfix/fix (to fix a bug).
-
enh/improvement (for enhancement, usually runtime performance).
-
Run tests
To run the tests, run the following in the root directory of the project:
uv run pytest
Or to run multiversion tests with linting included:
tox
To install tox and run it with uv you will need tox-uv and tox:
uv pip install tox tox-uv
Introducing dependencies
Please install dependencies via:
uv add {dependency-name}=={version}
When doing that your pyproject.toml file will be automatically updated as well as the lock files.
References
[1] Goodwin, A. J. H. (1957). The Medieval Empire of Ghana. The South African Archaeological Bulletin, 12(47), 108–112. https://doi.org/10.2307/3886971
Metadata
Release files for mansa 0.2.0
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 | Actions |
|---|---|---|---|---|
| mansa-0.2.0.tar.gz | 9.4 kB | With provenance | Details for mansa-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mansa-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for mansa-0.2.0-py3-none-any.whl |
Total release size: 17.4 kB
Release files / mansa-0.2.0.tar.gz
| Download URL | mansa-0.2.0.tar.gz |
|---|---|
| Size | 9.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1fa43a7ec8da128228593cd6ff242532d85bb965b0cb75cf6134a1ad4891a188
|
|
BLAKE2b-256 checksum How to use checksums |
40cfe8f73360594e2e383037c6acc4d2c31f982346153f17043e03bd530dcf5d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 4, 2025.
Transparency logRelease files / mansa-0.2.0-py3-none-any.whl
| Download URL | mansa-0.2.0-py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
aec06162798fb2a9d1a29ec8d372a5c0c3fd83a798df6e45672aef61b74245b8
|
|
BLAKE2b-256 checksum How to use checksums |
ed7dbd4305fb928ef369ce5c6d9b708839047d4bfad223e3e15e0725fc2c7116
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 4, 2025.
Transparency logSecurity for mansa 0.2.0
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for mansa-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 4, 2025.
Transparency logA 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.