Source code for pyobs.robotic.scripts.sequential

from __future__ import annotations
import logging
from typing import Any, TYPE_CHECKING

if TYPE_CHECKING:
    from pyobs.robotic.task import TaskData
from pyobs.robotic.scripts import Script

log = logging.getLogger(__name__)


[docs] class SequentialRunner(Script): """Script for running a sequence of other scripts.""" scripts: list[dict[str, Any]] check_all_can_run: bool = True
[docs] async def can_run(self, data: TaskData | None) -> bool: check_all = [await self.pyobs_model_validate(Script, s, by_alias=True).can_run(data) for s in self.scripts] return all(check_all) if self.check_all_can_run else check_all[0]
[docs] async def run(self, data: TaskData | None) -> None: for s in self.scripts: script = self.pyobs_model_validate(Script, s) if await script.can_run(data): await script.run(data) else: log.info(f"Script {s['class']} cannot run.")
__all__ = ["SequentialRunner"]