File size: 1,048 Bytes
18faf97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# ----------------------------------------------------------------------
# IMPORTS
# ----------------------------------------------------------------------
import io
import sys
import time
import logging
from contextlib import redirect_stdout
from typing import List, Callable

from src.utils import ProcessingContext


# ----------------------------------------------------------------------
# PIPELINE EXECUTION
# ----------------------------------------------------------------------
def run_functions_in_sequence(contexts: List[ProcessingContext], pipeline_steps: List[Callable]) -> None:
    for func in pipeline_steps:
        if all(context.skip_run or context.skip_processing for context in contexts):
            break
            
        logging.info(f"Executing pipeline step: {func.__name__}")
        
        stdout_buffer = io.StringIO()
        with redirect_stdout(stdout_buffer):
            func(contexts)
            
        sys.stdout.write(stdout_buffer.getvalue())
        sys.stdout.flush()
        
        time.sleep(1)