-
Notifications
You must be signed in to change notification settings - Fork 333
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
Make Downloader
Test Suite Resilient to ReadTimeout
#2710
Make Downloader
Test Suite Resilient to ReadTimeout
#2710
Conversation
Thank you for submitting a pull request (PR) to PlasmaPy! ✨ The future of the project depends on contributors like you, so we deeply appreciate it! 🌱 Our contributor guide has information on:
Important PlasmaPy recently switched to an The bottom of this page shows several checks that are run for every PR. Don't worry if something broke! We break stuff all the time. 😺 Click on "Details" to learn why a check didn't pass. Please also feel free to ask for help. We do that all the time as well. 🌸 You can find us in our chat room or weekly community meeting & office hours. Here are some tips:
If this PR is marked as ready for review, someone should stop by to provide a code review and offer suggestions soon. ✅ If you don't get a review within a few days, please feel free to send us a reminder. Please also use SI units within PlasmaPy, except when there is strong justification otherwise or in some examples. We thank you once again! |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2710 +/- ##
==========================================
- Coverage 95.14% 95.11% -0.03%
==========================================
Files 107 107
Lines 9411 9417 +6
Branches 2168 2168
==========================================
+ Hits 8954 8957 +3
- Misses 276 279 +3
Partials 181 181 ☔ View full report in Codecov by Sentry. |
@JaydenR2305 Can you try leaving the timeout at 10s and instead doing something like @pytest.fixture
def check_github_connection():
"""returns True if good connection to github, False otherwise"
@pytest.skipif(check_github_connection)
def test_any_test_using_api_calls My concern with increasing the timeout so long is that it will make CI take that much longer to run, and if a connection really takes > 10 s I'm not optimistic it will complete in 40s? |
Reduce timeout to 10 seconds
Downloader
Test Suite Resilient to ReadTimeout
Fix `_API_CONNECTION_ESTABLISHED`
@pheuer Any idea what's going on with the |
I don't think so - is that in the Langmuir module? You might open an issue about that. Maybe there's a random component in the test (or using hypothesis) that is failing occasionally on some edge value? |
_IS_CI = "GH_TOKEN" in os.environ | ||
|
||
|
||
# TODO: use a config file variable to allow users to set a location | ||
# for the data download folder? | ||
|
||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose this has to be in this main file rather than in the test file since multiple different test files (anything using downloader) will need to access it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, we just import it from there into the test modules that use the downloader directly/indirectly. It would also theoretically be possible to define the connection skipif
decorator in that module as well 🤔
PlasmaPy/src/plasmapy/utils/data/downloader.py Lines 29 to 32 in 4d08880
Would it be fine if I just |
Yes, I don't see a good way to test this (other than simulating a lost connection somehow, but that seems unnecessarily complicated) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JaydenR2305 This all looks good to me - ready to merge?
Resolves
requests.exceptions.ReadTimeout
errors originating from downloader-related testsUpon merging #2555 it was discovered that one of the associated tests can be flaky (see https://github.com/PlasmaPy/PlasmaPy/actions/runs/9349808820/job/25731939682?pr=2709#step:6:310).
I propose we increase the timeout of the get request to 40 seconds to give the server ample time to reply.Additionally, @pheuer suggested implementing a check to ensure if a connection can be established to the server within some timeframe, and simply
@pytest.mark.skip
any relevant tests if (here for my reference) a connection cannot be established.Resolves #2711