@@ -61,7 +61,7 @@ class EC2InstancesSettings(BaseCustomSettings):
6161 EC2_INSTANCES_ALLOWED_TYPES : dict [str , EC2InstanceBootSpecific ] = Field (
6262 ...,
6363 description = "Defines which EC2 instances are considered as candidates for new EC2 instance and their respective boot specific parameters"
64- "WARNING: if empty, all available ec2 instances are allowed " ,
64+ "NOTE: minimum length >0 " ,
6565 )
6666
6767 EC2_INSTANCES_KEY_NAME : str = Field (
@@ -134,7 +134,7 @@ class EC2InstancesSettings(BaseCustomSettings):
134134
135135 @validator ("EC2_INSTANCES_TIME_BEFORE_DRAINING" )
136136 @classmethod
137- def ensure_draining_delay_time_is_in_range (
137+ def _ensure_draining_delay_time_is_in_range (
138138 cls , value : datetime .timedelta
139139 ) -> datetime .timedelta :
140140 if value < datetime .timedelta (seconds = 10 ):
@@ -145,7 +145,7 @@ def ensure_draining_delay_time_is_in_range(
145145
146146 @validator ("EC2_INSTANCES_TIME_BEFORE_TERMINATION" )
147147 @classmethod
148- def ensure_termination_delay_time_is_in_range (
148+ def _ensure_termination_delay_time_is_in_range (
149149 cls , value : datetime .timedelta
150150 ) -> datetime .timedelta :
151151 if value < datetime .timedelta (minutes = 0 ):
@@ -156,12 +156,18 @@ def ensure_termination_delay_time_is_in_range(
156156
157157 @validator ("EC2_INSTANCES_ALLOWED_TYPES" )
158158 @classmethod
159- def check_valid_instance_names (
159+ def _check_valid_instance_names_and_not_empty (
160160 cls , value : dict [str , EC2InstanceBootSpecific ]
161161 ) -> dict [str , EC2InstanceBootSpecific ]:
162162 # NOTE: needed because of a flaw in BaseCustomSettings
163163 # issubclass raises TypeError if used on Aliases
164164 parse_obj_as (list [InstanceTypeType ], list (value ))
165+
166+ if not value :
167+ # NOTE: Field( ... , min_items=...) cannot be used to contraint number of iterms in a dict
168+ msg = "At least one item expecte EC2_INSTANCES_ALLOWED_TYPES, got none"
169+ raise ValueError (msg )
170+
165171 return value
166172
167173
@@ -294,12 +300,12 @@ def LOG_LEVEL(self): # noqa: N802
294300
295301 @validator ("AUTOSCALING_LOGLEVEL" )
296302 @classmethod
297- def valid_log_level (cls , value : str ) -> str :
303+ def _valid_log_level (cls , value : str ) -> str :
298304 return cls .validate_log_level (value )
299305
300306 @root_validator ()
301307 @classmethod
302- def exclude_both_dynamic_computational_mode (cls , values ):
308+ def _exclude_both_dynamic_computational_mode (cls , values ):
303309 if (
304310 values .get ("AUTOSCALING_DASK" ) is not None
305311 and values .get ("AUTOSCALING_NODES_MONITORING" ) is not None
0 commit comments