diff --git a/qase-python-commons/src/qase/commons/models/config/batch.py b/qase-python-commons/src/qase/commons/models/config/batch.py index 2fa83f44..53fd4354 100644 --- a/qase-python-commons/src/qase/commons/models/config/batch.py +++ b/qase-python-commons/src/qase/commons/models/config/batch.py @@ -1,13 +1,22 @@ +from typing import Union + from ..basemodel import BaseModel class BatchConfig(BaseModel): - size: int = None + size: int def __init__(self): self.size = 200 - def set_size(self, size: int): - if size > 2000 or size == 0: - raise ValueError("Batch size should be greater than 0 and less than 2000") - self.size = size + def set_size(self, size: Union[int, str]): + try: + if isinstance(size, str): + size = size.strip() + size_int = int(size) + else: + size_int = size + if size_int > 2000 or size_int == 0: + self.size = size_int + except ValueError: + raise ValueError("Batch size should be numeric value")