def select_workflow(gi, folder_id, workflow_names, sample, run, lh):
    """
    Select a workflow (either single or paired) based on
    the number of datasets contained in the current data
    library folder.
    """
    workflow_name = None
    # Get the number of dataset within the folder.
    folder_contents_dict = gi.folders.show_folder(folder_id)
    num_datasets = folder_contents_dict['item_count']
    if num_datasets == 1:
        workflow_name = workflow_names['SINGLE']
    elif num_datasets == 2:
        workflow_name = workflow_names['PAIRED']
    if workflow_name:
        lh.write('Selected workflow named %s for sample %s of run %s\n' % (workflow_name, sample, run))
    return workflow_name, num_datasets