from pathlib import Path
import logging
import json


def make_viridian_sample_header(new_run_uuid, sp3_sample_name):
    """
        Args:
            new_run_uuid (uuid): The unique id for the current run
            sp3_sample_name: The name of the SP3 sample
        Returns:
            dict: An object containing a subset of information from the Viridian log 
            file for the run. If no log file could be found None is return
    """
    log = None
    vn = (
        Path("/work/output") 
        / new_run_uuid 
        / "qc" 
        / f"{sp3_sample_name}.json"
    )
    if not vn.is_file():
        logging.error(f"The {vn} file could not be found")
        return None
    else:
        log = {}
        with open(vn) as f:
            log["viridian_log"] = json.load(f)
    
    if log:
        return log
    else:
        logging.error(f"The {vn} file is empty")
        return None