def load_yaml_with_sanity_check(yaml_file):
    """Load yaml and do sanity check. Internal use only."""
    with open(yaml_file) as f:
        yaml_data = yaml.load(f, Loader=yaml.loader.SafeLoader)
        try:
            meta_yaml = MetaYaml(**yaml_data)
        except dt.ValidationError as e:
            print("Details of pydantic.ValidationError:\n{}".format(e.json()))
            raise DGLError(
                "Validation Error for YAML fields. Details are shown above."
            )
        if meta_yaml.version != "1.0.0":
            raise DGLError(
                "Invalid CSVDataset version {}. Supported versions: '1.0.0'".format(
                    meta_yaml.version
                )
            )
        ntypes = [meta.ntype for meta in meta_yaml.node_data]
        if len(ntypes) > len(set(ntypes)):
            raise DGLError(
                "Each node CSV file must have a unique node type name, but found duplicate node type: {}.".format(
                    ntypes
                )
            )
        etypes = [tuple(meta.etype) for meta in meta_yaml.edge_data]
        if len(etypes) > len(set(etypes)):
            raise DGLError(
                "Each edge CSV file must have a unique edge type name, but found duplicate edge type: {}.".format(
                    etypes
                )
            )
        return meta_yaml
Load yaml and do sanity check. Internal use only.
python/dgl/data/csv_dataset_base.py