traitecoevo / APCalign

R package for accessing, matching and updating species names of Australian flora
https://traitecoevo.github.io/APCalign/
Other
4 stars 6 forks source link

Failing gracefully edge case #235

Closed wcornwell closed 1 month ago

wcornwell commented 2 months ago

There is still a CI fail that arises when the network on the computer is up but github specifically is down. That doesn't happen that frequently, but does seem to cause an issue from time to time.

wcornwell commented 2 months ago

something like

   # Check for errors in the response
    if (inherits(response, "try-error") || httr::http_error(response) || !network) {
      message("API currently down, try again later")
      return(invisible(NULL))
    }

might help, but there may need to be changes to the tests also

wcornwell commented 2 months ago

nevermind that approach didn't help, need to get the full error next time it occurs

wcornwell commented 2 months ago
 test_check("APCalign")
Downloading...
trying URL 'https://github.com/traitecoevo/APCalign/releases/download/0.0.2.9000/apc.parquet'
Content type 'application/octet-stream' length 10895737 bytes (10.4 MB)
==================================================
downloaded 10.4 MB

File downloaded successfully.
trying URL 'https://github.com/traitecoevo/APCalign/releases/download/0.0.2.9000/apni.parquet'
Content type 'application/octet-stream' length 27817594 bytes (26.5 MB)
==================================================
downloaded 26.5 MB

File downloaded successfully.

Loading resources into memory...

===========================
=====================================================
================================================================================
...done
API currently down, try again later
API currently down, try again later
Downloading...
  6.       ├─base::tryCatch(...) at APCalign/R/load_taxonomic_resources.R:447:5
  7.       │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
  8.       │   └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
  9.       │     └─base (local) doTryCatch(return(expr), name, parentenv, handler)
 10.       └─utils::download.file(url, path_to_file, mode = "wb") at APCalign/R/load_taxonomic_resources.R:448:7
── Warning ('test-connection.R:11:3'): Complains when network is down ──────────
cannot open URL 'https://github.com/traitecoevo/APCalign/releases/download//apni.parquet': HTTP status was '404 Not Found'
Backtrace:
     ▆
  1. ├─testthat::expect_visible(dataset_access_function()) at test-connection.R:11:3
  2. │ └─base::withVisible(call)
  3. └─APCalign:::dataset_access_function()
  4.   └─APCalign:::dataset_get(version, path) at APCalign/R/load_taxonomic_resources.R:322:7
  5.     └─APCalign (local) download_and_read_parquet(apni.url, path_to_apni) at APCalign/R/load_taxonomic_resources.R:475:5
  6.       ├─base::tryCatch(...) at APCalign/R/load_taxonomic_resources.R:447:5
  7.       │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
  8.       │   └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
  9.       │     └─base (local) doTryCatch(return(expr), name, parentenv, handler)
 10.       └─utils::download.file(url, path_to_file, mode = "wb") at APCalign/R/load_taxonomic_resources.R:448:7
── Warning ('test-connection.R:12:3'): Complains when network is down ──────────
downloaded length 0 != reported length 9
Backtrace:
    ▆
 1. ├─testthat::expect_visible(dataset_get()) at test-connection.R:12:3
 2. │ └─base::withVisible(call)
 3. └─APCalign:::dataset_get()
 4.   └─APCalign (local) download_and_read_parquet(apc.url, path_to_apc) at APCalign/R/load_taxonomic_resources.R:469:5
 5.     ├─base::tryCatch(...) at APCalign/R/load_taxonomic_resources.R:447:5
 6.     │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
 7.     │   └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
 8.     │     └─base (local) doTryCatch(return(expr), name, parentenv, handler)
 9.     └─utils::download.file(url, path_to_file, mode = "wb") at APCalign/R/load_taxonomic_resources.R:448:7
── Warning ('test-connection.R:12:3'): Complains when network is down ──────────
cannot open URL 'https://github.com/traitecoevo/APCalign/releases/download//apc.parquet': HTTP status was '404 Not Found'
Backtrace:
    ▆
 1. ├─testthat::expect_visible(dataset_get()) at test-connection.R:12:3
 2. │ └─base::withVisible(call)
 3. └─APCalign:::dataset_get()
 4.   └─APCalign (local) download_and_read_parquet(apc.url, path_to_apc) at APCalign/R/load_taxonomic_resources.R:469:5
 5.     ├─base::tryCatch(...) at APCalign/R/load_taxonomic_resources.R:447:5
 6.     │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
 7.     │   └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
 8.     │     └─base (local) doTryCatch(return(expr), name, parentenv, handler)
 9.     └─utils::download.file(url, path_to_file, mode = "wb") at APCalign/R/load_taxonomic_resources.R:448:7
── Warning ('test-connection.R:12:3'): Complains when network is down ──────────
downloaded length 0 != reported length 9
Backtrace:
    ▆
 1. ├─testthat::expect_visible(dataset_get()) at test-connection.R:12:3
 2. │ └─base::withVisible(call)
 3. └─APCalign:::dataset_get()
 4.   └─APCalign (local) download_and_read_parquet(apni.url, path_to_apni) at APCalign/R/load_taxonomic_resources.R:475:5
 5.     ├─base::tryCatch(...) at APCalign/R/load_taxonomic_resources.R:447:5
 6.     │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
 7.     │   └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
 8.     │     └─base (local) doTryCatch(return(expr), name, parentenv, handler)
 9.     └─utils::download.file(url, path_to_file, mode = "wb") at APCalign/R/load_taxonomic_resources.R:448:7
── Warning ('test-connection.R:12:3'): Complains when network is down ──────────
cannot open URL 'https://github.com/traitecoevo/APCalign/releases/download//apni.parquet': HTTP status was '404 Not Found'
Backtrace:
    ▆
 1. ├─testthat::expect_visible(dataset_get()) at test-connection.R:12:3
 2. │ └─base::withVisible(call)
 3. └─APCalign:::dataset_get()
 4.   └─APCalign (local) download_and_read_parquet(apni.url, path_to_apni) at APCalign/R/load_taxonomic_resources.R:475:5
 5.     ├─base::tryCatch(...) at APCalign/R/load_taxonomic_resources.R:447:5
 6.     │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
 7.     │   └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
 8.     │     └─base (local) doTryCatch(return(expr), name, parentenv, handler)
 9.     └─utils::download.file(url, path_to_file, mode = "wb") at APCalign/R/load_taxonomic_resources.R:448:7

══ Failed tests ════════════════════════════════════════════════════════════════
── Failure ('test-connection.R:10:3'): Complains when network is down ──────────
default_version() does not invisibly

[ FAIL 1 | WARN 8 | SKIP 0 | PASS 102 ]
Error: Error: Test failures
wcornwell commented 1 month ago

https://github.com/traitecoevo/APCalign/actions/runs/9591549267/job/26870559235

wcornwell commented 1 month ago

fixed here: https://github.com/traitecoevo/APCalign/commit/a99fc67c1c3b10e7dfb863ea5986ea9ea0ab4b4d