Size

class aws_cdk.core.Size(*args: Any, **kwargs)

Bases: object

Represents the amount of digital storage.

The amount can be specified either as a literal value (e.g: 10) which cannot be negative, or as an unresolved number token.

When the amount is passed as a token, unit conversion is not possible.

ExampleMetadata

infused

Example:

tasks.SageMakerCreateTrainingJob(self, "TrainSagemaker",
    training_job_name=sfn.JsonPath.string_at("$.JobName"),
    algorithm_specification=tasks.AlgorithmSpecification(
        algorithm_name="BlazingText",
        training_input_mode=tasks.InputMode.FILE
    ),
    input_data_config=[tasks.Channel(
        channel_name="train",
        data_source=tasks.DataSource(
            s3_data_source=tasks.S3DataSource(
                s3_data_type=tasks.S3DataType.S3_PREFIX,
                s3_location=tasks.S3Location.from_json_expression("$.S3Bucket")
            )
        )
    )],
    output_data_config=tasks.OutputDataConfig(
        s3_output_location=tasks.S3Location.from_bucket(s3.Bucket.from_bucket_name(self, "Bucket", "mybucket"), "myoutputpath")
    ),
    resource_config=tasks.ResourceConfig(
        instance_count=1,
        instance_type=ec2.InstanceType(sfn.JsonPath.string_at("$.InstanceType")),
        volume_size=Size.gibibytes(50)
    ),  # optional: default is 1 instance of EC2 `M4.XLarge` with `10GB` volume
    stopping_condition=tasks.StoppingCondition(
        max_runtime=Duration.hours(2)
    )
)

Methods

to_gibibytes(*, rounding=None)

Return this storage as a total number of gibibytes.

Parameters

rounding (Optional[SizeRoundingBehavior]) – How conversions should behave when it encounters a non-integer result. Default: SizeRoundingBehavior.FAIL

Return type

Union[int, float]

Returns

the quantity of bytes expressed in gibibytes

to_kibibytes(*, rounding=None)

Return this storage as a total number of kibibytes.

Parameters

rounding (Optional[SizeRoundingBehavior]) – How conversions should behave when it encounters a non-integer result. Default: SizeRoundingBehavior.FAIL

Return type

Union[int, float]

Returns

the quantity of bytes expressed in kibibytes

to_mebibytes(*, rounding=None)

Return this storage as a total number of mebibytes.

Parameters

rounding (Optional[SizeRoundingBehavior]) – How conversions should behave when it encounters a non-integer result. Default: SizeRoundingBehavior.FAIL

Return type

Union[int, float]

Returns

the quantity of bytes expressed in mebibytes

to_pebibytes(*, rounding=None)

Return this storage as a total number of pebibytes.

Parameters

rounding (Optional[SizeRoundingBehavior]) – How conversions should behave when it encounters a non-integer result. Default: SizeRoundingBehavior.FAIL

Return type

Union[int, float]

Returns

the quantity of bytes expressed in pebibytes

to_tebibytes(*, rounding=None)

Return this storage as a total number of tebibytes.

Parameters

rounding (Optional[SizeRoundingBehavior]) – How conversions should behave when it encounters a non-integer result. Default: SizeRoundingBehavior.FAIL

Return type

Union[int, float]

Returns

the quantity of bytes expressed in tebibytes

Static Methods

classmethod gibibytes(amount)

Create a Storage representing an amount gibibytes.

1 GiB = 1024 MiB

Parameters

amount (Union[int, float]) – the amount of gibibytes to be represented.

Return type

Size

Returns

a new Size instance

classmethod kibibytes(amount)

Create a Storage representing an amount kibibytes.

1 KiB = 1024 bytes

Parameters

amount (Union[int, float]) – the amount of kibibytes to be represented.

Return type

Size

Returns

a new Size instance

classmethod mebibytes(amount)

Create a Storage representing an amount mebibytes.

1 MiB = 1024 KiB

Parameters

amount (Union[int, float]) – the amount of mebibytes to be represented.

Return type

Size

Returns

a new Size instance

classmethod pebibyte(amount)

(deprecated) Create a Storage representing an amount pebibytes.

1 PiB = 1024 TiB

Parameters

amount (Union[int, float]) –

Deprecated

use pebibytes instead

Stability

deprecated

Return type

Size

classmethod pebibytes(amount)

Create a Storage representing an amount pebibytes.

1 PiB = 1024 TiB

Parameters

amount (Union[int, float]) – the amount of pebibytes to be represented.

Return type

Size

Returns

a new Size instance

classmethod tebibytes(amount)

Create a Storage representing an amount tebibytes.

1 TiB = 1024 GiB

Parameters

amount (Union[int, float]) – the amount of tebibytes to be represented.

Return type

Size

Returns

a new Size instance