-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Warnings when saving a spacy model during unittest #5230
Comments
Thanks for the report! Definitely something to look into. If you feel like helping out with a PR, that would be most welcome :-) |
Sure, I'll have a look. |
As a side note, the reason this may not have been seen yet appears to be this bug in pytest: |
As suggested by the warning messages, some of the file descriptors declared in |
If it's the same issue, I think it's fine to copy the fix across. The code probably got copied around originally... |
Here' s another question: The interface class The reason I am asking is the following line in if self.model not in (None, True, False):
serialize["model"] = lambda p: p.open("wb").write(self.model.to_bytes()) In particular, can I assume that model will always implement the method |
Short answer: Yes - you can assume that a pipe's Longer answer: when looking at the Meanwhile, Thinc 8 has been released which has |
Thank you for responding so fast. I see, I did not pay attention to the version of Thinc spacy is currently using. Thanks for pointing that out. Actually, I was hoping to use It seems that for a fix it is only necessary to use |
Yea, I think you're right. The |
I think this is similar to the issue when i'm invoking Exception ignored in: <_io.FileIO name='/path/to/thingie/meta.json' mode='wb' closefd=True>
ResourceWarning: unclosed file <_io.TextIOWrapper name='/path/to/thingie/meta.json' mode='w' encoding='UTF-8'>
Exception ignored in: <_io.FileIO name='/path/to/thingie/tagger/model' mode='wb' closefd=True>
ResourceWarning: unclosed file <_io.BufferedWriter name='/path/to/thingie/tagger/model'>
Exception ignored in: <_io.FileIO name='/path/to/thingie/vocab/vectors' mode='wb' closefd=True>
ResourceWarning: unclosed file <_io.BufferedWriter name='/path/to/thingie/vocab/vectors'> Python version: 3.7.7 Which is weird. The only thing I think changed was minor update to python? I was using 2.2.3 a month ago, and then today it's decided to show this error. Note: I'm using it, not unittesting. |
@lfiedler : thanks again for your contributions, this will be included in spaCy 2.3 onwards ! |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
2 similar comments
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
When saving a model during unit testing with
unittest
I get warnings on unclosed files.This happens with custom models as well as with models downloaded from public repository.
Running with unittest results in:
This seems to be a bug similar as to #1706, which was related to loading models and has been fixed. However, it seems that saving a model also does not properly close files.
Since this can be muted easily, this is not much of an issue for me. Still though, might as well report it.
The text was updated successfully, but these errors were encountered: