Skip to main content

Making your CCoE happy

Project description

mansa-cd-pipeline

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

  1. Install uv via the official installer:

    curl -LsSf https://astral.sh/uv/install.sh | sh
    
  2. Clone this repository with:

    git clone https://github.com/b2impact/mansa.git
    
  3. Install dependencies and build the package:

    uv pip install -e ".[dev]"
    
  4. 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mansa-0.2.0.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mansa-0.2.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file mansa-0.2.0.tar.gz.

File metadata

  • Download URL: mansa-0.2.0.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mansa-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1fa43a7ec8da128228593cd6ff242532d85bb965b0cb75cf6134a1ad4891a188
MD5 c20431d778dce4256d37561e2e250596
BLAKE2b-256 40cfe8f73360594e2e383037c6acc4d2c31f982346153f17043e03bd530dcf5d

See more details on using hashes here.

Provenance

The following attestation bundles were made for mansa-0.2.0.tar.gz:

Publisher: cd-pipeline.yaml on b2impact/mansa

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mansa-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: mansa-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mansa-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aec06162798fb2a9d1a29ec8d372a5c0c3fd83a798df6e45672aef61b74245b8
MD5 4ba69237d350721a763155fbc2a7bc7a
BLAKE2b-256 ed7dbd4305fb928ef369ce5c6d9b708839047d4bfad223e3e15e0725fc2c7116

See more details on using hashes here.

Provenance

The following attestation bundles were made for mansa-0.2.0-py3-none-any.whl:

Publisher: cd-pipeline.yaml on b2impact/mansa

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page