File tree Expand file tree Collapse file tree 3 files changed +28
-0
lines changed
src/runpod_flash/core/resources Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -324,6 +324,20 @@ def sync_input_fields(self):
324324
325325 return self
326326
327+ @model_validator (mode = "after" )
328+ def validate_worker_range (self ):
329+ """Ensure worker scaling bounds are valid."""
330+ if (
331+ self .workersMin is not None
332+ and self .workersMax is not None
333+ and self .workersMin > self .workersMax
334+ ):
335+ raise ValueError (
336+ f"workersMin ({ self .workersMin } ) cannot be greater than "
337+ f"workersMax ({ self .workersMax } )"
338+ )
339+ return self
340+
327341 def _has_cpu_instances (self ) -> bool :
328342 """Check if endpoint has CPU instances configured.
329343
Original file line number Diff line number Diff line change 1414class TestLiveServerless :
1515 """Test LiveServerless (GPU) class behavior."""
1616
17+ def test_live_serverless_workers_min_cannot_exceed_workers_max (self ):
18+ with pytest .raises (
19+ ValueError ,
20+ match = r"workersMin \(5\) cannot be greater than workersMax \(1\)" ,
21+ ):
22+ LiveServerless (name = "broken" , workersMin = 5 , workersMax = 1 )
23+
1724 def test_live_serverless_gpu_defaults (self ):
1825 """Test LiveServerless uses GPU image and defaults."""
1926 live_serverless = LiveServerless (
Original file line number Diff line number Diff line change @@ -209,6 +209,13 @@ async def test_ensure_network_volume_deployed_uses_existing_volume(self):
209209class TestServerlessResourceValidation :
210210 """Test field validation and serialization."""
211211
212+ def test_workers_min_cannot_exceed_workers_max (self ):
213+ with pytest .raises (
214+ ValueError ,
215+ match = r"workersMin \(5\) cannot be greater than workersMax \(1\)" ,
216+ ):
217+ ServerlessResource (name = "test" , workersMin = 5 , workersMax = 1 )
218+
212219 def test_scaler_type_serialization (self ):
213220 """Test ServerlessScalerType enum serialization."""
214221 serverless = ServerlessResource (
You can’t perform that action at this time.
0 commit comments