TypeError: export_vcf: parameter 'metadata': expected (None or Mapping[str, Mapping[str, Mapping[str, str]]]), found dict

Hi hail team,

I’m trying to export a VCF with a header dictionary but am getting this error:

TypeError: export_vcf: parameter 'metadata': expected (None or Mapping[str, Mapping[str, Mapping[str, str]]]), found dict

The dict I’m passing into metadata has nested dictionaries under the keys filter, format, and info.

Do you know what might be causing this error?

Thanks!

bumping this – this error is related to exporting the final UKBB VCFs

this is a bad error message, but I think the root cause is that there’s a typecheck failure inside the dict. What’s the arg you passed?

I passed a (very large) dict: gs://broad-ukbb/broad.freeze_6/temp/header_dict.pickle. good to know it’s probaby a typecheck failure; hopefully it’s just a typo within the dict!

this might help:


# expect: (None or Mapping[str, Mapping[str, Mapping[str, str]]])
def validate(d):
    for k, v in d.items():
        if not isinstance(k, str):
            raise ValueError(f'bad top level key {k}')
        if not isinstance(v, dict):
            raise ValueError(f'bad top-level value {v} at {k}')
        for k2, v2 in v.items():
            if not isinstance(k2, str):
                raise ValueError(f'bad 2nd-level key {k2} at ${k}')
            if not isinstance(v2, dict):
                raise ValueError(f'bad 2nd-level value {v2} at {k}/{k2}')
            for k3, v3 in v2.items():
                if not isinstance(k3, str):
                    raise ValueError(f'bad 3rd-level key {k3} at ${k}/{k2}')
                if not isinstance(v3, str):
                    raise ValueError(f'bad 3rd-level value {v3} at {k}/{k2}/{k3}')           
1 Like

thank you!! I actually think I just found the issue but will bookmark this for the future.

I could also add this to the export_vcf code.

1 Like