installing on Arch fails due to pykwalify rules error #85

Closed
opened 2018-08-10 09:54:02 +00:00 by bjo · 2 comments

=================================== FAILURES ===================================
____________ test_parse_configuration_transforms_file_into_mapping _____________

    def test_parse_configuration_transforms_file_into_mapping():
        mock_config_and_schema(
            '''
            location:
                source_directories:
                    - /home
                    - /etc
    
                repositories:
                    - hostname.borg
    
            retention:
                keep_minutely: 60
                keep_hourly: 24
                keep_daily: 7
    
            consistency:
                checks:
                    - repository
                    - archives
            '''
        )
    
>       result = module.parse_configuration('config.yaml', 'schema.yaml')

borgmatic/tests/integration/config/test_validate.py:58: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
borgmatic/config/validate.py:89: in parse_configuration
    parsed_result = validator.validate(raise_exception=False)
/usr/lib/python3.7/site-packages/pykwalify/core.py:164: in validate
    self._start_validate(self.source)
/usr/lib/python3.7/site-packages/pykwalify/core.py:206: in _start_validate
    root_rule = Rule(schema=self.schema)
/usr/lib/python3.7/site-packages/pykwalify/rule.py:64: in __init__
    self.init(schema, "")
/usr/lib/python3.7/site-packages/pykwalify/rule.py:428: in init
    func_mapping[k](v, rule, path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <pykwalify.rule.Rule object at 0x7fa95d5d7d30>
v = ordereddict([('location', ordereddict([('desc', 'Where to look for files to backup, and where to store those backups. ...)]), ('desc', 'List of one or more shell commands or scripts to execute in case an exception has occurred.')]))]))]))])
rule = <pykwalify.rule.Rule object at 0x7fa95d5d7d30>, path = ''

    def init_mapping_value(self, v, rule, path):
        """
            """
        # Check for duplicate use of 'map' and 'mapping'
        if self.mapping:
            raise RuleError(
                msg=u"Keywords 'map' and 'mapping' can't be used on the same level",
                error_key=u"mapping.duplicate_keywords",
                path=path,
            )
    
        log.debug(u"Init mapping value : %s", path)
    
        if v is not None and not isinstance(v, dict):
            raise RuleError(
                msg=u"Value for keyword 'map/mapping' is not a dict",
                error_key=u"mapping.not_dict",
>               path=path,
            )
E           pykwalify.errors.RuleError: <RuleError: error code 4: Value for keyword 'map/mapping' is not a dict: Path: '/'>

/usr/lib/python3.7/site-packages/pykwalify/rule.py:1105: RuleError
__________ test_parse_configuration_passes_through_quoted_punctuation __________

    def test_parse_configuration_passes_through_quoted_punctuation():
        escaped_punctuation = string.punctuation.replace('\\', r'\\').replace('"', r'\"')
    
        mock_config_and_schema(
            '''
            location:
                source_directories:
                    - /home
    
                repositories:
                    - "{}.borg"
            '''.format(escaped_punctuation)
        )
    
>       result = module.parse_configuration('config.yaml', 'schema.yaml')

borgmatic/tests/integration/config/test_validate.py:81: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
borgmatic/config/validate.py:89: in parse_configuration
    parsed_result = validator.validate(raise_exception=False)
/usr/lib/python3.7/site-packages/pykwalify/core.py:164: in validate
    self._start_validate(self.source)
/usr/lib/python3.7/site-packages/pykwalify/core.py:206: in _start_validate
    root_rule = Rule(schema=self.schema)
/usr/lib/python3.7/site-packages/pykwalify/rule.py:64: in __init__
    self.init(schema, "")
/usr/lib/python3.7/site-packages/pykwalify/rule.py:428: in init
    func_mapping[k](v, rule, path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <pykwalify.rule.Rule object at 0x7fa95d4c8588>
v = ordereddict([('location', ordereddict([('desc', 'Where to look for files to backup, and where to store those backups. ...)]), ('desc', 'List of one or more shell commands or scripts to execute in case an exception has occurred.')]))]))]))])
rule = <pykwalify.rule.Rule object at 0x7fa95d4c8588>, path = ''

    def init_mapping_value(self, v, rule, path):
        """
            """
        # Check for duplicate use of 'map' and 'mapping'
        if self.mapping:
            raise RuleError(
                msg=u"Keywords 'map' and 'mapping' can't be used on the same level",
                error_key=u"mapping.duplicate_keywords",
                path=path,
            )
    
        log.debug(u"Init mapping value : %s", path)
    
        if v is not None and not isinstance(v, dict):
            raise RuleError(
                msg=u"Value for keyword 'map/mapping' is not a dict",
                error_key=u"mapping.not_dict",
>               path=path,
            )
E           pykwalify.errors.RuleError: <RuleError: error code 4: Value for keyword 'map/mapping' is not a dict: Path: '/'>

/usr/lib/python3.7/site-packages/pykwalify/rule.py:1105: RuleError
_____ test_parse_configuration_with_schema_lacking_examples_does_not_raise _____

    def test_parse_configuration_with_schema_lacking_examples_does_not_raise():
        mock_config_and_schema(
            '''
            location:
                source_directories:
                    - /home
    
                repositories:
                    - hostname.borg
            ''',
            '''
            map:
                location:
                    required: true
                    map:
                        source_directories:
                            required: true
                            seq:
                                - type: scalar
                        repositories:
                            required: true
                            seq:
                                - type: scalar
            '''
        )
    
>       module.parse_configuration('config.yaml', 'schema.yaml')

borgmatic/tests/integration/config/test_validate.py:117: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
borgmatic/config/validate.py:89: in parse_configuration
    parsed_result = validator.validate(raise_exception=False)
/usr/lib/python3.7/site-packages/pykwalify/core.py:164: in validate
    self._start_validate(self.source)
/usr/lib/python3.7/site-packages/pykwalify/core.py:206: in _start_validate
    root_rule = Rule(schema=self.schema)
/usr/lib/python3.7/site-packages/pykwalify/rule.py:64: in __init__
    self.init(schema, "")
/usr/lib/python3.7/site-packages/pykwalify/rule.py:428: in init
    func_mapping[k](v, rule, path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <pykwalify.rule.Rule object at 0x7fa95d3dd748>
v = ordereddict([('location', ordereddict([('required', True), ('map', ordereddict([('source_directories', ordereddict([('...lar')])])])), ('repositories', ordereddict([('required', True), ('seq', [ordereddict([('type', 'scalar')])])]))]))]))])
rule = <pykwalify.rule.Rule object at 0x7fa95d3dd748>, path = ''

    def init_mapping_value(self, v, rule, path):
        """
            """
        # Check for duplicate use of 'map' and 'mapping'
        if self.mapping:
            raise RuleError(
                msg=u"Keywords 'map' and 'mapping' can't be used on the same level",
                error_key=u"mapping.duplicate_keywords",
                path=path,
            )
    
        log.debug(u"Init mapping value : %s", path)
    
        if v is not None and not isinstance(v, dict):
            raise RuleError(
                msg=u"Value for keyword 'map/mapping' is not a dict",
                error_key=u"mapping.not_dict",
>               path=path,
            )
E           pykwalify.errors.RuleError: <RuleError: error code 4: Value for keyword 'map/mapping' is not a dict: Path: '/'>

/usr/lib/python3.7/site-packages/pykwalify/rule.py:1105: RuleError
_____________ test_parse_configuration_raises_for_validation_error _____________

    def test_parse_configuration_raises_for_validation_error():
        mock_config_and_schema(
            '''
            location:
                source_directories: yes
                repositories:
                    - hostname.borg
            '''
        )
    
        with pytest.raises(module.Validation_error):
>           module.parse_configuration('config.yaml', 'schema.yaml')

borgmatic/tests/integration/config/test_validate.py:152: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
borgmatic/config/validate.py:89: in parse_configuration
    parsed_result = validator.validate(raise_exception=False)
/usr/lib/python3.7/site-packages/pykwalify/core.py:164: in validate
    self._start_validate(self.source)
/usr/lib/python3.7/site-packages/pykwalify/core.py:206: in _start_validate
    root_rule = Rule(schema=self.schema)
/usr/lib/python3.7/site-packages/pykwalify/rule.py:64: in __init__
    self.init(schema, "")
/usr/lib/python3.7/site-packages/pykwalify/rule.py:428: in init
    func_mapping[k](v, rule, path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <pykwalify.rule.Rule object at 0x7fa95d4d7b00>
v = ordereddict([('location', ordereddict([('desc', 'Where to look for files to backup, and where to store those backups. ...)]), ('desc', 'List of one or more shell commands or scripts to execute in case an exception has occurred.')]))]))]))])
rule = <pykwalify.rule.Rule object at 0x7fa95d4d7b00>, path = ''

    def init_mapping_value(self, v, rule, path):
        """
            """
        # Check for duplicate use of 'map' and 'mapping'
        if self.mapping:
            raise RuleError(
                msg=u"Keywords 'map' and 'mapping' can't be used on the same level",
                error_key=u"mapping.duplicate_keywords",
                path=path,
            )
    
        log.debug(u"Init mapping value : %s", path)
    
        if v is not None and not isinstance(v, dict):
            raise RuleError(
                msg=u"Value for keyword 'map/mapping' is not a dict",
                error_key=u"mapping.not_dict",
>               path=path,
            )
E           pykwalify.errors.RuleError: <RuleError: error code 4: Value for keyword 'map/mapping' is not a dict: Path: '/'>

/usr/lib/python3.7/site-packages/pykwalify/rule.py:1105: RuleError
===================== 4 failed, 176 passed in 1.76 seconds =====================
``` =================================== FAILURES =================================== ____________ test_parse_configuration_transforms_file_into_mapping _____________ def test_parse_configuration_transforms_file_into_mapping(): mock_config_and_schema( ''' location: source_directories: - /home - /etc repositories: - hostname.borg retention: keep_minutely: 60 keep_hourly: 24 keep_daily: 7 consistency: checks: - repository - archives ''' ) > result = module.parse_configuration('config.yaml', 'schema.yaml') borgmatic/tests/integration/config/test_validate.py:58: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ borgmatic/config/validate.py:89: in parse_configuration parsed_result = validator.validate(raise_exception=False) /usr/lib/python3.7/site-packages/pykwalify/core.py:164: in validate self._start_validate(self.source) /usr/lib/python3.7/site-packages/pykwalify/core.py:206: in _start_validate root_rule = Rule(schema=self.schema) /usr/lib/python3.7/site-packages/pykwalify/rule.py:64: in __init__ self.init(schema, "") /usr/lib/python3.7/site-packages/pykwalify/rule.py:428: in init func_mapping[k](v, rule, path) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pykwalify.rule.Rule object at 0x7fa95d5d7d30> v = ordereddict([('location', ordereddict([('desc', 'Where to look for files to backup, and where to store those backups. ...)]), ('desc', 'List of one or more shell commands or scripts to execute in case an exception has occurred.')]))]))]))]) rule = <pykwalify.rule.Rule object at 0x7fa95d5d7d30>, path = '' def init_mapping_value(self, v, rule, path): """ """ # Check for duplicate use of 'map' and 'mapping' if self.mapping: raise RuleError( msg=u"Keywords 'map' and 'mapping' can't be used on the same level", error_key=u"mapping.duplicate_keywords", path=path, ) log.debug(u"Init mapping value : %s", path) if v is not None and not isinstance(v, dict): raise RuleError( msg=u"Value for keyword 'map/mapping' is not a dict", error_key=u"mapping.not_dict", > path=path, ) E pykwalify.errors.RuleError: <RuleError: error code 4: Value for keyword 'map/mapping' is not a dict: Path: '/'> /usr/lib/python3.7/site-packages/pykwalify/rule.py:1105: RuleError __________ test_parse_configuration_passes_through_quoted_punctuation __________ def test_parse_configuration_passes_through_quoted_punctuation(): escaped_punctuation = string.punctuation.replace('\\', r'\\').replace('"', r'\"') mock_config_and_schema( ''' location: source_directories: - /home repositories: - "{}.borg" '''.format(escaped_punctuation) ) > result = module.parse_configuration('config.yaml', 'schema.yaml') borgmatic/tests/integration/config/test_validate.py:81: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ borgmatic/config/validate.py:89: in parse_configuration parsed_result = validator.validate(raise_exception=False) /usr/lib/python3.7/site-packages/pykwalify/core.py:164: in validate self._start_validate(self.source) /usr/lib/python3.7/site-packages/pykwalify/core.py:206: in _start_validate root_rule = Rule(schema=self.schema) /usr/lib/python3.7/site-packages/pykwalify/rule.py:64: in __init__ self.init(schema, "") /usr/lib/python3.7/site-packages/pykwalify/rule.py:428: in init func_mapping[k](v, rule, path) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pykwalify.rule.Rule object at 0x7fa95d4c8588> v = ordereddict([('location', ordereddict([('desc', 'Where to look for files to backup, and where to store those backups. ...)]), ('desc', 'List of one or more shell commands or scripts to execute in case an exception has occurred.')]))]))]))]) rule = <pykwalify.rule.Rule object at 0x7fa95d4c8588>, path = '' def init_mapping_value(self, v, rule, path): """ """ # Check for duplicate use of 'map' and 'mapping' if self.mapping: raise RuleError( msg=u"Keywords 'map' and 'mapping' can't be used on the same level", error_key=u"mapping.duplicate_keywords", path=path, ) log.debug(u"Init mapping value : %s", path) if v is not None and not isinstance(v, dict): raise RuleError( msg=u"Value for keyword 'map/mapping' is not a dict", error_key=u"mapping.not_dict", > path=path, ) E pykwalify.errors.RuleError: <RuleError: error code 4: Value for keyword 'map/mapping' is not a dict: Path: '/'> /usr/lib/python3.7/site-packages/pykwalify/rule.py:1105: RuleError _____ test_parse_configuration_with_schema_lacking_examples_does_not_raise _____ def test_parse_configuration_with_schema_lacking_examples_does_not_raise(): mock_config_and_schema( ''' location: source_directories: - /home repositories: - hostname.borg ''', ''' map: location: required: true map: source_directories: required: true seq: - type: scalar repositories: required: true seq: - type: scalar ''' ) > module.parse_configuration('config.yaml', 'schema.yaml') borgmatic/tests/integration/config/test_validate.py:117: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ borgmatic/config/validate.py:89: in parse_configuration parsed_result = validator.validate(raise_exception=False) /usr/lib/python3.7/site-packages/pykwalify/core.py:164: in validate self._start_validate(self.source) /usr/lib/python3.7/site-packages/pykwalify/core.py:206: in _start_validate root_rule = Rule(schema=self.schema) /usr/lib/python3.7/site-packages/pykwalify/rule.py:64: in __init__ self.init(schema, "") /usr/lib/python3.7/site-packages/pykwalify/rule.py:428: in init func_mapping[k](v, rule, path) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pykwalify.rule.Rule object at 0x7fa95d3dd748> v = ordereddict([('location', ordereddict([('required', True), ('map', ordereddict([('source_directories', ordereddict([('...lar')])])])), ('repositories', ordereddict([('required', True), ('seq', [ordereddict([('type', 'scalar')])])]))]))]))]) rule = <pykwalify.rule.Rule object at 0x7fa95d3dd748>, path = '' def init_mapping_value(self, v, rule, path): """ """ # Check for duplicate use of 'map' and 'mapping' if self.mapping: raise RuleError( msg=u"Keywords 'map' and 'mapping' can't be used on the same level", error_key=u"mapping.duplicate_keywords", path=path, ) log.debug(u"Init mapping value : %s", path) if v is not None and not isinstance(v, dict): raise RuleError( msg=u"Value for keyword 'map/mapping' is not a dict", error_key=u"mapping.not_dict", > path=path, ) E pykwalify.errors.RuleError: <RuleError: error code 4: Value for keyword 'map/mapping' is not a dict: Path: '/'> /usr/lib/python3.7/site-packages/pykwalify/rule.py:1105: RuleError _____________ test_parse_configuration_raises_for_validation_error _____________ def test_parse_configuration_raises_for_validation_error(): mock_config_and_schema( ''' location: source_directories: yes repositories: - hostname.borg ''' ) with pytest.raises(module.Validation_error): > module.parse_configuration('config.yaml', 'schema.yaml') borgmatic/tests/integration/config/test_validate.py:152: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ borgmatic/config/validate.py:89: in parse_configuration parsed_result = validator.validate(raise_exception=False) /usr/lib/python3.7/site-packages/pykwalify/core.py:164: in validate self._start_validate(self.source) /usr/lib/python3.7/site-packages/pykwalify/core.py:206: in _start_validate root_rule = Rule(schema=self.schema) /usr/lib/python3.7/site-packages/pykwalify/rule.py:64: in __init__ self.init(schema, "") /usr/lib/python3.7/site-packages/pykwalify/rule.py:428: in init func_mapping[k](v, rule, path) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pykwalify.rule.Rule object at 0x7fa95d4d7b00> v = ordereddict([('location', ordereddict([('desc', 'Where to look for files to backup, and where to store those backups. ...)]), ('desc', 'List of one or more shell commands or scripts to execute in case an exception has occurred.')]))]))]))]) rule = <pykwalify.rule.Rule object at 0x7fa95d4d7b00>, path = '' def init_mapping_value(self, v, rule, path): """ """ # Check for duplicate use of 'map' and 'mapping' if self.mapping: raise RuleError( msg=u"Keywords 'map' and 'mapping' can't be used on the same level", error_key=u"mapping.duplicate_keywords", path=path, ) log.debug(u"Init mapping value : %s", path) if v is not None and not isinstance(v, dict): raise RuleError( msg=u"Value for keyword 'map/mapping' is not a dict", error_key=u"mapping.not_dict", > path=path, ) E pykwalify.errors.RuleError: <RuleError: error code 4: Value for keyword 'map/mapping' is not a dict: Path: '/'> /usr/lib/python3.7/site-packages/pykwalify/rule.py:1105: RuleError ===================== 4 failed, 176 passed in 1.76 seconds ===================== ```
Owner

Thanks for filing. Looks like this is the same issue mentioned in this pull request, and likely caused by an incompatibility in newer versions of ruamel.yaml.

Thanks for filing. Looks like this is the same issue mentioned in [this pull request](https://github.com/witten/borgmatic/pull/23), and likely caused by an incompatibility in newer versions of `ruamel.yaml`.
Owner

Okay, I believe this is now fixed in borgmatic 1.2.2, just released. I managed to change borgmatic's use of ruamel.yaml to load the config and the schema in such a way that pykwalify no longer explodes. I confirmed that the changed code works with both ruamel.yaml 0.15.51 and 0.15.52 (before and after the breaking change, respectively).

Okay, I believe this is now fixed in borgmatic 1.2.2, just released. I managed to change borgmatic's use of `ruamel.yaml` to load the config and the schema in such a way that pykwalify no longer explodes. I confirmed that the changed code works with both `ruamel.yaml` 0.15.51 and 0.15.52 (before and after the breaking change, respectively).
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#85
No description provided.