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

fix: status page and update #166

Merged
merged 17 commits into from
Jan 26, 2025
Merged

fix: status page and update #166

merged 17 commits into from
Jan 26, 2025

Conversation

5hojib
Copy link
Collaborator

@5hojib 5hojib commented Jan 26, 2025

Summary by Sourcery

Update the Docker base image to 5hojib/aeon:beta. Simplify the upstream repository configuration by prioritizing configuration file values over environment variables, and falling back to the default https://github.com/AeonOrg/Aeon-MLTB repository and main branch if neither is set. Improve error handling in the update script by catching all exceptions when loading the configuration file. Remove the unused SEARCH_LIMIT setting and update the status page UI to dynamically generate buttons for filtering by status.

Bug Fixes:

  • Fix an issue where the status page would not display all available statuses when there were more than 20 tasks.

Enhancements:

  • Simplify the upstream repository configuration logic.
  • Improve error handling when loading configuration files.

Copy link
Contributor

sourcery-ai bot commented Jan 26, 2025

Reviewer's Guide by Sourcery

This pull request focuses on improving the robustness of the application by addressing configuration loading, adding support for environment variables, and fixing a bug in the status page. Additionally, it removes an unused variable and updates the base docker image.

Sequence diagram for updated configuration loading process

sequenceDiagram
    participant App
    participant Config
    participant Env
    App->>Config: Load configuration
    alt Config file exists
        Config->>Config: Load from config.py
    else Config file missing
        Config-->>App: Raise Exception
        App->>Env: Fallback to environment variables
    end
    Note over App,Env: New fallback chain for UPSTREAM_REPO and UPSTREAM_BRANCH
    App->>Config: Get UPSTREAM_REPO
    Config-->>App: Return config value
    alt Config value empty
        App->>Env: Get UPSTREAM_REPO
        Env-->>App: Return env value
        alt Env value empty
            App->>App: Use default value
        end
    end
Loading

Class diagram showing configuration changes

classDiagram
    class ConfigManager {
        +load()
        +load_dict(config_dict)
    }
    class Config {
        +UPSTREAM_REPO: str
        +UPSTREAM_BRANCH: str
        -DOWNLOAD_DIR: str
        -LEECH_SPLIT_SIZE: int
        -RSS_DELAY: int
        -DEFAULT_UPLOAD: str
    }
    note for Config "Removed SEARCH_LIMIT and SEARCH_API_LINK"
    ConfigManager --> Config: manages
Loading

State diagram for status page button generation

stateDiagram-v2
    [*] --> CheckStatus
    CheckStatus --> EvaluateConditions: status != "All" OR tasks_no > 20
    EvaluateConditions --> CreateButtons: Conditions met
    CreateButtons --> InitializeButtonMaker: buttons not exists
    InitializeButtonMaker --> AddStatusButtons
    AddStatusButtons --> BuildMenu
    BuildMenu --> [*]: Return button menu
    EvaluateConditions --> [*]: Conditions not met
Loading

File-Level Changes

Change Details Files
Improved configuration loading by adding support for environment variables.
  • Added support for environment variables for UPSTREAM_REPO and UPSTREAM_BRANCH.
  • The application now falls back to environment variables if the values are not found in the config file.
update.py
Fixed a bug in the status page.
  • Added a check to ensure that the buttons object is initialized before adding buttons to it.
bot/helper/ext_utils/status_utils.py
Removed unused SEARCH_LIMIT variable.
  • Removed SEARCH_LIMIT from the default settings.
  • Removed SEARCH_LIMIT from the config loading logic.
bot/modules/bot_settings.py
bot/core/config_manager.py
Updated the base docker image.
  • Changed the base image from 5hojib/aeon:latest to 5hojib/aeon:beta.
Dockerfile
Handled a broader range of exceptions when loading configurations.
  • Changed ModuleNotFoundError to a more general Exception when loading configurations.
update.py
Removed unnecessary calls to initiate_search_tools.
  • Removed calls to initiate_search_tools when updating SEARCH_PLUGINS and SEARCH_API_LINK.
bot/modules/bot_settings.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. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the 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 exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

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
Contributor

@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.

Hey @5hojib - I've reviewed your changes - here's some feedback:

Overall Comments:

  • The change from ModuleNotFoundError to catching all Exceptions is overly broad and could mask real issues. Consider keeping the specific exception handling.
  • Switching from latest to beta Docker image tag may introduce instability. Please provide justification for this change or consider staying with the stable release.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@@ -256,6 +256,8 @@ async def get_readable_message(sid, is_user, page_no=1, status="All", page_step=
if status != "All" or tasks_no > 20:
for label, status_value in list(STATUSES.items()):
if status_value != status:
if not buttons:
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (bug_risk): Initialize 'buttons' variable before the loop to prevent potential UnboundLocalError

The buttons variable should be initialized before the loop to ensure it exists when the condition is checked.

@5hojib 5hojib merged commit 55346eb into main Jan 26, 2025
1 check passed
@5hojib 5hojib deleted the beta branch January 26, 2025 04:20
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