def get_dag(nodes, downstream_fn) -> Tuple[Dict, Dict]:
dag = {}<EOL>node_by_ids = {}<EOL>for node in nodes:<EOL><INDENT>downstream_ops = downstream_fn(node)<EOL>dag[node.id] = set(downstream_ops)<EOL>node_by_ids[node.id] = node<EOL><DEDENT>return dag, node_by_ids<EOL>
Return a dag representation of the nodes passed.

    This is equally used for pipelines and pipeline runs.

    Params:
        nodes: an instance of `Operation` | `OperationRun` the nodes to represent en dag.
        downstream_fn: a function that returns the downstream nodes of the a node.

    Returns:
         tuple: (dag, dict(node_id: node))