Skip to content

style: use glue for line-wrapping in cache warnings #191

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

Merged
merged 2 commits into from
Oct 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions R/cache.R
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,12 @@ cache_epidata_call <- function(epidata_call, fetch_args = fetch_args_list()) {
if (as_of_recent || issues_recent) {
cli::cli_warn(
c(
"using cached results with `as_of` within the past week (or the future!).",
"This will likely result in an invalid cache. Consider\n",
"1. disabling the cache for this session with `disable_cache` or permanently with environmental ",
"variable `EPIDATR_USE_CACHE=FALSE`\n",
"2. setting `EPIDATR_CACHE_MAX_AGE_DAYS={Sys.getenv('EPIDATR_CACHE_MAX_AGE_DAYS', unset = 1)}`",
" to e.g. `3/24` (3 hours)."
"Using cached results with `as_of` within the past week (or the future!).
This will likely result in an invalid cache. Consider",
"i" = "disabling the cache for this session with `disable_cache` or
Copy link
Contributor

Choose a reason for hiding this comment

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

comment: "i" = is "info item", not numbered list, if that was what you were expecting. Here it might look prettier to use "*" for a bulleted list. (Not sure how to do an actual enumeration, but here just an unordered list seems more suitable.)

permanently with environmental variable `EPIDATR_USE_CACHE=FALSE`",
"i" = "setting `EPIDATR_CACHE_MAX_AGE_DAYS={Sys.getenv('EPIDATR_CACHE_MAX_AGE_DAYS
', unset = 1)}` to e.g. `3/24` (3 hours)."
Copy link
Contributor

@brookslogan brookslogan Oct 2, 2023

Choose a reason for hiding this comment

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

todo: This rendered as ℹ setting `EPIDATR_CACHE_MAX_AGE_DAYS=1` to e.g. `3/24` (3 hours). for me. Tweak to remove or reword the =1. [hopefully fixed the GitHub formatting]

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that was intended, to show the current value? though it does look like github is treating the ` strangely.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe we reword it for clarity?

setting `EPIDATR_CACHE_MAX_AGE_DAYS` (currently {Sys.getenv('EPIDATR_CACHE_MAX_AGE_DAYS'
, unset = 1)}) to e.g. `3/24` (3 hours)

Copy link
Contributor

Choose a reason for hiding this comment

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

slight tweak, maybe
setting environment variable `EPIDATR_CACHE_MAX_AGE_DAYS` (currently {Sys.getenv('EPIDATR_CACHE_MAX_AGE_DAYS', unset = 1)}) to e.g. `3/24` (3 hours)

(btw, Sys.getenv's unset parameter will be stringified. Don't think it matters here but I thought I saw some hints of surprise due to this somewhere in the code.)

Copy link
Contributor

Choose a reason for hiding this comment

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

it might also benefit from some extra explanation what it's doing, making sure that they receive any new versions of versions quickly (but with better wording)

),
.frequency = "regularly",
.frequency_id = "cache timing issues",
Expand All @@ -267,8 +267,8 @@ cache_epidata_call <- function(epidata_call, fetch_args = fetch_args_list()) {
if (!is.key_missing(cached)) {
cli::cli_warn(
c(
"loading from the cache at {cache_environ$epidatr_cache$info()$dir}; ",
"see {cache_environ$epidatr_cache$info()$logfile} for more details."
"Loading from the cache at {cache_environ$epidatr_cache$info()$dir};
see {cache_environ$epidatr_cache$info()$logfile} for more details."
),
.frequency = "regularly",
.frequency_id = "using the cache",
Expand All @@ -277,7 +277,6 @@ cache_epidata_call <- function(epidata_call, fetch_args = fetch_args_list()) {
return(cached[[1]])
}
}
'which was saved on {format(cached[[2]],"%A %B %d, %Y")}, which took {round(cached[[3]][[3]], digits=5)} seconds.'
# need to actually get the data, since its either not in the cache or we're not caching
runtime <- system.time(if (epidata_call$only_supports_classic) {
fetched <- fetch_classic(epidata_call, fetch_args)
Expand Down