Example #1
0
def idclass_schema(dirpath_lwc_root=None):
    """
    Return a table of idclass schemata.

    """
    return dict(
        (name, Schema(Match(regex, expected='id: ' + name)))
        for (name, regex) in da.idclass.regex_table(dirpath_lwc_root).items())
Example #2
0
def get():
    """
    Return the data validation schema for the identifier class register.

    """
    common = da.check.schema.common

    return Schema({
        'title': common.TITLE_TEXT,
        'introduction': common.PARAGRAPH_TEXT,
        'register': {
            common.LOWERCASE_NAME: {
                'desc': common.TITLE_TEXT,
                Optional('pfix'): Match(r'[a-z]{1,3}'),
                Optional('dgts'): Range(1, 12),
                Optional('expr'): str,
                'note': common.PARAGRAPH_TEXT
            }
        },
        Extra: Reject
    })
compile_schema = Schema({
    'optimizer': str,
    'loss': str,
}, extra_keys=Allow)

fit_schema = Schema({'epochs': int}, extra_keys=Allow)

instance_schema = Schema({
    'data': data_schema,
    'sampling': sampling_schema,
    'architecture': architecture_schema,
    'compile': compile_schema,
    'fit': fit_schema,
    'batch_ratio': float,
    Optional(Match(r'notes.*')): str,
})

# ########## Schemata for base configs ########## #
list_msg = '\'list\' must be a sequence of mappings.'
prod_msg = '\'product\' must be a sequence of sequences of mappings.'
experiment_schema = Schema({
    'name':
    str,
    # Must be any dict
    'base_config':
    Schema({}, extra_keys=Allow),
    # only one of 'list_config' or 'product_config' are allowed
    # Must be a list of dicts
    Optional('list'):
    Msg(All(Schema([Schema({}, extra_keys=Allow)]), Length(min=1)), list_msg),
Example #4
0
# -*- coding: utf-8 -*-

from good import Schema, All, Required, Optional, Length, Match, Email

login_schema = Schema({
    Required('login'): unicode,
    Required('password'): unicode
})

signup_schema = Schema({
    Required('username'):
    All(unicode, Match(r'^[\w.]+$'), Length(max=32)),
    Required('email'):
    Email(),
    Required('password'):
    All(unicode, Length(min=3, max=32))
})

edit_schema = Schema({
    Optional('firstname'):
    All(unicode, Length(max=32)),
    Optional('lastname'):
    All(unicode, Length(max=32)),
    Optional('password'):
    Schema({
        Required('old'): All(unicode, Length(min=3, max=32)),
        Required('new'): All(unicode, Length(min=3, max=32))
    })
})
Example #5
0
def get(idclass_schema_tab):
    """
    Return the data validation schema for the codeword register.

    """
    common = da.check.schema.common

    # The quantifier is used to define the
    # relationship between the bounding box
    # and the target entity.
    #
    quantifier = Any(

        # The target object is present everywhere within the ROI.
        #
        # Any declarations falling within the ROI can be considered a true
        # positive. On the other hand, an absence of declarations should only
        # be considered as a missed detection if all detection criteria have
        # been met by the target.
        #
        # Used for probability-of-detection KPI metrics.
        #
        'all'

        # A target object may be present somewhere within the ROI.
        #
        # A declaration falling within the ROI cannot definitively be
        # classified as either a true positive or a false alarm. This
        # quantifier is intended to be used in conjunction with not_exist
        # labels in false alarm rate tests to screen off parts of the data
        # stream that might contain real targets and that should not
        # contribute to false alarm rate metrics.
        #
        'exist',

        # Unless otherwise specified, no target object is present in any part
        # of the ROI.
        #
        # If no other label matches, then a detection in the ROI is
        # definitely a false alarm. Used for false alarm rate tests to
        # identify parts of the data stream that do not contain real targets.
        #
        'not_exist',
    )
    # The bounding_box is used to define a region
    # of interest within the image. In conjunction
    # with the lo/hi byte offsets it may be used
    # to
    bounding_box = Schema({

        # Upper left column (inclusive).
        'ulc': int,

        # Upper left row (inclusive).
        'ulr': int,

        # Lower right column (exclusive).
        'lrc': int,

        # Lower right row (exclusive).
        'lrr': int,
    })

    line_segment = Schema({

        # Upper left column (inclusive).
        'ulc': int,

        # Upper left row (inclusive).
        'ulr': int,

        # Lower right column (exclusive).
        'lrc': int,

        # Lower right row (exclusive).
        'lrr': int,
    })

    compact_target_type = Any(Match('generic_target'))

    extended_target_type = Any(Match('generic_horizon'))

    compact_target_label = Schema({

        # Bounding box.
        "box": bounding_box,

        # Quantifier.
        'qua': quantifier,

        # Target type.
        'typ': compact_target_type
    })

    extended_target_label = Schema({

        # Line segment.
        'lin': line_segment,

        # Quantifier.
        'qua': quantifier,

        # Target type.
        'typ': extended_target_type
    })

    return Schema({

        # Label format type.
        'typ': common.LOWERCASE_NAME,

        # Label format version.
        'ver': int,

        # Unique identifier (GUID).
        'uid': common.LOWERCASE_HEX,

        # Trace to requirement.
        'req': [idclass_schema_tab['item']],

        # Trace to team member responsible.
        'rsp': [idclass_schema_tab['team_member']],

        # Start byte (inclusive) of byte range of interest.
        'lo': common.NUMERIC_STRING,

        # End byte (exclusive) of byte range of interest.
        'hi': common.NUMERIC_STRING,

        # Function specific label payload.
        'lbl': Any(compact_target_label, extended_target_label),
        Extra: Reject
    })
Example #6
0
# -*- coding: utf-8 -*-

from good import Schema, All, Required, Length, Match, Email


signup = Schema({
    Required('username'): All(unicode, Match(r'^[a-zA-Z0-9_]+$')),
    Required('email'): Email(),
    Required('password'): All(unicode, Length(min=5))
})
Example #7
0
        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an AS IS BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License."
...
"""

import da.idclass
from good import (All, Any, Coerce, Match, Optional, Required, Schema, Extra,
                  Reject)

TITLE_TEXT = Schema(Match(r'[A-Z]{1}[\w,. -]{2,74}\.', expected='Title text'))

SUMMARY_TEXT = Schema(
    Match(r'[A-Z]{1}[\w,.\n -]{3,256}', expected='Summary text'))

PARAGRAPH_TEXT = Schema(
    Match(r'[A-Z]{1}[\w,.\n :;-]{6,1024}', expected='Paragraph text'))

LOWERCASE_NAME = Schema(
    Match(r'[a-z0-9_ ]', expected='Lowercase underscore delimited name'))

LOWERCASE_PATH = Schema(Match(r'[.a-z0-9_/]', expected='Lowercase file path'))

URL = Schema(Match(r'[A-Za-z0-9_/:]', expected='URL'))

EMAIL_ADDRESS = Schema(
Example #8
0
# -*- coding: utf-8 -*-
__author__ = 'AminHP'

# python imports
from good import Schema, All, Required, Optional, Length, Match, Email

# project imports
from project.modules.recaptcha_validator import ReCaptcha


signup_schema = Schema({
    Required('username'): All(unicode, Match(r'^[a-zA-Z0-9_]*$'), Length(min=1, max=32)),
    Required('email'): Email(),
    Required('password'): All(unicode, Length(min=3, max=32)),
    Required('recaptcha'): ReCaptcha()
})


login_schema = Schema({
    Required('login'): unicode,
    Required('password'): unicode
})


edit_schema = Schema({
    Optional('email'): Email(),
    Optional('password'): Schema({
        Required('old_password'): All(unicode, Length(min=3, max=32)),
        Required('new_password'): All(unicode, Length(min=3, max=32))
    }),
    Optional('firstname'): All(unicode, Length(min=1, max=32)),