Exemplo n.º 1
0
from crummycm.validation.types.placeholders.placeholder import (
    KeyPlaceholder,
    ValuePlaceholder,
)
from crummycm.validation.types.dicts.foundation.unnamed_dict import UnnamedDict
from crummycm.validation.types.dicts.foundation.known_dict import KnownDict
from crummycm.validation.types.dicts.config_dict import ConfigDict as CD
from crummycm.validation.types.values.element.numeric import Numeric
from crummycm.validation.types.values.element.text import Text

# from crummycm.validation.types.values.base import BaseValue
cd_outer = CD({
    "my_mixed":
    CD({
        "kd_num": Numeric(default_value=int(0), required=False, is_type=int),
        KeyPlaceholder("some_str", ends_with="_str"): Text(),
        KeyPlaceholder("some_num"): ValuePlaceholder("user_num"),
        "wild_card": ValuePlaceholder("wild_card_value"),
    })
})

no_cd_single = {
    "my_mixed": {
        "kd_num": Numeric(default_value=int(0), required=False, is_type=int),
        KeyPlaceholder("some_str", ends_with="_str"): Text(),
        KeyPlaceholder("some_num"): ValuePlaceholder("user_num"),
        "wild_card": ValuePlaceholder("wild_card_value"),
    }
}

