@@ -86,7 +86,7 @@ def __pydantic_schema_base_type__(cls) -> type[Profile]:
86
86
def create (
87
87
cls ,
88
88
rate_type : str ,
89
- rate : float | int | list [float | int ] | None ,
89
+ rate : list [float ] | None ,
90
90
random_seed : int = 42 ,
91
91
** kwargs : Any ,
92
92
) -> Profile :
@@ -112,7 +112,7 @@ def create(
112
112
def resolve_args (
113
113
cls ,
114
114
rate_type : str ,
115
- rate : float | int | list [float , int ] | None ,
115
+ rate : list [float ] | None ,
116
116
random_seed : int ,
117
117
** kwargs : Any ,
118
118
) -> dict [str , Any ]:
@@ -264,7 +264,7 @@ class SynchronousProfile(Profile):
264
264
def resolve_args (
265
265
cls ,
266
266
rate_type : str ,
267
- rate : float | int | list [float , int ] | None ,
267
+ rate : list [float ] | None ,
268
268
random_seed : int ,
269
269
** kwargs : Any ,
270
270
) -> dict [str , Any ]:
@@ -313,7 +313,7 @@ class ConcurrentProfile(Profile):
313
313
"""Fixed-concurrency strategy execution profile with configurable stream counts."""
314
314
315
315
type_ : Literal ["concurrent" ] = "concurrent" # type: ignore[assignment]
316
- streams : int | list [int ] = Field (
316
+ streams : list [int ] = Field (
317
317
description = "Number of concurrent streams for request scheduling" ,
318
318
gt = 0 ,
319
319
)
@@ -330,7 +330,7 @@ class ConcurrentProfile(Profile):
330
330
def resolve_args (
331
331
cls ,
332
332
rate_type : str ,
333
- rate : float | int | list [float , int ] | None ,
333
+ rate : list [float ] | None ,
334
334
random_seed : int ,
335
335
** kwargs : Any ,
336
336
) -> dict [str , Any ]:
@@ -344,7 +344,7 @@ def resolve_args(
344
344
:return: Dictionary of resolved arguments.
345
345
:raises ValueError: If rate is None.
346
346
"""
347
- kwargs ["streams" ] = rate
347
+ kwargs ["streams" ] = [ int ( r ) for r in rate ] if rate else None
348
348
return kwargs
349
349
350
350
@property
@@ -401,7 +401,7 @@ class ThroughputProfile(Profile):
401
401
def resolve_args (
402
402
cls ,
403
403
rate_type : str ,
404
- rate : float | int | list [float , int ] | None ,
404
+ rate : list [float ] | None ,
405
405
random_seed : int ,
406
406
** kwargs : Any ,
407
407
) -> dict [str , Any ]:
@@ -456,7 +456,7 @@ class AsyncProfile(Profile):
456
456
strategy_type : Literal ["constant" , "poisson" ] = Field (
457
457
description = "Type of asynchronous strategy pattern to use" ,
458
458
)
459
- rate : float | list [float ] = Field (
459
+ rate : list [float ] = Field (
460
460
description = "Request scheduling rate in requests per second" ,
461
461
gt = 0 ,
462
462
)
@@ -482,7 +482,7 @@ class AsyncProfile(Profile):
482
482
def resolve_args (
483
483
cls ,
484
484
rate_type : str ,
485
- rate : float | int | list [float , int ] | None ,
485
+ rate : list [float ] | None ,
486
486
random_seed : int ,
487
487
** kwargs : Any ,
488
488
) -> dict [str , Any ]:
@@ -516,7 +516,7 @@ def resolve_args(
516
516
@property
517
517
def strategy_types (self ) -> list [StrategyType ]:
518
518
"""Get async strategy types for each configured rate."""
519
- num_strategies = len (self .rate ) if isinstance ( self . rate , list ) else 1
519
+ num_strategies = len (self .rate )
520
520
return [self .strategy_type ] * num_strategies
521
521
522
522
def next_strategy (
@@ -533,7 +533,7 @@ def next_strategy(
533
533
or None if all rates completed.
534
534
:raises ValueError: If strategy_type is neither 'constant' nor 'poisson'.
535
535
"""
536
- rate = self .rate if isinstance ( self . rate , list ) else [ self . rate ]
536
+ rate = self .rate
537
537
538
538
if len (self .completed_strategies ) >= len (rate ):
539
539
return None
@@ -607,7 +607,7 @@ class SweepProfile(Profile):
607
607
def resolve_args (
608
608
cls ,
609
609
rate_type : str ,
610
- rate : float | int | list [float , int ] | None ,
610
+ rate : list [float ] | None ,
611
611
random_seed : int ,
612
612
** kwargs : Any ,
613
613
) -> dict [str , Any ]:
@@ -620,7 +620,8 @@ def resolve_args(
620
620
:param kwargs: Additional arguments to pass through.
621
621
:return: Dictionary of resolved arguments.
622
622
"""
623
- kwargs ["sweep_size" ] = kwargs .get ("sweep_size" , rate )
623
+ sweep_size_from_rate = rate [0 ] if rate else None
624
+ kwargs ["sweep_size" ] = kwargs .get ("sweep_size" , sweep_size_from_rate )
624
625
kwargs ["random_seed" ] = random_seed
625
626
if rate_type in ["constant" , "poisson" ]:
626
627
kwargs ["strategy_type" ] = rate_type
0 commit comments