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

🐛 WordNetCorpusReader has no attribute LazyCorpusLoader #6

Closed
2 tasks done
KamenDimitrov97 opened this issue Aug 13, 2024 · 2 comments · Fixed by #7
Closed
2 tasks done

🐛 WordNetCorpusReader has no attribute LazyCorpusLoader #6

KamenDimitrov97 opened this issue Aug 13, 2024 · 2 comments · Fixed by #7
Assignees
Labels
bug Something isn't working

Comments

@KamenDimitrov97
Copy link
Contributor

Issue Summary

I get a WordNetCorpusReader to have no attribute LazyCorpusLoader when a endpoint is hit seconds after server starts.
If a request is made seconds after the server has started that error pops up when using bonn inside gunicorn server.

The LazyCorpusLoader is like a placeholder that stands in for the actual data until it’s fully loaded. It’s used to avoid loading huge corpora into memory right away. When you first use it, it switches from being a placeholder to the real data object you need.
The real object you need WordNetCorpusReader hasn't loaded when the server is ready to make the call hence the error.

Steps to Reproduce

  1. Start my app.
  2. Setup logging.
  3. Initialize a server using FastApi with a lifespan method.
  4. lifespan is an asyncronus context manager method which, among other things, initializes category manager controller with a fifu_file and settings. I've attached a code_block with my server.
  5. Make a request 3-5 seconds after server is up.
  6. Get an the above mentioned error.

Expected Behavior

It's expected for the category_manager to have loaded.

Actual Behavior

Get an error WordNetCorpusReader to have no attribute LazyCorpusLoader

Environment

  • Linux Fedora 39
  • bonn 0.1.5
  • server version v0.7.0

Possible Solution

Resources used: stack overflow similar issue

Checklist

  • I have reviewed existing issues and confirmed that this issue has not been logged before.
  • I have provided minimal example of expected vs actual behavior.

Note: Please make sure to check if there is already an existing issue similar to yours before submitting a new one. If you find an existing issue,
you can comment on it to provide additional information or to show that you are experiencing the same problem.

@KamenDimitrov97 KamenDimitrov97 added the bug Something isn't working label Aug 13, 2024
@KamenDimitrov97 KamenDimitrov97 changed the title 🐛 WordNetCorpusReader to have no attribute LazyCorpusLoader 🐛 WordNetCorpusReader has no attribute LazyCorpusLoader Aug 13, 2024
@KamenDimitrov97 KamenDimitrov97 self-assigned this Aug 14, 2024
@KamenDimitrov97
Copy link
Contributor Author

I've managed to fix the issue by catching the error, logging an exception and trying again in the same method.
Since the first time WordNetCorpusReader is being called it's a LazyCorpusLoader who's in the process of converting into a WordNetCorpusReader so if you call it once you'll get the error WordNetCorpusReader to have no attribute LazyCorpusLoader
but the second time it'll work as intended.

@KamenDimitrov97
Copy link
Contributor Author

I'm starting to work on ensuring that the stopwords WordListCorpusReader and the wn WordNetCorpusReader is loaded.
Issues is we don't load it ourselves it's being called in the WornetLemmetizer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant