@task
def make_nodes(
    nodes_to_make_lst,
    max_num_nodes,
    db_name,
):
    """
    
    A loop:
        a) Determines if to make a node in the graph db
        b) The number of nodes to make in the graph db
        c) The artifacts for the node. Definitions, images ...
    
    """

    # Step 1 of the we extract the accumulated task loop result from context
    loop_payload = prefect.context.get("task_loop_result", {})

    # This is what gets returned from loop result
    nodes_to_make_lst = loop_payload.get("nodes_to_make_lst", nodes_to_make_lst)
    #context_df = loop_payload.get("context_df", args.context_df)
    
    # Make nodes in parallel
    with Flow("Prallelize Make node") as parflow:

        make_node_response = make_node.map(
            node_key_dict=nodes_to_make_lst,
            db_name=unmapped(db_name),
            graph_db_name=unmapped(graph_db_name),
            artifact_coll_nm=unmapped(artifact_coll_nm),
            node_artifact_dir=unmapped(node_artifact_dir),
            unique_node_id_clmn_nm=unmapped(unique_node_id_clmn_nm)
        )
    get_defs_state = parflow.run(
        executor=executor
    )
    #parflow.visualize(flow_state=get_defs_state)

    make_nodes_lst = get_defs_state.result[make_node_response].result[0]
    pprint(f"make_nodes_lst: {len( make_nodes_lst)}")

    
    pprint(f"Making new level")
    
    num_nodes_completed = lmap_io.count_nodes.run(db_conn["graph_db"])
    pprint(num_nodes_completed)
    
    if num_nodes_completed>=max_num_nodes:

        logger.info(f"Finished Making Knowledge Graph: {num_nodes_completed}")
        return  num_nodes_completed

    raise LOOP(
                message=f"{len(make_nodes_lst)}", 
                result=dict(
                    nodes_to_make_lst=make_nodes_lst
                )
    )