forked from bokeh/bokeh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pipeline.py
60 lines (42 loc) · 1.68 KB
/
pipeline.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# -----------------------------------------------------------------------------
# Copyright (c) Anaconda, Inc., and Bokeh Contributors.
# All rights reserved.
#
# The full license is in the file LICENSE.txt, distributed with this software.
# -----------------------------------------------------------------------------
"""
"""
from __future__ import annotations
# Standard library imports
from typing import Callable, Sequence
# Bokeh imports
from .action import SKIPPED, ActionResult, ActionReturn
from .config import Config
from .logger import LOG
from .system import System
from .ui import task
__all__ = ("StepType",)
StepType = Callable[[Config, System], ActionReturn]
def is_check(step: StepType) -> bool:
return step.__name__.startswith("check_") or step.__name__.startswith("verify_")
class Pipeline:
""""""
def __init__(self, steps: Sequence[StepType], config: Config, system: System) -> None:
self._steps = steps
self._config = config
self._system = system
def execute(self) -> None:
""""""
LOG.clear()
for step in self._steps:
LOG.record(task(f"Starting task {step.__name__}"))
if is_check(step) and self._system.dry_run:
LOG.record(str(SKIPPED(f"{step.__name__} skipped for dry run")))
continue
if self._config.prerelease and getattr(step, "skip_for_prerelease", False):
LOG.record(str(SKIPPED(f"{step.__name__} skipped for pre-releases")))
continue
result = step(self._config, self._system)
LOG.record(str(result))
if result.kind is ActionResult.FAIL:
self._system.abort()