Skip to content

tropo_pyaps3: check GAM account info in pyaps3/model.cfg file#639

Merged
yunjunz merged 6 commits intoinsarlab:mainfrom
pbrotoisworo:pyapskey
Aug 14, 2021
Merged

tropo_pyaps3: check GAM account info in pyaps3/model.cfg file#639
yunjunz merged 6 commits intoinsarlab:mainfrom
pbrotoisworo:pyapskey

Conversation

@pbrotoisworo
Copy link
Copy Markdown
Contributor

@pbrotoisworo pbrotoisworo commented Aug 13, 2021

Description of proposed changes

This addresses the error of missing API config for PyAPS. If the user did not input their API credentials in model.cfg in the pyaps3 directory it raised a vague ZeroDivisionError: float division by zero error.

This revision will now raise a ValueError with a more appropriate error message telling users that the API config is missing.

Related to #226.

Reminders

  • 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 adding new functionality, add a detailed description to the documentation and/or an example.

@pbrotoisworo
Copy link
Copy Markdown
Contributor Author

Something I just noticed now: According to this L116 in tropo_pyaps3.py you only accept ERA5.

The PR checks all the tropo models that were in model.cfg (ERA, MERRA, ECMWF, etc). If you are not accepting other models maybe the model.cfg can be cleaned up for clarity. I can also revise the code to remove checks for unused tropo models.

@yunjunz yunjunz self-requested a review August 13, 2021 17:43
@yunjunz
Copy link
Copy Markdown
Member

yunjunz commented Aug 13, 2021

Thank you @pbrotoisworo. I just cleaned up the model.cfg a little bit following your suggestion (yunjunz/PyAPS@3ba82ff).

For the checking here, either removing the other models or keeping them is good to me. If we keep all of them, it will be good to move this checking to an independent function, and call it here.

Below is for your reference:
[CDS] -> ERA5
[ECMWF] -> ERAI
[MERRA] -> MERRA
No checking is required for NARR.
All the others are irrelevant.

@pbrotoisworo
Copy link
Copy Markdown
Contributor Author

@yunjunz. I've created a separate function to check the pyaps config and kept the other tropo models to prevent errors if people want to use them in the future.

The function will check for default values (e.g your-uid:your-api-key) and empty values for the selected tropo model.

@yunjunz yunjunz changed the title Revise error message for missing PyAPS config (#226) tropo_pyaps3: check GAM account info in pyaps3/model.cfg file Aug 14, 2021
Copy link
Copy Markdown
Member

@yunjunz yunjunz left a comment

Choose a reason for hiding this comment

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

Looks great. Thank you @pbrotoisworo for addressing this issue!

@yunjunz yunjunz merged commit a6d5d7c into insarlab:main Aug 14, 2021
@pbrotoisworo pbrotoisworo deleted the pyapskey branch August 15, 2021 10:36
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.

2 participants