flytekit.Resources#

class flytekit.Resources(cpu=None, mem=None, gpu=None, ephemeral_storage=None)[source]#

This class is used to specify both resource requests and resource limits.

Resources(cpu="1", mem="2048")  # This is 1 CPU and 2 KB of memory
Resources(cpu="100m", mem="2Gi")  # This is 1/10th of a CPU and 2 gigabytes of memory
Resources(cpu=0.5, mem=1024) # This is 500m CPU and 1 KB of memory

# For Kubernetes-based tasks, pods use ephemeral local storage for scratch space, caching, and for logs.
# This allocates 1Gi of such local storage.
Resources(ephemeral_storage="1Gi")

Note

Persistent storage is not currently supported on the Flyte backend.

Please see the User Guide for detailed examples. Also refer to the K8s conventions.

Methods

Parameters:
classmethod from_dict(d, *, dialect=None)#
classmethod from_json(data, decoder=<function loads>, **from_dict_kwargs)#
Parameters:
Return type:

T

to_dict()#
to_json(encoder=<function dumps>, **to_dict_kwargs)#
Parameters:
Return type:

str | bytes | bytearray

Attributes

cpu: str | int | float | None = None
ephemeral_storage: str | int | None = None
gpu: str | int | None = None
mem: str | int | None = None