Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yaml.safe_load broke in CI #1048

Closed
ischoegl opened this issue May 31, 2021 · 1 comment · Fixed by #1049
Closed

yaml.safe_load broke in CI #1048

ischoegl opened this issue May 31, 2021 · 1 comment · Fixed by #1049
Labels

Comments

@ischoegl
Copy link
Member

ischoegl commented May 31, 2021

Problem description

After throwing DeprecationWarnings for a while, yaml.safe_load finally broke.

Steps to reproduce

Run GitHub Actions on a PR.

Behavior

The old deprecation warning was:

build/python/cantera/test/test_composite.py::TestSolutionSerialization::test_yaml_outunits
  /home/runner/work/cantera/cantera/build/python/cantera/test/test_composite.py:579: PendingDeprecationWarning: 
  safe_load will be removed, use
  
    yaml=YAML(typ='safe', pure=True)
    yaml.load(...)
  
  instead
    generated = yaml.safe_load(infile)

The error now is:

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <ruamel.yaml.loader.SafeLoader object at 0x7f536a988208>, block = True
indentless_sequence = True

    def parse_node(self, block=False, indentless_sequence=False):
        # type: (bool, bool) -> Any
        if self.scanner.check_token(AliasToken):
            token = self.scanner.get_token()
            event = AliasEvent(token.value, token.start_mark, token.end_mark)  # type: Any
            self.state = self.states.pop()
            return event
    
        anchor = None
        tag = None
        start_mark = end_mark = tag_mark = None
        if self.scanner.check_token(AnchorToken):
            token = self.scanner.get_token()
            self.move_token_comment(token)
            start_mark = token.start_mark
            end_mark = token.end_mark
            anchor = token.value
            if self.scanner.check_token(TagToken):
                token = self.scanner.get_token()
                tag_mark = token.start_mark
                end_mark = token.end_mark
                tag = token.value
        elif self.scanner.check_token(TagToken):
            token = self.scanner.get_token()
            start_mark = tag_mark = token.start_mark
            end_mark = token.end_mark
            tag = token.value
            if self.scanner.check_token(AnchorToken):
                token = self.scanner.get_token()
                start_mark = tag_mark = token.start_mark
                end_mark = token.end_mark
                anchor = token.value
        if tag is not None:
            handle, suffix = tag
            if handle is not None:
                if handle not in self.tag_handles:
                    raise ParserError(
                        'while parsing a node',
                        start_mark,
                        _F('found undefined tag handle {handle!r}', handle=handle),
                        tag_mark,
                    )
                tag = self.transform_tag(handle, suffix)
            else:
                tag = suffix
        # if tag == '!':
        #     raise ParserError("while parsing a node", start_mark,
        #             "found non-specific tag '!'", tag_mark,
        #      "Please check 'http://pyyaml.org/wiki/YAMLNonSpecificTag'
        #     and share your opinion.")
        if start_mark is None:
            start_mark = end_mark = self.scanner.peek_token().start_mark
        event = None
        implicit = tag is None or tag == '!'
        if indentless_sequence and self.scanner.check_token(BlockEntryToken):
            comment = None
            pt = self.scanner.peek_token()
>           if self.loader and self.loader.comment_handling is None:
E           AttributeError: 'SafeLoader' object has no attribute 'comment_handling'

/opt/hostedtoolcache/Python/3.6.13/x64/lib/python3.6/site-packages/ruamel/yaml/parser.py:414: AttributeError
___________ ERROR at setup of TestModels.test_restore_thermo_models ____________

cls = <class 'cantera.test.test_composite.TestModels'>

    @classmethod
    def setUpClass(cls):
        utilities.CanteraTest.setUpClass()
        cls.yml_file = pjoin(cls.test_data_dir, "thermo-models.yaml")
        with open(cls.yml_file, 'rt', encoding="utf-8") as stream:
>           cls.yml = yaml.safe_load(stream)

../../build/python/cantera/test/test_composite.py:27: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/opt/hostedtoolcache/Python/3.6.13/x64/lib/python3.6/site-packages/ruamel/yaml/main.py:1118: in safe_load
    return load(stream, SafeLoader, version)
/opt/hostedtoolcache/Python/3.6.13/x64/lib/python3.6/site-packages/ruamel/yaml/main.py:1071: in load
    return loader._constructor.get_single_data()

System information

  • Cantera version: main
  • OS: GH Actions

Affected Tests

*****************************
***    Testing Summary    ***
scons: building terminated because of errors.
*****************************

Tests passed: 1439
Up-to-date tests skipped: 0
Tests failed: 3
Failed tests:
    - python: test_composite.TestSolutionSerialization.test_yaml_outunits
    - python: test_convert.ck2yamlTest.test_extra
    - python: test_convert.ck2yamlTest.test_sri_zero
*****************************
@ischoegl
Copy link
Member Author

ischoegl commented Jun 2, 2021

The breaking upstream change was apparently reverted, which however still leaves safe_load deprecated and in need of a replacement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant