@@ -160,83 +160,85 @@ def _build_cluster_args(**pars):
160160 args ["Instances" ]["InstanceFleets" ].append (fleet_master )
161161
162162 # Core Instance Fleet
163- timeout_action_core = "SWITCH_TO_ON_DEMAND" if pars ["spot_timeout_to_on_demand_core" ] else "TERMINATE_CLUSTER"
164- fleet_core : Dict = {
165- "Name" :
166- "CORE" ,
167- "InstanceFleetType" :
168- "CORE" ,
169- "TargetOnDemandCapacity" :
170- pars ["instance_num_on_demand_core" ],
171- "TargetSpotCapacity" :
172- pars ["instance_num_spot_core" ],
173- "InstanceTypeConfigs" : [
174- {
175- "InstanceType" : pars ["instance_type_core" ],
176- "WeightedCapacity" : 1 ,
177- "BidPriceAsPercentageOfOnDemandPrice" : pars ["spot_bid_percentage_of_on_demand_core" ],
178- "EbsConfiguration" : {
179- "EbsBlockDeviceConfigs" : [{
180- "VolumeSpecification" : {
181- "SizeInGB" : pars ["instance_ebs_size_core" ],
182- "VolumeType" : "gp2"
183- },
184- "VolumesPerInstance" : 1
185- }],
186- "EbsOptimized" :
187- True
163+ if (pars ["instance_num_spot_core" ] > 0 ) or pars ["instance_num_on_demand_core" ] > 0 :
164+ timeout_action_core = "SWITCH_TO_ON_DEMAND" if pars ["spot_timeout_to_on_demand_core" ] else "TERMINATE_CLUSTER"
165+ fleet_core : Dict = {
166+ "Name" :
167+ "CORE" ,
168+ "InstanceFleetType" :
169+ "CORE" ,
170+ "TargetOnDemandCapacity" :
171+ pars ["instance_num_on_demand_core" ],
172+ "TargetSpotCapacity" :
173+ pars ["instance_num_spot_core" ],
174+ "InstanceTypeConfigs" : [
175+ {
176+ "InstanceType" : pars ["instance_type_core" ],
177+ "WeightedCapacity" : 1 ,
178+ "BidPriceAsPercentageOfOnDemandPrice" : pars ["spot_bid_percentage_of_on_demand_core" ],
179+ "EbsConfiguration" : {
180+ "EbsBlockDeviceConfigs" : [{
181+ "VolumeSpecification" : {
182+ "SizeInGB" : pars ["instance_ebs_size_core" ],
183+ "VolumeType" : "gp2"
184+ },
185+ "VolumesPerInstance" : 1
186+ }],
187+ "EbsOptimized" :
188+ True
189+ },
188190 },
189- },
190- ],
191- }
192- if pars ["instance_num_spot_core" ] > 0 :
193- fleet_core ["LaunchSpecifications" ]: Dict = {
194- "SpotSpecification" : {
195- "TimeoutDurationMinutes" : pars ["spot_provisioning_timeout_core" ],
196- "TimeoutAction" : timeout_action_core ,
197- }
191+ ],
198192 }
199- args ["Instances" ]["InstanceFleets" ].append (fleet_core )
193+ if pars ["instance_num_spot_core" ] > 0 :
194+ fleet_core ["LaunchSpecifications" ]: Dict = {
195+ "SpotSpecification" : {
196+ "TimeoutDurationMinutes" : pars ["spot_provisioning_timeout_core" ],
197+ "TimeoutAction" : timeout_action_core ,
198+ }
199+ }
200+ args ["Instances" ]["InstanceFleets" ].append (fleet_core )
200201
201- # # Task Instance Fleet
202- timeout_action_task : str = "SWITCH_TO_ON_DEMAND" if pars [
203- "spot_timeout_to_on_demand_task" ] else "TERMINATE_CLUSTER"
204- fleet_task : Dict = {
205- "Name" :
206- "TASK" ,
207- "InstanceFleetType" :
208- "TASK" ,
209- "TargetOnDemandCapacity" :
210- pars ["instance_num_on_demand_task" ],
211- "TargetSpotCapacity" :
212- pars ["instance_num_spot_task" ],
213- "InstanceTypeConfigs" : [
214- {
215- "InstanceType" : pars ["instance_type_task" ],
216- "WeightedCapacity" : 1 ,
217- "BidPriceAsPercentageOfOnDemandPrice" : pars ["spot_bid_percentage_of_on_demand_task" ],
218- "EbsConfiguration" : {
219- "EbsBlockDeviceConfigs" : [{
220- "VolumeSpecification" : {
221- "SizeInGB" : pars ["instance_ebs_size_task" ],
222- "VolumeType" : "gp2"
223- },
224- "VolumesPerInstance" : 1
225- }],
226- "EbsOptimized" :
227- True
202+ # Task Instance Fleet
203+ if (pars ["instance_num_spot_task" ] > 0 ) or pars ["instance_num_on_demand_task" ] > 0 :
204+ timeout_action_task : str = "SWITCH_TO_ON_DEMAND" if pars [
205+ "spot_timeout_to_on_demand_task" ] else "TERMINATE_CLUSTER"
206+ fleet_task : Dict = {
207+ "Name" :
208+ "TASK" ,
209+ "InstanceFleetType" :
210+ "TASK" ,
211+ "TargetOnDemandCapacity" :
212+ pars ["instance_num_on_demand_task" ],
213+ "TargetSpotCapacity" :
214+ pars ["instance_num_spot_task" ],
215+ "InstanceTypeConfigs" : [
216+ {
217+ "InstanceType" : pars ["instance_type_task" ],
218+ "WeightedCapacity" : 1 ,
219+ "BidPriceAsPercentageOfOnDemandPrice" : pars ["spot_bid_percentage_of_on_demand_task" ],
220+ "EbsConfiguration" : {
221+ "EbsBlockDeviceConfigs" : [{
222+ "VolumeSpecification" : {
223+ "SizeInGB" : pars ["instance_ebs_size_task" ],
224+ "VolumeType" : "gp2"
225+ },
226+ "VolumesPerInstance" : 1
227+ }],
228+ "EbsOptimized" :
229+ True
230+ },
228231 },
229- },
230- ],
231- }
232- if pars ["instance_num_spot_task" ] > 0 :
233- fleet_task ["LaunchSpecifications" ]: Dict = {
234- "SpotSpecification" : {
235- "TimeoutDurationMinutes" : pars ["spot_provisioning_timeout_task" ],
236- "TimeoutAction" : timeout_action_task ,
237- }
232+ ],
238233 }
239- args ["Instances" ]["InstanceFleets" ].append (fleet_task )
234+ if pars ["instance_num_spot_task" ] > 0 :
235+ fleet_task ["LaunchSpecifications" ]: Dict = {
236+ "SpotSpecification" : {
237+ "TimeoutDurationMinutes" : pars ["spot_provisioning_timeout_task" ],
238+ "TimeoutAction" : timeout_action_task ,
239+ }
240+ }
241+ args ["Instances" ]["InstanceFleets" ].append (fleet_task )
240242
241243 logger .info (f"args: \n { json .dumps (args , default = str , indent = 4 )} " )
242244 return args
0 commit comments