コード例 #1
0
def validate_types(schemas_and_tables: list):
    """Normalize a list of desired annotation types
    if passed None returns all types, otherwise checks that types exist

    Parameters
    ----------
    types: list[str] or None

    Returns
    -------
    list[str]
        list of types

    Raises
    ------
    UnknownAnnotationTypeException
        If types contains an invalid type
    """

    all_types = get_types()
    if not (all(schema_name in all_types
                for schema_name, table_name in schemas_and_tables)):

        bad_types = [
            schema_name for schema_name, table_name in schemas_and_tables
            if schema_name not in all_types
        ]

        msg = f"{bad_types} are invalid types"
        raise UnknownAnnotationTypeException(msg)
コード例 #2
0
def make_all_models(datasets):
    model_dict = {}
    types = get_types()
    for dataset in datasets:
        model_dict[dataset] = {}
        for type_ in types:
            model_dict[dataset][type_] = make_annotation_model(dataset, type_)
    return model_dict
コード例 #3
0
 def get(self):
     return get_types()
コード例 #4
0
def test_get_types():
    types = get_types()
    for type_ in types:
        schema = get_schema(type_)
        assert issubclass(schema, AnnotationSchema) or issubclass(
            schema, SpatialPoint)
コード例 #5
0
def test_flatten_all():
    types = get_types()
    for type_ in types:
        Schema = get_flat_schema(type_)
コード例 #6
0
def index():
    schema_types = get_types()

    return render_template("index.html", schema_types=schema_types, version=__version__)