@@ -85,24 +85,38 @@ def _definitions(self, dynamic=False):
8585 return definitions
8686
8787 def _features (self , dynamic = False ):
88+ features = set (self .custom_settings .get ("Features" , "" ).split (',' ))
89+ # this is a simple workaround for empty Features: split will give [''] and we'll discard it
90+ # as well as all empty strings.
91+ features .discard ('' )
92+
93+ # remove "system" features from configured features, so that they will never interfere
94+ for feat in ('static' , 'dynamic' , 'gpu' , 'efa' ) :
95+ features .discard (feat )
96+
8897 resource_type = "static"
8998 if dynamic :
9099 resource_type = "dynamic"
100+ features .add (resource_type )
101+
102+ # If there's only 1 instance type defined, add it as a feature.
103+ # Note: When multiple instance types are defined we do not know in advance which one will be used
104+ # to launch the node. So we do not list any of them as feature
105+ if len (self .instance_types ) == 1 :
106+ features .add (self .instance_types [0 ])
91107
92- instance_type = f",{ self .instance_types [0 ]} "
93- if len (self .instance_types ) > 1 :
94- # When multiple instance types are defined we do not know in advance which one will be used
95- # to launch the node. So we do not list any of them as feature
96- instance_type = ""
108+ # add ComputeResource name as a feature
109+ features .add (self .name )
97110
98- features = f"Feature={ resource_type } { instance_type } ,{ self .name } "
99111 if self .efa_enabled :
100- features += ", efa"
112+ features . add ( ' efa' )
101113
102114 if self .gpu_count > 0 :
103- features += ",gpu"
104-
105- return features
115+ features .add ('gpu' )
116+
117+ # Note: sorted() is called to ease tests development only: we can then predict features ordering
118+ features_string = ',' .join (sorted (features ))
119+ return f"Feature={ features_string } "
106120
107121 def _custom_settings (self ):
108122 custom = ""
0 commit comments