@@ -84,7 +84,7 @@ class SSHHostParams(CoreModel):
8484 "The amount of blocks to split the instance into, a number or `auto`."
8585 " `auto` means as many as possible."
8686 " The number of GPUs and CPUs must be divisible by the number of blocks."
87- " Defaults to the top-level `blocks` value. "
87+ " Defaults to the top-level `blocks` value"
8888 ),
8989 ge = 1 ,
9090 ),
@@ -130,7 +130,7 @@ class SSHParams(CoreModel):
130130 " If not specified, `dstack` will use IPs from the first found internal network."
131131 )
132132 ),
133- ]
133+ ] = None
134134
135135 @validator ("network" )
136136 def validate_network (cls , value ):
@@ -206,50 +206,13 @@ def _post_validate_ranges(cls, values):
206206 return values
207207
208208
209- class InstanceGroupParamsConfig (CoreConfig ):
210- @staticmethod
211- def schema_extra (schema : Dict [str , Any ]):
212- add_extra_schema_types (
213- schema ["properties" ]["nodes" ],
214- extra_types = [{"type" : "integer" }, {"type" : "string" }],
215- )
216- add_extra_schema_types (
217- schema ["properties" ]["idle_duration" ],
218- extra_types = [{"type" : "string" }],
219- )
220-
221-
222- class InstanceGroupParams (CoreModel ):
223- env : Annotated [
224- Env ,
225- Field (description = "The mapping or the list of environment variables" ),
226- ] = Env ()
227- ssh_config : Annotated [
228- Optional [SSHParams ],
229- Field (description = "The parameters for adding instances via SSH" ),
230- ] = None
231-
232- nodes : Annotated [
233- Optional [FleetNodesSpec ], Field (description = "The number of instances in cloud fleet" )
234- ] = None
209+ class CommonFleetConfigurationProps (CoreModel ):
210+ type : Literal ["fleet" ] = "fleet"
211+ name : Annotated [Optional [str ], Field (description = "The fleet name" )] = None
235212 placement : Annotated [
236213 Optional [InstanceGroupPlacement ],
237214 Field (description = "The placement of instances: `any` or `cluster`" ),
238215 ] = None
239- reservation : Annotated [
240- Optional [str ],
241- Field (
242- description = (
243- "The existing reservation to use for instance provisioning."
244- " Supports AWS Capacity Reservations, AWS Capacity Blocks, and GCP reservations"
245- )
246- ),
247- ] = None
248- resources : Annotated [
249- Optional [ResourcesSpec ],
250- Field (description = "The resources requirements" ),
251- ] = None
252-
253216 blocks : Annotated [
254217 Union [Literal ["auto" ], int ],
255218 Field (
@@ -263,6 +226,22 @@ class InstanceGroupParams(CoreModel):
263226 ),
264227 ] = 1
265228
229+
230+ class BackendFleetConfiguraionProps (CoreModel ):
231+ nodes : Annotated [Optional [FleetNodesSpec ], Field (description = "The number of instances" )] = None
232+ reservation : Annotated [
233+ Optional [str ],
234+ Field (
235+ description = (
236+ "The existing reservation to use for instance provisioning."
237+ " Supports AWS Capacity Reservations, AWS Capacity Blocks, and GCP reservations"
238+ )
239+ ),
240+ ] = None
241+ resources : Annotated [
242+ Optional [ResourcesSpec ],
243+ Field (description = "The resources requirements" ),
244+ ] = None
266245 backends : Annotated [
267246 Optional [List [BackendType ]],
268247 Field (description = "The backends to consider for provisioning (e.g., `[aws, gcp]`)" ),
@@ -314,6 +293,16 @@ class InstanceGroupParams(CoreModel):
314293 )
315294 ),
316295 ] = None
296+ tags : Annotated [
297+ Optional [Dict [str , str ]],
298+ Field (
299+ description = (
300+ "The custom tags to associate with the resource."
301+ " The tags are also propagated to the underlying backend resources."
302+ " If there is a conflict with backend-level tags, does not override them"
303+ )
304+ ),
305+ ] = None
317306
318307 @validator ("nodes" , pre = True )
319308 def parse_nodes (cls , v : Optional [Union [dict , str ]]) -> Optional [dict ]:
@@ -329,35 +318,61 @@ def parse_nodes(cls, v: Optional[Union[dict, str]]) -> Optional[dict]:
329318 parse_idle_duration
330319 )
331320
332-
333- class FleetProps (CoreModel ):
334- type : Literal ["fleet" ] = "fleet"
335- name : Annotated [Optional [str ], Field (description = "The fleet name" )] = None
321+ _validate_tags = validator ("tags" , pre = True , allow_reuse = True )(tags_validator )
336322
337323
338- class FleetConfigurationConfig ( InstanceGroupParamsConfig ):
324+ class BackendFleetConfigurationPropsConfig ( CoreConfig ):
339325 @staticmethod
340326 def schema_extra (schema : Dict [str , Any ]):
341- InstanceGroupParamsConfig .schema_extra (schema )
327+ add_extra_schema_types (
328+ schema ["properties" ]["nodes" ],
329+ extra_types = [{"type" : "integer" }, {"type" : "string" }],
330+ )
331+ add_extra_schema_types (
332+ schema ["properties" ]["idle_duration" ],
333+ extra_types = [{"type" : "string" }],
334+ )
335+
336+
337+ class SSHFleetConfigurationProps (CoreModel ):
338+ ssh_config : Annotated [
339+ Optional [SSHParams ],
340+ Field (description = "The parameters for adding instances via SSH" ),
341+ ] = None
342+ env : Annotated [
343+ Env ,
344+ Field (description = "The mapping or the list of environment variables" ),
345+ ] = Env ()
346+
347+
348+ class FleetConfigurationConfig (BackendFleetConfigurationPropsConfig ):
349+ @staticmethod
350+ def schema_extra (schema : dict [str , Any ]):
351+ BackendFleetConfigurationPropsConfig .schema_extra (schema )
342352
343353
344354class FleetConfiguration (
345- InstanceGroupParams ,
346- FleetProps ,
355+ SSHFleetConfigurationProps ,
356+ BackendFleetConfiguraionProps ,
357+ CommonFleetConfigurationProps ,
347358 generate_dual_core_model (FleetConfigurationConfig ),
348359):
349- tags : Annotated [
350- Optional [Dict [str , str ]],
351- Field (
352- description = (
353- "The custom tags to associate with the resource."
354- " The tags are also propagated to the underlying backend resources."
355- " If there is a conflict with backend-level tags, does not override them"
356- )
357- ),
358- ] = None
360+ pass
359361
360- _validate_tags = validator ("tags" , pre = True , allow_reuse = True )(tags_validator )
362+
363+ class BackendFleetConfiguration (
364+ BackendFleetConfiguraionProps ,
365+ CommonFleetConfigurationProps ,
366+ generate_dual_core_model (BackendFleetConfigurationPropsConfig ),
367+ ):
368+ """For the documentation only"""
369+
370+
371+ class SSHFleetConfiguration (
372+ SSHFleetConfigurationProps ,
373+ CommonFleetConfigurationProps ,
374+ ):
375+ """For the documentation only"""
361376
362377
363378class FleetSpecConfig (CoreConfig ):
0 commit comments