SCasanova / f1dataR

An R package to access Formula 1 Data from the Ergast API and the unofficial F1 data stream via the fastf1 python library.
https://scasanova.github.io/f1dataR/
Other
52 stars 5 forks source link

Handle & Test without internet #233

Closed pbulsink closed 6 months ago

codecov[bot] commented 6 months ago

Codecov Report

Attention: Patch coverage is 24.32432% with 56 lines in your changes are missing coverage. Please review.

Project coverage is 51.48%. Comparing base (a1bc9e0) to head (7ca3286).

:exclamation: Current head 7ca3286 differs from pull request most recent head cd38073. Consider uploading reports for the commit cd38073 to get more accurate results

Files Patch % Lines
R/utils.R 35.00% 26 Missing :warning:
R/load_race_session.R 0.00% 15 Missing :warning:
R/plot_fastest.R 0.00% 5 Missing :warning:
R/circuit_details.R 0.00% 3 Missing :warning:
R/load_driver_telemetry.R 0.00% 3 Missing :warning:
R/load_session_laps.R 0.00% 3 Missing :warning:
R/load_circuits.R 50.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #233 +/- ## =========================================== - Coverage 93.95% 51.48% -42.48% =========================================== Files 19 19 Lines 596 641 +45 =========================================== - Hits 560 330 -230 - Misses 36 311 +275 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

pbulsink commented 6 months ago

This concludes covering Ergast related no-internet failures, need to cover FastF1 no-internet yet...

pbulsink commented 6 months ago

This is a big PR.

Beyond minor fixes here and there on top of what I've already pulled to master about being flexible with changing API returns, the big thing is handling no internet connection gracefully.

For Ergast functions, there's a set of escapes via tryCatch that detect if there's an error in establishing and completing the api request. If they're hit, the get_ergast_data() function returns NULL (and displays a message to the user but not a warning). The requesting function detects this NULL return and exits, again returning NULL.

For FastF1 functions, there's two escapes: similar via tryCatch checking the availability of the [livetiming.formula1.com]() web resource, but also verifying that the python functions have been able to download data. If either fail, again, messages are displayed and functions return NULL.