Skip to main content

A small package to do some finops optimisations

Project description

FinOptim package

The best python package to help you optimise your cloud spendings

Instalation

The package is available on PyPI, it is possible to install it directly with pip.

pip install finoptim

It requires at least Python 3.10. The documentation is available on readthedoc.

Usage example

import finoptim as fp
import pandas as pd


past_usage = pd.DataFrame(...) # some query of yours
prices = fp.prices.aws()
print(prices_df.iloc[:, :4].to_markdown(
    tablefmt='rounded_outline',
    numalign='center'))
>>>
╭──────┬────────────┬──────────────┬─────────────────┬──────────────╮
        Arlequin    Moratorium    Anthropophage    Apophtegme  
├──────┼────────────┼──────────────┼─────────────────┼──────────────┤
 OD      0.167        0.122          0.0056          0.0058    
 RI3Y  0.0637352    0.0476682       0.0022035      0.00234155  
 RI1Y  0.0981063    0.0716404      0.00330824      0.00330824  
 SP1Y    0.115         0.09          0.0038          0.0039    
 SP3Y    0.073        0.054          0.0025          0.0026    
╰──────┴────────────┴──────────────┴─────────────────┴──────────────╯

All the prices are per hours.

Proceeding to the optimisation is made with the optimise function

res = fp.optimise(past_usage, prices)

The optimise function can take as input lots of different predictions, and also current commitments. The optimisation is made with all the pricing models found in the prices object

predictions = [pd.DataFrame(...), ...] # some query of yours

res = fp.optimise(
    predictions,
    prices,
    current_commitments={"type" : "RI3Y", "level" : 10 * 32, 'guid' : 'Moule à gaufres', "end_date" : date(2024, 12, 21), 'price_key' : .0123},
    convergence_details=True
    )

Now the res object hold the best levels of commitment on the time period.

guid_to_instance_name = {"K7YHHNFGTNN2DP28" : 'i3.large', 'SAHHHV5TXVX4DCTS' : 'r5.large'}
res.format(instance_type=guid_to_instance_name)
print(res)
>>>
╭─────────────────┬──────────────────────────┬───────────────╮
 instance_type     three_year_commitments   price_per_day 
├─────────────────┼──────────────────────────┼───────────────┤
 i3.large                   1338                2,886     
 r5.large                   1570                2,564     
 savings plans              1937                1,937     
╰─────────────────┴──────────────────────────┴───────────────╯

TODO

lib convenience

  • allow for long DataFrame as input
  • the cost function should return a gradient when evaluated (save some compute)(the function is a nightmare : abort the mission)
  • listening to keyboard interupt from Rust is harder than expected with multi threading
  • logging instead of printing, both in the Python and Rust sides

actual problems

  • find a real stop condition for the inertial optimiser
  • can we guess the "eigenvectors" of the problem ? if we have estimations, we can set great parameters for the inertial optimiser
  • problem is highly non linear and this will require more thinking

Project size

wc -l src/finoptim/*.py rust/src/*.rs src/finoptim/prices/*.py tests/*.py

is around 3k lines of code

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

finoptim-0.1.72.tar.gz (32.9 kB view hashes)

Uploaded Source

Built Distributions

finoptim-0.1.72-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.4 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

finoptim-0.1.72-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.4 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

finoptim-0.1.72-pp310-pypy310_pp73-manylinux_2_12_i686.manylinux2010_i686.whl (1.4 MB view hashes)

Uploaded PyPy manylinux: glibc 2.12+ i686

finoptim-0.1.72-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.4 MB view hashes)

Uploaded CPython 3.13 manylinux: glibc 2.17+ ARM64

finoptim-0.1.72-cp312-none-win_amd64.whl (397.4 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

finoptim-0.1.72-cp312-none-win32.whl (350.1 kB view hashes)

Uploaded CPython 3.12 Windows x86

finoptim-0.1.72-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.4 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

finoptim-0.1.72-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.4 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

finoptim-0.1.72-cp312-cp312-manylinux_2_12_i686.manylinux2010_i686.whl (1.4 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.12+ i686

finoptim-0.1.72-cp311-none-win_amd64.whl (398.1 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

finoptim-0.1.72-cp311-none-win32.whl (351.7 kB view hashes)

Uploaded CPython 3.11 Windows x86

finoptim-0.1.72-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.4 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

finoptim-0.1.72-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.4 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

finoptim-0.1.72-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.whl (1.4 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.12+ i686

finoptim-0.1.72-cp311-cp311-macosx_11_0_arm64.whl (497.9 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

finoptim-0.1.72-cp311-cp311-macosx_10_7_x86_64.whl (553.5 kB view hashes)

Uploaded CPython 3.11 macOS 10.7+ x86-64

finoptim-0.1.72-cp310-none-win_amd64.whl (398.1 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

finoptim-0.1.72-cp310-none-win32.whl (351.7 kB view hashes)

Uploaded CPython 3.10 Windows x86

finoptim-0.1.72-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.4 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

finoptim-0.1.72-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.4 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

finoptim-0.1.72-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.whl (1.4 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.12+ i686

finoptim-0.1.72-cp310-cp310-macosx_11_0_arm64.whl (497.9 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

finoptim-0.1.72-cp310-cp310-macosx_10_7_x86_64.whl (553.5 kB view hashes)

Uploaded CPython 3.10 macOS 10.7+ x86-64

Supported by

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