[![mansa-ci-pipeline](https://github.com/b2impact/mansa/actions/workflows/ci-pipeline.yaml/badge.svg)](https://github.com/b2impact/mansa/actions/workflows/ci-pipeline.yaml)![Python Versions](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12-blue)[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)[![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)
# Mansa - a FinOps friendly linter
<p align="center">
<img src="/docs/images/meme.jpg">
</p>
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](https://en.wikipedia.org/wiki/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](https://www.techtarget.com/searchcio/news/366570542/Cloud-costs-continue-to-rise-in-2024#:~:text=The%20cloud%20inflation%20trend%20looks,pattern%20of%20rising%20cloud%20costs.).
# Usage guide
Just run:
``` bash
mansa --directory .
mansa --file mypythonfile.py
```
If you want to use your custom config.toml file you can use:
``` bash
mansa --directory . --config myfile.toml
mansa --file mypythonfile.py --config myfile.toml
```
# Build Instructions
1. Install poetry via the [oficial installer](https://python-poetry.org/docs/#installing-with-the-official-installer):
``` bash
curl -sSL https://install.python-poetry.org | python3 -
```
2. Clone this repository with:
``` bash
git clone https://github.com/b2impact/mansa.git
```
3. Ensure poetry is using the correct virtual environment. You can activate the environment manually with:
``` bash
poetry shell
```
4. Install dependencies and build the package:
``` bash
poetry install
```
5. Build the package:
``` bash
poetry build
```
# Development guidelines
As usual, we stick to [TBD](https://trunkbaseddevelopment.com/), 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:
``` bash
poetry run pytest
```
Or to run multiversion tests with linting included:
``` bash
poetry run tox
```
To install tox we recommend using pipx as:
``` bash
pipx install tox
```
### Introducing dependencies
Please install dependencies via:
``` bash
poetry 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
Raw data
{
"_id": null,
"home_page": "https://github.com/b2impact/mansa/tree/main",
"name": "mansa",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": "linter, python, ast",
"author": "Edgar Bahilo",
"author_email": "edgar.bahilo@b2-impact.com",
"download_url": "https://files.pythonhosted.org/packages/42/1c/067a13fbe6d554f4814f7d812fbb9263b8e0ddf34e92a3fb386d5486c60e/mansa-0.1.2.tar.gz",
"platform": null,
"description": "[![mansa-ci-pipeline](https://github.com/b2impact/mansa/actions/workflows/ci-pipeline.yaml/badge.svg)](https://github.com/b2impact/mansa/actions/workflows/ci-pipeline.yaml)![Python Versions](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12-blue)[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)[![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)\n\n# Mansa - a FinOps friendly linter\n\n<p align=\"center\">\n<img src=\"/docs/images/meme.jpg\">\n</p>\n\nFinOps 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.\n\nFinOps 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.\n\nAll 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.\n\nMansa 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.\n\n# Why Mansa?\n\nUsually 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.\n\nBesides 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.\n\nBecause 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.\n\nMansa 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.\n\n## Why this name?\n\n[Mansa Musa](https://en.wikipedia.org/wiki/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](https://www.techtarget.com/searchcio/news/366570542/Cloud-costs-continue-to-rise-in-2024#:~:text=The%20cloud%20inflation%20trend%20looks,pattern%20of%20rising%20cloud%20costs.).\n\n# Usage guide\n\nJust run: \n\n``` bash\nmansa --directory .\nmansa --file mypythonfile.py\n```\nIf you want to use your custom config.toml file you can use:\n\n``` bash\nmansa --directory . --config myfile.toml\nmansa --file mypythonfile.py --config myfile.toml\n```\n\n# Build Instructions\n\n1. Install poetry via the [oficial installer](https://python-poetry.org/docs/#installing-with-the-official-installer):\n\n ``` bash\n curl -sSL https://install.python-poetry.org | python3 -\n ```\n\n2. Clone this repository with:\n\n ``` bash\n git clone https://github.com/b2impact/mansa.git\n ```\n3. Ensure poetry is using the correct virtual environment. You can activate the environment manually with:\n\n ``` bash\n poetry shell\n ```\n\n4. Install dependencies and build the package:\n\n ``` bash\n poetry install\n ```\n\n5. Build the package:\n\n ``` bash\n poetry build\n ```\n\n# Development guidelines\n\nAs usual, we stick to [TBD](https://trunkbaseddevelopment.com/), Create your own branch according to the following guidelines:\n\n- {type_of_branch}/{namefirstlettersurnamefirstlettersurnamesecondletter}/{change_name}\n\n- Being type of branch:\n\n - feat (of feature).\n\n - bugfix/fix (to fix a bug).\n\n - enh/improvement (for enhancement, usually runtime performance).\n\n### Run tests\n\nTo run the tests, run the following in the root directory of the project:\n\n``` bash\npoetry run pytest\n```\n\nOr to run multiversion tests with linting included:\n\n``` bash\npoetry run tox\n```\n\nTo install tox we recommend using pipx as:\n\n``` bash\npipx install tox\n```\n\n### Introducing dependencies\n\nPlease install dependencies via:\n\n``` bash\npoetry add {dependency-name}=={version}\n```\n\nWhen doing that your pyproject.toml file will be automatically updated as well as the lock files.\n\n### References\n\n\\[1\\] Goodwin, A. J. H. (1957). The Medieval Empire of Ghana. *The South African Archaeological Bulletin*, *12*(47), 108\u2013112. https://doi.org/10.2307/3886971\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Making your CCoE happy",
"version": "0.1.2",
"project_urls": {
"Homepage": "https://github.com/b2impact/mansa/tree/main",
"Repository": "https://github.com/b2impact/mansa/tree/main"
},
"split_keywords": [
"linter",
" python",
" ast"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "289fc4b20a7afcaa87fab69dd2f1edd98283de7f2ffbba38291afb17edf93d1e",
"md5": "015e8366c40a6b1233e5cff9bf79d4eb",
"sha256": "64cc451b5d19b7a9074d2f2b092bea7c4aa54656be638c875d17ce08478e3bd0"
},
"downloads": -1,
"filename": "mansa-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "015e8366c40a6b1233e5cff9bf79d4eb",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 8708,
"upload_time": "2024-08-17T09:12:20",
"upload_time_iso_8601": "2024-08-17T09:12:20.989590Z",
"url": "https://files.pythonhosted.org/packages/28/9f/c4b20a7afcaa87fab69dd2f1edd98283de7f2ffbba38291afb17edf93d1e/mansa-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "421c067a13fbe6d554f4814f7d812fbb9263b8e0ddf34e92a3fb386d5486c60e",
"md5": "06f760b153c93bcbe3b965960866a3bd",
"sha256": "bf45b7d55c790bd4ddb0bc553e0204dbcc4e94c56c47f15495937d18573a79a5"
},
"downloads": -1,
"filename": "mansa-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "06f760b153c93bcbe3b965960866a3bd",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 8457,
"upload_time": "2024-08-17T09:12:22",
"upload_time_iso_8601": "2024-08-17T09:12:22.204929Z",
"url": "https://files.pythonhosted.org/packages/42/1c/067a13fbe6d554f4814f7d812fbb9263b8e0ddf34e92a3fb386d5486c60e/mansa-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-17 09:12:22",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "b2impact",
"github_project": "mansa",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "mansa"
}