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

rework wikidata and mb delays #1122

Merged
merged 1 commit into from
Dec 25, 2024
Merged

rework wikidata and mb delays #1122

merged 1 commit into from
Dec 25, 2024

Conversation

aw-was-here
Copy link
Collaborator

@aw-was-here aw-was-here commented Dec 25, 2024

Summary by Sourcery

Reduce MusicBrainz timeouts and increase retries. Reduce Wikipedia timeouts and add logging.

Enhancements:

  • Reduce the timeout for MusicBrainz queries from 30 seconds to 15 seconds and increase the maximum number of retries from 1 to 2 to improve responsiveness.
  • Reduce the timeout for Wikipedia queries to 5 seconds and enable logging to improve debugging and error handling.

Copy link

sourcery-ai bot commented Dec 25, 2024

Reviewer's Guide by Sourcery

This pull request reworks the Wikidata and MusicBrainz delays to improve performance and logging.

Sequence diagram for updated API retry and timeout behavior

sequenceDiagram
    participant App
    participant MB as MusicBrainz API
    participant WD as Wikidata API

    Note over App,WD: Updated timeout and retry configuration

    App->>MB: API Request
    alt Success
        MB-->>App: Response (within 15s)
    else Timeout
        MB--xApp: Timeout (after 15s)
        Note over App: Retry up to 2 times
        App->>MB: Retry Request
    end

    App->>WD: Wikidata Request
    alt Success
        WD-->>App: Response (within 5s)
    else Timeout
        WD--xApp: Timeout (after 5s)
        Note over App: Fallback to English if configured
        App->>WD: Request English data
    end
Loading

Class diagram showing configuration changes

classDiagram
    class MusicBrainzHelper {
        +config
        +__init__(config)
    }
    note for MusicBrainzHelper "Changed log level to INFO"

    class WikimediaHelper {
        +config
        -_get_page(entity, lang)
        -_check_missing(metadata)
    }
    note for WikimediaHelper "Added 5s timeout for requests"
Loading

File-Level Changes

Change Details Files
Reduced the MusicBrainz timeout and increased the maximum number of retries.
  • Decreased the timeout from 30 seconds to 15 seconds.
  • Increased the maximum retries from 1 to 2.
nowplaying/musicbrainz.py
Set the logging level for musicbrainzngs to INFO.
  • Changed the logging level from CRITICAL+1 to INFO to provide more detailed logs.
nowplaying/musicbrainz.py
Added a timeout to the Wikimedia API calls.
  • Introduced a 5-second timeout for wptools.page calls to prevent indefinite delays.
nowplaying/artistextras/wikimedia.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

We've reviewed this pull request using the Sourcery rules engine. If you would also like our AI-powered code review then let us know.

Copy link

codecov bot commented Dec 25, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 62.44%. Comparing base (b025b67) to head (f7d2b40).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
nowplaying/artistextras/wikimedia.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1122   +/-   ##
=======================================
  Coverage   62.44%   62.44%           
=======================================
  Files          44       44           
  Lines        7338     7338           
=======================================
  Hits         4582     4582           
  Misses       2756     2756           
Flag Coverage Δ
unittests 62.44% <50.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@aw-was-here aw-was-here merged commit 3c403fc into main Dec 25, 2024
13 of 14 checks passed
@aw-was-here aw-was-here deleted the metadata branch December 25, 2024 04:57
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.

1 participant