Resources
The hera.workflows.resources module provides the Resources class for setting CPU, memory and other limits.
Resources
A representation of a collection of resources that are requested to be consumed by a task for execution.
This follow the K8S definition for resources.
Attributes:
| Name | Type | Description |
|---|---|---|
cpu_request |
Optional[Union[float, int, str]]
|
The number of CPUs to request, either as a fraction (millicpu), whole number, or a string. |
cpu_limit |
Optional[Union[float, int, str]]
|
The limit of CPUs to request, either as a fraction (millicpu), whole number, or a string. |
memory_request |
Optional[str]
|
The amount of memory to request. |
memory_limit |
Optional[str]
|
The memory limit of the pod. |
ephemeral_request |
Optional[str]
|
The amount of ephemeral storage to request. |
ephemeral_limit |
Optional[str]
|
The ephemeral storage limit of the pod. |
gpus |
Optional[Union[int, str]]
|
The number of GPUs to request. |
gpu_flag |
Optional[str]
|
The GPU flag to use for identifying how many GPUs to mount to a pod. This is dependent on the cloud provider. |
custom_resources |
Optional[Dict]
|
Any custom resources to request. This is dependent on the cloud provider. |
Notes
Most of the fields that support a union of int and str support either specifying a number for the resource,
such as 1 CPU, 2 GPU, etc., a str representation of that numerical resource, such as ‘1’ CPU, ‘2’ GPU, etc., but
also supports specifying a to be computed value, such as {{inputs.parameters.cpu_request}}. This means tasks,
steps, etc., can be stitched together in a way to have a task/step that computes the resource requirements, and
then outputs them to the next step/task.
Source code in src/hera/workflows/resources.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
build
Builds the resource requirements of the pod.