Skip to content

[Fix YAML Parsing] Replace deprecated yaml.load() usage and update ruamel.yaml dependencies #247

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

pm25
Copy link
Contributor

@pm25 pm25 commented May 17, 2025

What does this PR do?

This PR addresses an issue related to YAML parsing. Specifically, using:

dic = yaml.load(f.read(), Loader=yaml.Loader)

(from semilearn/core/utils/misc.py#L25)

raises the following error with newer versions of ruamel.yaml:

AttributeError: "load()" has been removed, use YAML(typ='rt') instead.

To resolve this, I updated the code to use the recommended interface:

from ruamel.yaml import YAML

yaml = YAML(typ='rt')
with open(yml, 'r', encoding='utf-8') as f:
    dic = yaml.load(f)

I also updated the dependencies in requirements.txt to ensure compatibility:

  • ruamel.yaml >= 0.18.0
  • ruamel.yaml.clib >= 0.2.7

These versions are required for the YAML(typ='rt') interface to work as expected.

Does your PR introduce any breaking changes? If yes, please list them.

No. I verified that all packages listed in requirements.txt can be installed with their minimal versions without error. I also tested the FixMatch implementation and confirmed that it runs smoothly with the updated YAML handling and dependencies.

Before submitting

  • Was this discussed/approved via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you list all the breaking changes introduced by this pull request?

PR review

Anyone in the community is welcome to review the PR.
Before you start reviewing, make sure you have read the review guidelines. In short, see the following bullet-list:

  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

@pm25 pm25 changed the title Mypatch4 [Fix YAML Parsing] Replace deprecated yaml.load() usage and update ruamel.yaml dependencies May 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant