Ejemplo n.º 1
0
def check_schema_version(cls, cls_type):
    if isinstance(cls_type, str):
        if cls_type == 'entityset':
            from featuretools.entityset.serialize import SCHEMA_VERSION
            version_string = cls.get('schema_version')
        elif cls_type == 'features':
            from featuretools.feature_base.features_serializer import SCHEMA_VERSION
            version_string = cls.features_dict['schema_version']

        current = SCHEMA_VERSION.split('.')
        saved = version_string.split('.')

        warning_text_upgrade = (
            'The schema version of the saved %s'
            '(%s) is greater than the latest supported (%s). '
            'You may need to upgrade featuretools. Attempting to load %s ...' %
            (cls_type, version_string, SCHEMA_VERSION, cls_type))
        for c_num, s_num in zip_longest(current, saved, fillvalue=0):
            if c_num > s_num:
                break
            elif c_num < s_num:
                warnings.warn(warning_text_upgrade)
                break

        warning_text_outdated = ('The schema version of the saved %s'
                                 '(%s) is no longer supported by this version '
                                 'of featuretools. Attempting to load %s ...' %
                                 (cls_type, version_string, cls_type))
        # Check if saved has older major version.
        if current[0] > saved[0]:
            warnings.warn(warning_text_outdated)
Ejemplo n.º 2
0
def check_schema_version(cls, cls_type):
    if is_string(cls_type):
        if is_python_2():
            from itertools import izip_longest as zip_longest
        else:
            from itertools import zip_longest

        if cls_type == 'entityset':
            from featuretools.entityset.serialize import SCHEMA_VERSION
            version_string = cls.get('schema_version')
        elif cls_type == 'features':
            from featuretools.feature_base.features_serializer import SCHEMA_VERSION
            version_string = cls.features_dict['schema_version']

        current = SCHEMA_VERSION.split('.')
        saved = version_string.split('.')

        error_text_upgrade = (
            'Unable to load %s. The schema version of the saved '
            '%s (%s) is greater than the latest supported (%s). '
            'You may need to upgrade featuretools.' %
            (cls_type, cls_type, version_string, SCHEMA_VERSION))
        for c_num, s_num in zip_longest(current, saved, fillvalue=0):
            if c_num > s_num:
                break
            elif c_num < s_num:
                raise RuntimeError(error_text_upgrade)

        error_text_outdated = ('Unable to load %s. The schema version '
                               'of the saved %s (%s) is no longer '
                               'supported by this version of featuretools.' %
                               (cls_type, cls_type, version_string))
        # Check if saved has older major version.
        if current[0] > saved[0]:
            raise RuntimeError(error_text_outdated)
Ejemplo n.º 3
0
def test_earlier_schema_version(es):
    def test_version(major, minor, patch, raises=True):
        version = '.'.join([str(v) for v in [major, minor, patch]])
        if raises:
            error_text = ('Unable to load entityset. The schema version of the '
                          'saved entityset (%s) is no longer supported by this '
                          'version of featuretools.'
                          % (version))
        else:
            error_text = None

        _check_schema_version(version, es, error_text)

    major, minor, patch = [int(s) for s in SCHEMA_VERSION.split('.')]

    test_version(major - 1, minor, patch)
    test_version(major, minor - 1, patch, raises=False)
    test_version(major, minor, patch - 1, raises=False)
Ejemplo n.º 4
0
def test_later_schema_version(es):
    def test_version(major, minor, patch, raises=True):
        version = '.'.join([str(v) for v in [major, minor, patch]])
        if raises:
            error_text = ('Unable to load entityset. The schema version of the saved '
                          'entityset (%s) is greater than the latest supported (%s). '
                          'You may need to upgrade featuretools.'
                          % (version, SCHEMA_VERSION))
        else:
            error_text = None

        _check_schema_version(version, es, error_text)

    major, minor, patch = [int(s) for s in SCHEMA_VERSION.split('.')]

    test_version(major + 1, minor, patch)
    test_version(major, minor + 1, patch)
    test_version(major, minor, patch + 1)
    test_version(major, minor - 1, patch + 1, raises=False)
Ejemplo n.º 5
0
def test_earlier_schema_version(es):
    def test_version(major, minor, patch, raises=True):
        version = '.'.join([str(v) for v in [major, minor, patch]])
        if raises:
            warning_text = (
                'The schema version of the saved entityset'
                '(%s) is no longer supported by this version'
                'of featuretools. Attempting to load entityset ...' %
                (version))
        else:
            warning_text = None

        _check_schema_version(version, es, warning_text)

    major, minor, patch = [int(s) for s in SCHEMA_VERSION.split('.')]

    test_version(major - 1, minor, patch)
    test_version(major, minor - 1, patch, raises=False)
    test_version(major, minor, patch - 1, raises=False)
Ejemplo n.º 6
0
def test_later_schema_version(es, caplog):
    def test_version(major, minor, patch, raises=True):
        version = '.'.join([str(v) for v in [major, minor, patch]])
        if raises:
            warning_text = (
                'The schema version of the saved entityset'
                '(%s) is greater than the latest supported (%s). '
                'You may need to upgrade featuretools. Attempting to load entityset ...'
                % (version, SCHEMA_VERSION))
        else:
            warning_text = None

        _check_schema_version(version, es, warning_text, caplog, 'warn')

    major, minor, patch = [int(s) for s in SCHEMA_VERSION.split('.')]

    test_version(major + 1, minor, patch)
    test_version(major, minor + 1, patch)
    test_version(major, minor, patch + 1)
    test_version(major, minor - 1, patch + 1, raises=False)