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

Open tokenizer.json within context manager #129

Merged
merged 3 commits into from
Nov 27, 2024

Conversation

neilmehta24
Copy link
Contributor

Seeing this warning:

ResourceWarning: unclosed file <_io.TextIOWrapper name='/Users/neil/.cache/lm-studio/models/mlx-community/pixtral-12b-4bit/tokenizer.json' mode='r' encoding='UTF-8'>
  tokenizer_content = json.load(tokenizer_file.open())

This PR fixes this warning by closing the tokenizer file after reading it.

Copy link
Owner

@Blaizzy Blaizzy left a comment

Choose a reason for hiding this comment

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

Thank you very much for this PR @neilmehta24!

I left a comment and suggestion

mlx_vlm/tokenizer_utils.py Outdated Show resolved Hide resolved
@neilmehta24 neilmehta24 requested a review from Blaizzy November 27, 2024 20:41
@Blaizzy Blaizzy merged commit 7f2c558 into Blaizzy:main Nov 27, 2024
1 check passed
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.

2 participants