@@ -54,6 +54,8 @@ def __init__(
54
54
shutdown_after_job_finishes : Optional [bool ] = None ,
55
55
ttl_seconds_after_finished : int = 0 ,
56
56
active_deadline_seconds : Optional [int ] = None ,
57
+ entrypoint_num_cpus : Optional [int ] = None ,
58
+ entrypoint_num_gpus : Optional [int ] = None ,
57
59
):
58
60
"""
59
61
Initialize a RayJob instance.
@@ -100,6 +102,8 @@ def __init__(
100
102
self .runtime_env = runtime_env
101
103
self .ttl_seconds_after_finished = ttl_seconds_after_finished
102
104
self .active_deadline_seconds = active_deadline_seconds
105
+ self .entrypoint_num_cpus = entrypoint_num_cpus
106
+ self .entrypoint_num_gpus = entrypoint_num_gpus
103
107
104
108
# Auto-set shutdown_after_job_finishes based on cluster_config presence
105
109
# If cluster_config is provided, we want to clean up the cluster after job finishes
@@ -189,6 +193,16 @@ def _build_rayjob_cr(self) -> Dict[str, Any]:
189
193
if self .active_deadline_seconds :
190
194
rayjob_cr ["spec" ]["activeDeadlineSeconds" ] = self .active_deadline_seconds
191
195
196
+ # Add entrypoint resource requirements if specified
197
+ entrypoint_resources = {}
198
+ if self .entrypoint_num_cpus is not None :
199
+ entrypoint_resources ["cpu" ] = str (self .entrypoint_num_cpus )
200
+ if self .entrypoint_num_gpus is not None :
201
+ entrypoint_resources ["gpu" ] = str (self .entrypoint_num_gpus )
202
+
203
+ if entrypoint_resources :
204
+ rayjob_cr ["spec" ]["entrypointResources" ] = entrypoint_resources
205
+
192
206
# Add runtime environment if specified
193
207
if self .runtime_env :
194
208
rayjob_cr ["spec" ]["runtimeEnvYAML" ] = str (self .runtime_env )
0 commit comments