nodes: 0, module; 1, function_definition; 2, function_name:set_topological_dag_upstreams; 3, parameters; 4, block; 5, identifier:dag; 6, identifier:ops; 7, identifier:op_runs; 8, identifier:runs_by_ops; 9, expression_statement; 10, expression_statement; 11, for_statement; 12, comment:"""Set the upstream runs for the operation runs in the dag following the topological sort."""; 13, assignment; 14, identifier:op_id; 15, identifier:sorted_ops; 16, block; 17, identifier:sorted_ops; 18, call; 19, expression_statement; 20, expression_statement; 21, expression_statement; 22, attribute; 23, argument_list; 24, assignment; 25, assignment; 26, call; 27, identifier:dags; 28, identifier:sort_topologically; 29, keyword_argument; 30, identifier:op_run_id; 31, subscript; 32, identifier:op_run; 33, subscript; 34, identifier:set_op_upstreams; 35, argument_list; 36, identifier:dag; 37, identifier:dag; 38, identifier:runs_by_ops; 39, identifier:op_id; 40, identifier:op_runs; 41, identifier:op_run_id; 42, keyword_argument; 43, keyword_argument; 44, identifier:op_run; 45, identifier:op_run; 46, identifier:op; 47, subscript; 48, identifier:ops; 49, identifier:op_id
code: def set_topological_dag_upstreams(dag, ops, op_runs, runs_by_ops):
      """Set the upstream runs for the operation runs in the dag following the topological sort."""
      sorted_ops = dags.sort_topologically(dag=dag)
      for op_id in sorted_ops:
          op_run_id = runs_by_ops[op_id]
          op_run = op_runs[op_run_id]
          set_op_upstreams(op_run=op_run, op=ops[op_id])