def test_later_schema_version(es):
    def test_version(major, minor, patch, raises=True):
        version = '.'.join([str(v) for v in [major, minor, patch]])
        dictionary = {
            'ft_version': ft.__version__,
            'schema_version': version,
            'entityset': es.to_dictionary(),
            'feature_list': [],
            'feature_definitions': {}
        }

        error_text = (
            'Unable to load features. The schema version of the saved '
            'features (%s) is greater than the latest supported (%s). '
            'You may need to upgrade featuretools.' %
            (version, SCHEMA_VERSION))

        if raises:
            with pytest.raises(RuntimeError) as excinfo:
                FeaturesDeserializer(dictionary)

            assert error_text == str(excinfo.value)
        else:
            FeaturesDeserializer(dictionary)

    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 - 1, minor + 1, patch, raises=False)
    test_version(major - 1, minor, patch + 1, raises=False)
    test_version(major, minor - 1, patch + 1, raises=False)
    def _check_schema_version(self):
        current = SCHEMA_VERSION.split('.')
        saved = self.features_dict['schema_version'].split('.')
        error_text = (
            'Unable to load features. The schema version of the saved '
            'features (%s) is greater than the latest supported (%s). '
            'You may need to upgrade featuretools.' %
            (self.features_dict['schema_version'], 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)
def test_earlier_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 features"
                "(%s) is no longer supported by this version "
                "of featuretools. Attempting to load features ..." % (version))
        else:
            warning_text = None

        _check_schema_version(version, es, warning_text, caplog, "log")

    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)
Exemple #4
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 features'
                '(%s) is no longer supported by this version '
                'of featuretools. Attempting to load features ...' % (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)
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 features. The schema version of the '
                          'saved features (%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)
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 features. The schema version of the saved '
                          'features (%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)
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 features"
                "(%s) is greater than the latest supported (%s). "
                "You may need to upgrade featuretools. Attempting to load features ..."
                % (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)
    def _check_schema_version(self):
        current = SCHEMA_VERSION.split('.')
        version_string = self.features_dict['schema_version']
        saved = version_string.split('.')

        # Check if saved has older major version.
        if current[0] > saved[0]:
            raise RuntimeError('Unable to load features. The schema version '
                               'of the saved features (%s) is no longer '
                               'supported by this version of featuretools.'
                               % version_string)

        error_text = ('Unable to load features. The schema version of the saved '
                      'features (%s) is greater than the latest supported (%s). '
                      'You may need to upgrade featuretools.'
                      % (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)