Skip to content

[fix] parser json.load PosixPath bug#10354

Open
Belle0918 wants to merge 2 commits intohiyouga:mainfrom
Belle0918:fix_json_load_posixpath
Open

[fix] parser json.load PosixPath bug#10354
Belle0918 wants to merge 2 commits intohiyouga:mainfrom
Belle0918:fix_json_load_posixpath

Conversation

@Belle0918
Copy link
Copy Markdown

What does this PR do?

Fix an AttributeError in read_args() when loading config from a JSON file.
json.load() expects a file-like object, but the code passes a PosixPath. Use Path.read_text() + json.loads() instead.

Fixes #10316

Before submitting

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the JSON argument parsing logic in src/llamafactory/hparams/parser.py to correctly read file contents before parsing. A review comment suggests using OmegaConf.load() to simplify the implementation and improve consistency with the existing YAML loading logic.

Aligns with the existing YAML loading approach.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
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.

'PosixPath' object has no attribute 'read'

1 participant