toil.lib.ec2nodes

Module Contents

Classes

InstanceType

Functions

isNumber(s)

Determines if a unicode string (that may include commas) is a number.

parseStorage(storageData)

Parses EC2 JSON storage param string into a number.

parseMemory(memAttribute)

Returns EC2 'memory' string as a float.

fetchEC2Index(filename)

Downloads and writes the AWS Billing JSON to a file using the AWS pricing API.

fetchEC2InstanceDict(awsBillingJson, region)

Takes a JSON and returns a list of InstanceType objects representing EC2 instance params.

updateStaticEC2Instances()

Generates a new python file of fetchable EC2 Instances by region with current prices and specs.

Attributes

logger

dirname

EC2Regions

toil.lib.ec2nodes.logger
toil.lib.ec2nodes.dirname
toil.lib.ec2nodes.EC2Regions
class toil.lib.ec2nodes.InstanceType(name, cores, memory, disks, disk_capacity, architecture)[source]
Parameters
__slots__ = ('name', 'cores', 'memory', 'disks', 'disk_capacity', 'architecture')
__str__()[source]

Return str(self).

Return type

str

__eq__(other)[source]

Return self==value.

Parameters

other (object) –

Return type

bool

toil.lib.ec2nodes.isNumber(s)[source]

Determines if a unicode string (that may include commas) is a number.

Parameters

s (str) – Any unicode string.

Returns

True if s represents a number, False otherwise.

Return type

bool

toil.lib.ec2nodes.parseStorage(storageData)[source]

Parses EC2 JSON storage param string into a number.

Examples:

“2 x 160 SSD” “3 x 2000 HDD” “EBS only” “1 x 410” “8 x 1.9 NVMe SSD” “900 GB NVMe SSD”

Parameters

storageData (str) – EC2 JSON storage param string.

Returns

Two floats representing: (# of disks), and (disk_capacity in GiB of each disk).

Return type

Union[List[int], Tuple[Union[int, float], float]]

toil.lib.ec2nodes.parseMemory(memAttribute)[source]

Returns EC2 ‘memory’ string as a float.

Format should always be ‘#’ GiB (example: ‘244 GiB’ or ‘1,952 GiB’). Amazon loves to put commas in their numbers, so we have to accommodate that. If the syntax ever changes, this will raise.

Parameters

memAttribute (str) – EC2 JSON memory param string.

Returns

A float representing memory in GiB.

Return type

float

toil.lib.ec2nodes.fetchEC2Index(filename)[source]

Downloads and writes the AWS Billing JSON to a file using the AWS pricing API.

See: https://aws.amazon.com/blogs/aws/new-aws-price-list-api/

Returns

A dict of InstanceType objects, where the key is the string: aws instance name (example: ‘t2.micro’), and the value is an InstanceType object representing that aws instance name.

Parameters

filename (str) –

Return type

None

toil.lib.ec2nodes.fetchEC2InstanceDict(awsBillingJson, region)[source]

Takes a JSON and returns a list of InstanceType objects representing EC2 instance params.

Parameters
  • region (str) –

  • awsBillingJson (Dict[str, Any]) –

Returns

Return type

Dict[str, InstanceType]

toil.lib.ec2nodes.updateStaticEC2Instances()[source]

Generates a new python file of fetchable EC2 Instances by region with current prices and specs.

Takes a few (~3+) minutes to run (you’ll need decent internet).

Returns

Nothing. Writes a new ‘generatedEC2Lists.py’ file.

Return type

None