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

tropo_pyaps3: add --debug-mode option #1322

Merged
merged 2 commits into from
Feb 10, 2025
Merged

tropo_pyaps3: add --debug-mode option #1322

merged 2 commits into from
Feb 10, 2025

Conversation

yunjunz
Copy link
Member

@yunjunz yunjunz commented Feb 10, 2025

Description of proposed changes

  • tropo_pyaps3.py: add --debug(--mode) option to enable the debug mode to show the full error message of pyaps3 while downloading, to better diagnose new pyaps0.3.6 can not download dataset #1321

  • requirements.txt: set min version of pyaps3 to 0.3.6 for the new CDS website

Reminders

  • Pass Pre-commit check (green)
  • Pass Codacy code review (green)
  • Pass Circle CI test (green)
  • Make sure that your code follows our style. Use the other functions/files as a basis.
  • If modifying functionality, describe changes to function behavior and arguments in a comment below the function declaration.
  • If adding new functionality, add a detailed description to the documentation and/or an example.

Summary by Sourcery

Add a --debug-mode option to show the full error message of pyaps3 while downloading, and set the minimum version of pyaps3 to 0.3.6.

New Features:

  • Added a --debug-mode option to tropo_pyaps3.py to facilitate debugging of pyaps3 downloads.

Tests:

  • Updated the help message to include the new --debug option.

+ tropo_pyaps3.py: add --debug(--mode) option to enable the debug mode to show the full error message of pyaps3 while downloading

+ requirements.txt: set min version of pyaps3 to 0.3.6 for the new CDS website
Copy link

sourcery-ai bot commented Feb 10, 2025

Reviewer's Guide by Sourcery

This pull request introduces a debug mode option for the tropo_pyaps3 process. The changes allow users to run pyaps3 in debug mode so that full error messages are shown without swallowing errors via retries, which aids in diagnosing issues. Additionally, the minimum required version of pyaps3 is updated to 0.3.6 to support the new CDS website.

Sequence diagram for debug mode flow in tropo_pyaps3

sequenceDiagram
  participant User as actor User
  participant CLI as CLI Parser
  participant Main as run_tropo_pyaps3
  participant DL as dload_grib_files
  participant PA as pyaps3

  User->>CLI: Provide CLI command with --debug flag
  CLI->>Main: Parse arguments (debug_mode = True)
  Main->>DL: Call dload_grib_files(..., debug_mode=True)

  alt Debug Mode Enabled
    DL->>PA: Call appropriate download function (ECMWFdload/MERRAdload/NARRdload) without retry
  else Operation Mode
    loop Up to 3 Attempts
      DL->>PA: Call download function (wrapped in try/except)
      PA-->>DL: Return result or error
      alt Error Encountered
        DL-->>DL: Print warning and retry if attempt < 3
      end
    end
  end

  DL-->>Main: Return downloaded grib files
  Main-->>CLI: Continue processing
Loading

File-Level Changes

Change Details Files
Implement debug mode option in tropo_pyaps3 download function
  • Added a new 'debug_mode' parameter to the download function to control error handling behavior.
  • Refactored the download logic to bypass retry loops and exception suppression when in debug mode.
  • Updated CLI argument parser to include the '--debug' or '--debug-mode' flags for enabling debug mode.
src/mintpy/tropo_pyaps3.py
src/mintpy/cli/tropo_pyaps3.py
Update pyaps3 version requirements
  • Modified the minimum version of pyaps3 in requirements.txt from 0.3 to 0.3.6 to support compatibility with the new CDS website.
requirements.txt

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

codeautopilot bot commented Feb 10, 2025

PR Summary

This Pull Request introduces a new --debug-mode option to the tropo_pyaps3.py script, allowing users to enable a debug mode that provides detailed error messages from pyaps3 during the downloading of weather model data. This enhancement aims to facilitate better diagnosis of issues, particularly those related to downloading data, as referenced in issue #1321. Additionally, the minimum version requirement for pyaps3 in requirements.txt has been updated to 0.3.6 to accommodate changes on the new CDS website.

Review Checklist

  • Pass Pre-commit check (green)
  • Pass Codacy code review (green)
  • Pass Circle CI test (green)
  • Ensure code follows the project's style guidelines.
  • Describe changes to function behavior and arguments in comments if functionality is modified.
  • Add detailed documentation or examples for new functionality.

Suggestion

Consider adding unit tests or integration tests to verify the new --debug-mode functionality. This will help ensure that the debug mode behaves as expected and provides the necessary error information without affecting the normal operation of the script.

This comment was generated by AI. Information provided may be incorrect.

Current plan usage: 0%

Have feedback or need help?
Documentation
[email protected]

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.

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

Overall Comments:

  • Consider extracting the download logic into a separate function to improve readability.
  • It might be clearer to use if not debug_mode: instead of else: to enclose the try/except block.
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.

@yunjunz yunjunz merged commit 2dcccde into insarlab:main Feb 10, 2025
7 checks passed
@yunjunz yunjunz deleted the pyaps3 branch February 10, 2025 14:59
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