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

Collect errors from automatic suggestion backends #9638

Open
nijel opened this issue Jul 27, 2023 · 9 comments
Open

Collect errors from automatic suggestion backends #9638

nijel opened this issue Jul 27, 2023 · 9 comments
Labels
enhancement Adding or requesting a new feature. good first issue Opportunity for newcoming contributors. hacktoberfest This is suitable for Hacktoberfest. Don’t try to spam. help wanted Extra attention is needed.

Comments

@nijel
Copy link
Member

nijel commented Jul 27, 2023

Describe the problem

Currently, automatic suggestion backends silent themselves for errors which are most likely caused by rate limiting:

def is_rate_limit_error(self, exc):
if isinstance(exc, MachineryRateLimit):
return True
if not isinstance(exc, HTTPError):
return False
# Apply rate limiting for following status codes:
# HTTP 456 Client Error: Quota Exceeded (DeepL)
# HTTP 429 Too Many Requests
# HTTP 401 Unauthorized
# HTTP 403 Forbidden
# HTTP 503 Service Unavailable
if exc.response.status_code in (456, 429, 401, 403, 503):
return True
return False

This is nice for user viewed suggestions as it doesn't show an error message on each page.

But this makes such errors invisible to admins.

Describe the solution you'd like

Collect such errors and display them in the management interface.

Describe alternatives you've considered

No response

Screenshots

No response

Additional context

No response

@nijel nijel added enhancement Adding or requesting a new feature. hacktoberfest This is suitable for Hacktoberfest. Don’t try to spam. help wanted Extra attention is needed. good first issue Opportunity for newcoming contributors. labels Jul 27, 2023
@github-actions
Copy link

This issue seems to be a good fit for newbie contributors. You are welcome to contribute to Weblate! Don't hesitate to ask any questions you would have while implementing this.

You can learn about how to get started in our contributors documentation.

@AbdullahHabib-github
Copy link

I've over 3 years of experience in Python development and would love to contribute. @nijel Can you please assign this issue to me?

@nijel nijel assigned nijel and AbdullahHabib-github and unassigned nijel Aug 11, 2023
@nijel
Copy link
Member Author

nijel commented Aug 11, 2023

@AbdullahHabib-github you're welcome!

@AbdullahHabib-github
Copy link

@nijel should I create a new view or am I supposed to integrate it in any of the existing views?

@nijel
Copy link
Member Author

nijel commented Aug 14, 2023

There is already a view for managing automatic suggestions in https://github.com/WeblateOrg/weblate/blob/main/weblate/machinery/views.py, I think it should display such errors next to the configuration.

Something similar can be seen on GitHub webhooks - one tab is settings, another logs:

image

@nishitiwari22
Copy link

Is this issue still open? I am looking to contribute to it.

@nijel
Copy link
Member Author

nijel commented Sep 30, 2023

Yes, this is open. There is a similar change happening for add-ons in #10053 , it should at least share the UI.

@nishitiwari22
Copy link

nishitiwari22 commented Sep 30, 2023

@nijel

Okay, so I am trying to understand the particular Python file and I came up with a temporary code:

To resolve the issue of rate-limiting errors being silenced for admins, I made changes in the is_rate_limit_error method of the MachineTranslation class in the weblate/weblate/machinery/base.py file.

def is_rate_limit_error(self, exc):
if isinstance(exc, MachineryRateLimit):
return True
if not isinstance(exc, HTTPError):
return False
# Apply rate limiting for following status codes:
# HTTP 456 Client Error: Quota Exceeded (DeepL)
# HTTP 429 Too Many Requests
# HTTP 401 Unauthorized
# HTTP 403 Forbidden
# HTTP 503 Service Unavailable
if exc.response.status_code in (456, 429, 401, 403, 503):
return True
return False

I am trying to locally run on my machine as well. I'll add more as a move forward if the maintainer allows. Actually, this is my first PR and I want to take some time making it a valuable one. Therefore before committing any change I thought to let the maintainer know about it.

@nijel
Copy link
Member Author

nijel commented Oct 10, 2023

The implementation should be:

  • Add model to store the errors to weblate/machinery/models.py, it needs include engine name, nullable foreign key to Project (for project scoped installations), timestamp and field to store the error

  • Extend MachineTranslation.report_error method to take exception paramater and save the error to the database:

    def report_error(self, message):
    """Wrapper for handling error situations."""
    report_error(cause="Machinery error")
    LOGGER.error(message, self.name)

  • Add UI to list these errors

  • Add a background task to prune these errors after some time (30 days?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adding or requesting a new feature. good first issue Opportunity for newcoming contributors. hacktoberfest This is suitable for Hacktoberfest. Don’t try to spam. help wanted Extra attention is needed.
Projects
None yet
Development

No branches or pull requests

3 participants