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, so you can install it directly with pip.

pip install finoptim

It requires at least Python 3.10. The documentation is available on readthedoc at : xxxxxx (not possible with a private repo)

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(
    index=False,
    tablefmt='rounded_outline',
    numalign='center'))
>>>
╭────────────┬──────────────┬─────────────────┬──────────────╮
  Arlequin    Moratorium    Anthropophage    Apophtegme  
├────────────┼──────────────┼─────────────────┼──────────────┤
   0.167        0.122          0.0056          0.0058    
   0.073        0.054          0.0025          0.0026    
 0.0637352    0.0476682       0.0022035      0.00234155  
╰────────────┴──────────────┴─────────────────┴──────────────╯

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
current_reservations = pd.DataFrame(...) # some query of yours

res = fp.optimise_past(predictions, prices, current_reservations)

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

  • possibility to precise the period of the data in case it is not inferred correctly
  • coverage must follow the same inputs as cost
  • allow for long DataFrame as input
  • the cost function should return a gradient when evaluated (save some compute)
  • need to listen to keyboard interupt from Rust (harder than expected with multi threading)

actual problems

  • add in documentation that for now optimisation only works if you have RI < SP < OD
  • compute the better step size to avoid waiting too long (more or less done, but not even necessary with the inertial optimiser)
  • 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

if the problem is $f(w) = \frac{1}{2} w^T A w :-: b^T w$ then the optimal parameters for the inertial optimiser are :

$$ \alpha = \left(\frac{2}{\sqrt{\lambda_1} + \sqrt{\lambda_n}} \right) ^2 $$

$$ \beta = \left( \frac{\sqrt{\lambda_n} - \sqrt{\lambda_1}}{\sqrt{\lambda_1} + \sqrt{\lambda_n}} \right) ^2 $$

with $\lambda_1$ and $\lambda_n$ respectively the smallest and largest eigenvalues of $A$

lets admit constant usage for all the instances. Then $f(w) = $

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.2.tar.gz (29.7 kB view hashes)

Uploaded Source

Built Distributions

finoptim-0.1.2-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.2-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.3 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

finoptim-0.1.2-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.2-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.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.3 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

finoptim-0.1.2-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.2-cp311-none-win_amd64.whl (375.8 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

finoptim-0.1.2-cp311-none-win32.whl (333.1 kB view hashes)

Uploaded CPython 3.11 Windows x86

finoptim-0.1.2-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.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.3 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

finoptim-0.1.2-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.2-cp311-cp311-macosx_11_0_arm64.whl (483.1 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

finoptim-0.1.2-cp311-cp311-macosx_10_7_x86_64.whl (534.1 kB view hashes)

Uploaded CPython 3.11 macOS 10.7+ x86-64

finoptim-0.1.2-cp310-none-win_amd64.whl (375.8 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

finoptim-0.1.2-cp310-none-win32.whl (333.1 kB view hashes)

Uploaded CPython 3.10 Windows x86

finoptim-0.1.2-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.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.3 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

finoptim-0.1.2-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.2-cp310-cp310-macosx_11_0_arm64.whl (483.1 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

finoptim-0.1.2-cp310-cp310-macosx_10_7_x86_64.whl (534.1 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