Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

ec2-compare

PyPI - ec2-compare PyPI - Python Version Coverage PyPI - Downloads

Compare EC2 instances families without querying AWS API

Example:

  • Getting on instances by parameters
import ec2_compare.mixin
req = ec2_compare.mixin.EmrRequestMixin().ec3__get_machines(
    max_instances=5, # maximum number of machines
    # reuest parameters
    **{
        'cpu': 40, 'ram': 786432, 'min_cpu': 8, 'min_ram': 65536,
        'InstanceType': ['c4', 'c5.', 'r4', 'r5.', 'm4', 'm5.'],
        'SupportedArchitectures': ['x86_64'], 'SupportedUsageClasses': 'spot'
    })
  • Getting on instances suitable for on-demand
>>> import ec2_compare.internal.on_demand
>>> ec2_compare.internal.on_demand.get_instances_dict()[0]['InstanceType']
'm5d.xlarge'

Why it's more memory & CPU efficient

1). ec2-compare

  • Memory (penalty 8.1 Mb - 8175616 bytes)
>>>
def getCurrentMemoryUsage():
    ''' Memory usage in Bytes '''
    import psutil
    import os
    process = psutil.Process(os.getpid())
    return process.memory_info().rss
>>> getCurrentMemoryUsage()
9535488
>>> import ec2_compare.ec2data
>>> getCurrentMemoryUsage()
17641472
>>> len(ec2_compare.ec2data.get_instances_dict())
341
>>> getCurrentMemoryUsage()
17711104
  • Load time:
>>> import timeit
>>> timeit.timeit('import ec2_compare.ec2data;len(ec2_compare.ec2data.get_instances_dict())', number=1)
0.0028156930000000635
>>> timeit.timeit('import ec2_compare.ec2data;len(ec2_compare.ec2data.get_instances_dict())', number=1)
0.001711632000002794
>>> timeit.timeit('import ec2_compare.ec2data;len(ec2_compare.ec2data.get_instances_dict())', number=1000)
0.8330168470000032
>>> timeit.timeit('import ec2_compare.ec2data;len(ec2_compare.ec2data.get_instances_dict())', number=1000)
0.8174298469999997

2). Reading from json file:

  • Memory (penalty 2.5 Mb - 2592768 bytes)
>>> getCurrentMemoryUsage()
9379840
>>> import json
>>> with open("./helpers/aws_ec2.json") as json_file:
...     json.load(json_file)
...
>>> getCurrentMemoryUsage()
11972608
  • Load time:
>>> import timeit
>>>
s= '''
import json
with open("./helpers/aws_ec2.json") as json_file:
    json.load(json_file)
'''
timeit.timeit(s, number=1000)
>>
4.628850890999999

Versioning

ec2_compare follows PEP 440.

How to build

python -m pip install -e ./[devel]
# or pip install -e ./[devel]

# Running tests
scripts/tests.sh

Update data Locally

  1. Downland the latest info
aws ec2 describe-instance-types | jq '.InstanceTypes' > aws_ec2.json
  1. repack
python3 repack.py

Thank you

Download files

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

Source Distribution

ec2_compare-1.0.0a9.tar.gz (326.3 kB view details)

Uploaded Source

Built Distribution

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

ec2_compare-1.0.0a9-py3-none-any.whl (461.6 kB view details)

Uploaded Python 3

File details

Details for the file ec2_compare-1.0.0a9.tar.gz.

File metadata

  • Download URL: ec2_compare-1.0.0a9.tar.gz
  • Upload date:
  • Size: 326.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.6

File hashes

Hashes for ec2_compare-1.0.0a9.tar.gz
Algorithm Hash digest
SHA256 7d4a9d5c8f710286d514d6f4935995f5082a508be53e4edadf5f0bc34732c12f
MD5 261a3c812337b34a04959933e2d437fb
BLAKE2b-256 8f1344450e3486d987abebb7cef416768b7286b70af0edd4f173b24e6bd95781

See more details on using hashes here.

File details

Details for the file ec2_compare-1.0.0a9-py3-none-any.whl.

File metadata

  • Download URL: ec2_compare-1.0.0a9-py3-none-any.whl
  • Upload date:
  • Size: 461.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.6

File hashes

Hashes for ec2_compare-1.0.0a9-py3-none-any.whl
Algorithm Hash digest
SHA256 ae7c87942acab8c40fb34bd5ba4689914019859853f44db615981765caa81cde
MD5 418d31dcf5b35ea7e8f84ec08d004cf7
BLAKE2b-256 5cfe2834bf3ae57a57257202ab154391161e14f90d242e5c41d7570383c41cee

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.0a9 This release

2 files

Supported by

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