Python code for flexible pipeline control