20
20
KUBERNETES_PERSISTENT_VOLUME_CLAIMS ,
21
21
KUBERNETES_TOLERATIONS ,
22
22
KUBERNETES_SERVICE_ACCOUNT ,
23
+ KUBERNETES_SHARED_MEMORY ,
23
24
)
24
25
from metaflow .plugins .resources_decorator import ResourcesDecorator
25
26
from metaflow .plugins .timeout_decorator import get_run_time_limit_for_task
@@ -87,6 +88,8 @@ class KubernetesDecorator(StepDecorator):
87
88
persistent_volume_claims : Dict[str, str], optional, default None
88
89
A map (dictionary) of persistent volumes to be mounted to the pod for this step. The map is from persistent
89
90
volumes to the path to which the volume is to be mounted, e.g., `{'pvc-name': '/path/to/mount/on'}`.
91
+ shared_memory: int, optional
92
+ Shared memory size (in MiB) required for this step
90
93
"""
91
94
92
95
name = "kubernetes"
@@ -109,6 +112,7 @@ class KubernetesDecorator(StepDecorator):
109
112
"tmpfs_size" : None ,
110
113
"tmpfs_path" : "/metaflow_temp" ,
111
114
"persistent_volume_claims" : None , # e.g., {"pvc-name": "/mnt/vol", "another-pvc": "/mnt/vol2"}
115
+ "shared_memory" : None ,
112
116
}
113
117
package_url = None
114
118
package_sha = None
@@ -194,6 +198,8 @@ def __init__(self, attributes=None, statically_defined=False):
194
198
if not self .attributes ["tmpfs_size" ]:
195
199
# default tmpfs behavior - https://man7.org/linux/man-pages/man5/tmpfs.5.html
196
200
self .attributes ["tmpfs_size" ] = int (self .attributes ["memory" ]) // 2
201
+ if not self .attributes ["shared_memory" ]:
202
+ self .attributes ["shared_memory" ] = KUBERNETES_SHARED_MEMORY
197
203
198
204
# Refer https://github.com/Netflix/metaflow/blob/master/docs/lifecycle.png
199
205
def step_init (self , flow , graph , step , decos , environment , flow_datastore , logger ):
@@ -289,6 +295,17 @@ def step_init(self, flow, graph, step, decos, environment, flow_datastore, logge
289
295
)
290
296
)
291
297
298
+ if self .attributes ["shared_memory" ]:
299
+ if not (
300
+ isinstance (self .attributes ["shared_memory" ], int )
301
+ and int (self .attributes ["shared_memory" ]) > 0
302
+ ):
303
+ raise KubernetesException (
304
+ "Invalid shared_memory value: *{size}* for step *{step}* (should be an integer greater than 0)" .format (
305
+ size = self .attributes ["shared_memory" ], step = step
306
+ )
307
+ )
308
+
292
309
def package_init (self , flow , step_name , environment ):
293
310
try :
294
311
# Kubernetes is a soft dependency.
0 commit comments