Clean runtime code
This commit is contained in:
@@ -56,10 +56,6 @@ def _optional_bool(value: Any) -> bool | None:
|
||||
@dataclass(slots=True)
|
||||
class RuntimeSyncConfig:
|
||||
name: str | None = None
|
||||
ids_initial_size: int | None = None
|
||||
ids_next_size: int | None = None
|
||||
ids_max_pages: int | None = None
|
||||
condition_check_enabled: bool | None = None
|
||||
lane: str | None = None
|
||||
only_new: bool | None = None
|
||||
limit: int | None = None
|
||||
@@ -71,10 +67,6 @@ class RuntimeSyncConfig:
|
||||
lane = str(data.get("lane")).strip() if data.get("lane") else None
|
||||
return cls(
|
||||
name=name or None,
|
||||
ids_initial_size=_optional_int(data.get("ids_initial_size")),
|
||||
ids_next_size=_optional_int(data.get("ids_next_size")),
|
||||
ids_max_pages=_optional_int(data.get("ids_max_pages")),
|
||||
condition_check_enabled=_optional_bool(data.get("condition_check_enabled")),
|
||||
lane=lane or None,
|
||||
only_new=_optional_bool(data.get("only_new")),
|
||||
limit=_optional_int(data.get("limit")),
|
||||
@@ -349,27 +341,18 @@ class RuntimeMobileDeSegment:
|
||||
class RuntimeMobileDeEnrichmentConfig:
|
||||
enabled: bool = True
|
||||
batch_size: int = 10
|
||||
max_existing_images: int = 1
|
||||
staleness_hours: int = 168
|
||||
delay_seconds: float = 1.0
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, data: dict[str, Any] | None) -> "RuntimeMobileDeEnrichmentConfig":
|
||||
data = data or {}
|
||||
enabled = _optional_bool(data.get("enabled"))
|
||||
batch_size = _optional_int(data.get("batch_size"))
|
||||
max_existing_images = _optional_int(data.get("max_existing_images"))
|
||||
staleness_hours = _optional_int(data.get("staleness_hours"))
|
||||
try:
|
||||
delay_seconds = float(data.get("delay_seconds", 1.0))
|
||||
except (TypeError, ValueError):
|
||||
delay_seconds = 1.0
|
||||
return cls(
|
||||
enabled=True if enabled is None else enabled,
|
||||
batch_size=max(1, 10 if batch_size is None else batch_size),
|
||||
max_existing_images=max(0, 1 if max_existing_images is None else max_existing_images),
|
||||
staleness_hours=max(0, 168 if staleness_hours is None else staleness_hours),
|
||||
delay_seconds=max(0.0, delay_seconds),
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user