Skip to content

validate_annotation_spec

Validate the annotations.yaml files in the instrumentation directory.

validate_spec(spec_file)

Validate all '.annotations.yaml' files at path and return all invalid items.

Throws yaml.YAMLError

Source code in lineapy/utils/validate_annotation_spec.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
def validate_spec(spec_file: Path) -> List[Any]:
    """
    Validate all '.annotations.yaml' files at path
    and return all invalid items.

    Throws yaml.YAMLError
    """
    invalid_specs: List[Any] = []
    with open(spec_file, "r") as f:
        doc = yaml.safe_load(f)

        for item in doc:
            print(
                "Module specification: {}\n".format(json.dumps(item, indent=4))
            )

            try:
                a = ModuleAnnotation(**item)
            except pydantic.error_wrappers.ValidationError as e:
                invalid_specs.append(item)
    return invalid_specs

Was this helpful?

Help us improve docs with your feedback!