import logging


def _create_list_of_class_names(view, label_field):
    """Create list of class names from the label field.

    Args:
        view (voxel51 view object) - the voxel51 dataset
        label_field (str) - label field set in config

    Returns:
        class_names (list)
    """
    logging.info("Extracting class names from label field.")
    class_names = []
    for sample in view.select_fields(label_field):
        if sample[label_field] is not None:
            for detection in sample[label_field].detections:
                label = detection["label"]
                if label not in class_names:
                    class_names.append(label)
    logging.info("Finished extracting class names from label field.")
    return class_names