@@ -95,21 +95,33 @@ def ref(self) -> Dict[str, str]:
95
95
96
96
@attr .s
97
97
class CacheConfig :
98
- """Step to cache pipeline workflow.
98
+ """Configure steps to enable cache in pipeline workflow.
99
+
100
+ If caching is enabled, the pipeline attempts to find a previous execution of a step.
101
+ If a successful previous execution is found, the pipeline propagates the values
102
+ from previous execution rather than recomputing the step.
103
+
99
104
100
105
Attributes:
101
- enable_caching (bool): To enable step caching. Off by default .
106
+ enable_caching (bool): To enable step caching. Defaults to `False` .
102
107
expire_after (str): If step caching is enabled, a timeout also needs to defined.
103
108
It defines how old a previous execution can be to be considered for reuse.
104
- Needs to be ISO 8601 duration string.
109
+ Value should be an ISO 8601 duration string.
110
+ If step caching is disabled, it defaults to an empty string.
105
111
"""
106
112
107
113
enable_caching : bool = attr .ib (default = False )
108
- expire_after : str = attr .ib (factory = str )
114
+ expire_after = attr .ib (default = "" )
115
+
116
+ @expire_after .validator
117
+ def validate_expire_after (self , enable_caching , expire_after ):
118
+ """Validates ISO 8601 duration string."""
119
+ if enable_caching and expire_after == "" :
120
+ raise ValueError ("expire_after must be an ISO 8601 duration string" )
109
121
110
122
@property
111
123
def config (self ):
112
- """Enables caching in pipeline steps."""
124
+ """Configures caching in pipeline steps."""
113
125
return {"CacheConfig" : {"Enabled" : self .enable_caching , "ExpireAfter" : self .expire_after }}
114
126
115
127
@@ -132,7 +144,7 @@ def __init__(
132
144
name (str): The name of the training step.
133
145
estimator (EstimatorBase): A `sagemaker.estimator.EstimatorBase` instance.
134
146
inputs (TrainingInput): A `sagemaker.inputs.TrainingInput` instance. Defaults to `None`.
135
- cache_config (CacheConfig): A `sagemaker.steps.CacheConfig` instance to enable caching .
147
+ cache_config (CacheConfig): A `sagemaker.workflow. steps.CacheConfig` instance.
136
148
"""
137
149
super (TrainingStep , self ).__init__ (name , StepTypeEnum .TRAINING )
138
150
self .estimator = estimator
@@ -249,7 +261,7 @@ def __init__(
249
261
name (str): The name of the transform step.
250
262
transformer (Transformer): A `sagemaker.transformer.Transformer` instance.
251
263
inputs (TransformInput): A `sagemaker.inputs.TransformInput` instance.
252
- cache_config (CacheConfig): An instance to enable caching .
264
+ cache_config (CacheConfig): A `sagemaker.workflow.steps.CacheConfig` instance .
253
265
"""
254
266
super (TransformStep , self ).__init__ (name , StepTypeEnum .TRANSFORM )
255
267
self .transformer = transformer
@@ -331,7 +343,7 @@ def __init__(
331
343
script to run. Defaults to `None`.
332
344
property_files (List[PropertyFile]): A list of property files that workflow looks
333
345
for and resolves from the configured processing output list.
334
- cache_config (CacheConfig): An instance to enable caching .
346
+ cache_config (CacheConfig): A `sagemaker.workflow.steps.CacheConfig` instance .
335
347
"""
336
348
super (ProcessingStep , self ).__init__ (name , StepTypeEnum .PROCESSING )
337
349
self .processor = processor
0 commit comments