Skip to content

schemavalidation

schemavalidation

Module for the validating schemas

Classes

Functions

get_expmembers_from_class

get_expmembers_from_class(cls)

Returns all ExpMember from a given class

Source code in niceml/experiments/schemas/schemavalidation.py
def get_expmembers_from_class(cls) -> List[ExpMember]:
    """Returns all ExpMember from a given class"""
    exp_member_list: List[ExpMember] = [
        getattr(cls, member_name)
        for member_name in dir(cls)
        if isinstance(getattr(cls, member_name), ExpMember)
    ]
    return exp_member_list

validate_schema

validate_schema(exp_data, schema)

validates the instance with the given schema

Source code in niceml/experiments/schemas/schemavalidation.py
def validate_schema(exp_data: ExperimentData, schema) -> bool:
    """validates the instance with the given schema"""
    exp_member_list: List[ExpMember] = get_expmembers_from_class(schema)
    is_valid_list = [x.validate(exp_data) for x in exp_member_list]
    return all(is_valid_list)