def create_pipeline_run(pipeline, context_by_op):
pipeline_run = PipelineRun.objects.create(pipeline=pipeline)<EOL>dag, ops = pipeline.dag<EOL>op_runs = {}<EOL>runs_by_ops = {}<EOL>for op_id in dag.keys():<EOL><INDENT>op_run = OperationRun.objects.create(<EOL>pipeline_run=pipeline_run,<EOL>operation_id=op_id,<EOL>celery_task_context=context_by_op.get(op_id))<EOL>op_run_id = op_run.id<EOL>op_runs[op_run_id] = op_run<EOL>runs_by_ops[op_id] = op_run_id<EOL><DEDENT>set_topological_dag_upstreams(dag=dag, ops=ops, op_runs=op_runs, runs_by_ops=runs_by_ops)<EOL>
Create a pipeline run/instance.