@@ -89,6 +89,27 @@ def update_labels(yaml, instascale, instance_types):
8989 metadata .pop ("labels" )
9090
9191
92+ def update_priority (yaml , item , priority ):
93+ if priority not in ["low" , "default" , "high" ]:
94+ sys .exit ("Priority must be 'low', 'default', or 'high'" )
95+
96+ priority_levels = {
97+ "low" : (1 , "low-priority" ),
98+ "default" : (5 , "default-priority" ),
99+ "high" : (10 , "high-priority" ),
100+ }
101+
102+ priority_level = priority_levels [priority ]
103+ spec = yaml .get ("spec" )
104+ spec ["priority" ] = priority_level [0 ]
105+ # spec["SchedulingSpec"]["priorityClassName"] = priority_level
106+ if "generictemplate" in item .keys ():
107+ head = item .get ("generictemplate" ).get ("spec" ).get ("headGroupSpec" )
108+ worker = item .get ("generictemplate" ).get ("spec" ).get ("workerGroupSpecs" )[0 ]
109+ head ["template" ]["spec" ]["priorityClassName" ] = priority_level [1 ]
110+ worker ["template" ]["spec" ]["priorityClassName" ] = priority_level [1 ]
111+
112+
92113def update_custompodresources (
93114 item , min_cpu , max_cpu , min_memory , max_memory , gpu , workers
94115):
@@ -175,6 +196,11 @@ def update_resources(spec, min_cpu, max_cpu, min_memory, max_memory, gpu):
175196 limits ["nvidia.com/gpu" ] = gpu
176197
177198
199+ def update_scheduling_spec (yaml , workers ):
200+ spec = yaml .get ("spec" )
201+ spec ["schedulingSpec" ]["minAvailable" ] = workers + 1
202+
203+
178204def update_nodes (
179205 item ,
180206 appwrapper_name ,
@@ -346,6 +372,7 @@ def generate_appwrapper(
346372 env ,
347373 local_interactive : bool ,
348374 image_pull_secrets : list ,
375+ priority : str ,
349376):
350377 user_yaml = read_template (template )
351378 appwrapper_name , cluster_name = gen_names (name )
@@ -354,6 +381,8 @@ def generate_appwrapper(
354381 route_item = resources ["resources" ].get ("GenericItems" )[1 ]
355382 update_names (user_yaml , item , appwrapper_name , cluster_name , namespace )
356383 update_labels (user_yaml , instascale , instance_types )
384+ update_priority (user_yaml , item , priority )
385+ update_scheduling_spec (user_yaml , workers )
357386 update_custompodresources (
358387 item , min_cpu , max_cpu , min_memory , max_memory , gpu , workers
359388 )
0 commit comments