no_cd_single_nested = {
Exemplo n.º 2
0
from crummycm.validation.types.placeholders.placeholder import (
    KeyPlaceholder,
    ValuePlaceholder,
)
from crummycm.validation.types.dicts.foundation.unnamed_dict import UnnamedDict
from crummycm.validation.types.dicts.foundation.known_dict import KnownDict
from crummycm.validation.types.dicts.config_dict import ConfigDict as CD
from crummycm.validation.types.values.element.numeric import Numeric
from crummycm.validation.types.values.element.text import Text

# from crummycm.validation.types.values.base import BaseValue
A_mixed_all_single = {
    "my_mixed": CD(
        {
            "kd_num": Numeric(default_value=int(0), required=False, is_type=int),
            KeyPlaceholder("some_str", ends_with="_str"): Text(),
            KeyPlaceholder("some_num"): ValuePlaceholder("user_num"),
            "wild_card": ValuePlaceholder("wild_card_value"),
        }
    )
}

A_mixed_outter = CD(
    {
        "kd_num": Numeric(default_value=int(0), required=False, is_type=int),
        KeyPlaceholder("some_str", ends_with="_str"): Text(),
        KeyPlaceholder("some_num"): ValuePlaceholder("user_num"),
        "wild_card": ValuePlaceholder("wild_card_value"),
    }
)

A_mixed_all_single_nested = {
Exemplo n.º 3
0
from crummycm.validation.types.placeholders.placeholder import (
    KeyPlaceholder,
    ValuePlaceholder,
)
from crummycm.validation.types.dicts.foundation.unnamed_dict import UnnamedDict
from crummycm.validation.types.dicts.foundation.known_dict import KnownDict
from crummycm.validation.types.dicts.config_dict import ConfigDict as CD
from crummycm.validation.types.values.element.numeric import Numeric
from crummycm.validation.types.values.element.text import Text

no_catchall = CD({
    "my_mixed":
    CD({
        "kd_num": Numeric(default_value=int(0), required=False, is_type=int),
        KeyPlaceholder("some_str", ends_with="_str"): Text(),
        "wild_card": ValuePlaceholder("wild_card_value"),
    })
})

inner_multi_catchall = CD({
    "my_mixed":
    CD({
        "kd_num":
        Numeric(default_value=int(0), required=False, is_type=int),
        KeyPlaceholder("some_str", ends_with="_str"):
        Text(),
        "wild_card":
        ValuePlaceholder("wild_card_value"),
        KeyPlaceholder("anything", multi=True):
        ValuePlaceholder("anything_value"),
    })
Exemplo n.º 4
0
    KeyPlaceholder,
    ValuePlaceholder,
)
from crummycm.validation.types.dicts.foundation.unnamed_dict import UnnamedDict
from crummycm.validation.types.dicts.foundation.known_dict import KnownDict
from crummycm.validation.types.dicts.config_dict import ConfigDict as CD
from crummycm.validation.types.values.element.numeric import Numeric
from crummycm.validation.types.values.element.text import Text

flat_a = {
    "my_mixed":
    CD({
        "kd_num":
        Numeric(default_value=int(0), is_type=int),
        KeyPlaceholder("some_str", ends_with="_str", required=False):
        Text(default_value="DIESEL"),
        KeyPlaceholder("some_num", required=True):
        ValuePlaceholder("user_num"),
        "wild_card":
        ValuePlaceholder("wild_card_value"),
    })
}

nested_a = {
    "my_mixed":
    CD({
        "kd_num":
        Numeric(default_value=int(0), required=False, is_type=int),
        KeyPlaceholder("some_str", ends_with="_str"):
        Text(),
        KeyPlaceholder("some_num"):
        ValuePlaceholder("user_num"),
Exemplo n.º 5
0
from crummycm.validation.types.placeholders.placeholder import (
    KeyPlaceholder,
    ValuePlaceholder,
)

# from crummycm.validation.types.dicts.foundation.unnamed_dict import UnnamedDict
from crummycm.validation.types.dicts.foundation.named_dict import NamedDict
from crummycm.validation.types.dicts.config_dict import ConfigDict as CD

# from crummycm.validation.types.values.element.numeric import Numeric
from crummycm.validation.types.values.element.text import Text

# from crummycm.validation.types.values.base import BaseValue
required_num_false = {
    "my_conf": CD({KeyPlaceholder("my_val"): ValuePlaceholder("some_val")})
}

required_num_true = {
    "my_conf":
    CD({KeyPlaceholder("my_val", required=True): ValuePlaceholder("some_val")})
}
required_num_true_true = {
    "my_conf":
    CD({KeyPlaceholder("my_text", required=True): Text(required=True)})
}

required_num_true_false = {
    "my_conf":
    CD({KeyPlaceholder("my_text", required=True): Text(required=False)})
}
Exemplo n.º 6
0
from crummycm.validation.types.dicts.config_dict import ConfigDict as CD
from crummycm.validation.types.placeholders.placeholder import KeyPlaceholder as KPH
from crummycm.validation.types.values.element.numeric import Numeric
from crummycm.validation.types.values.element.text import Text
from crummycm.validation.types.values.element.bool import Bool
from crummycm.validation.types.values.compound.multi import Multi

ACCEPTED_DTYPES = ["int32", "float32", "int64", "float64"]

DATA = CD({
    "data": {
        "name": Text(required=True, to_lower=True),
        "schema": {
            KPH(name="feature_name", multi=True, required=True): {
                "shape":
                Multi(required=True,
                      is_type=list,
                      element_types=Numeric(is_type=int)),
                "dtype":
                Text(required=True, is_in_list=ACCEPTED_DTYPES),
                KPH("label", exact=True, required=False):
                Bool(required=True),
            }
        },
        "source": Text(required=True, starts_with="http:"),
    }
})
Exemplo n.º 7
0
      shape: [1, 1]
      dtype: "int32"
  source: "http://yann.lecun.com/exdb/mnist/"

"""
ACCEPTED_DTYPES = ["int32", "float32", "int64", "float64"]

TEMPLATE = CD({
    "data":
    CD({
        "name":
        Text(required=True, to_lower=True),
        "schema":
        CD({
            KPH(name="feature_name", multi=True, required=True):
            CD({
                "shape":
                Multi(
                    required=True,
                    is_type=list,
                    element_types=Numeric(is_type=int),
                ),
                "dtype":
                Text(required=True, is_in_list=ACCEPTED_DTYPES),
            })
        }),
        "source":
        Text(required=True, starts_with="http:"),
    })
})